Support for go submodules #8820

Closed
opened 2025-11-02 08:19:52 -06:00 by GiteaMirror · 3 comments
Owner

Originally created by @Codebreaker101 on GitHub (Apr 12, 2022).

Feature Description

Following this guide on using go submodules I was able to recreate the functionality on GitHub, but when I moved to my private Gitea instance I was greeted with this error:

go: finding module for package git.example.com/Codebreaker101/testgo/b
go: downloading git.example.com/Codebreaker101/testgo v0.0.0-20220412181549-3b716bc4b575
git.example.com/Codebreaker101/testgo/a imports
        git.example.com/Codebreaker101/testgo/b: module git.example.com/Codebreaker101/testgo@latest found (v0.0.0-20220412181549-3b716bc4b575), but does not contain package git.example.com/Codebreaker101/testgo/b

You can use this script to test (just replace git.example.com/Codebreaker101/testgo with your own repo)

# init repo
go mod init git.example.com/Codebreaker101/testgo
git add go.mod
git commit -q -am 'Initial commit'
git push -q

# create b submodule
mkdir b
cd b
cat <<EOD >b.go
package b

const Name = "Gopher"
EOD
go mod init git.example.com/Codebreaker101/testgo/b
go test

# commit and tag b submodule
cd ..
git add b
git commit -q -am 'Add package b'
git push -q
git tag b/v0.1.1
git push -q origin b/v0.1.1


# create example
mkdir a
cd a
cat <<EOD >a.go
package main

import (
	"git.example.com/Codebreaker101/testgo/b"
	"fmt"
)

const Name = b.Name

func main() {
	fmt.Println(Name)
}
EOD
go mod init git.example.com/Codebreaker101/testgo/a
go mod tidy

Relevant docs:

  1. https://go.googlesource.com/proposal/+/master/design/24301-versioned-go.md#proposal
  2. https://github.com/golang/go/wiki/Modules#publishing-a-release

Screenshots

No response

Originally created by @Codebreaker101 on GitHub (Apr 12, 2022). ### Feature Description Following [this guide](https://github.com/go-modules-by-example/index/blob/master/009_submodules/README.md) on using go submodules I was able to recreate the functionality on GitHub, but when I moved to my private Gitea instance I was greeted with this error: ``` go: finding module for package git.example.com/Codebreaker101/testgo/b go: downloading git.example.com/Codebreaker101/testgo v0.0.0-20220412181549-3b716bc4b575 git.example.com/Codebreaker101/testgo/a imports git.example.com/Codebreaker101/testgo/b: module git.example.com/Codebreaker101/testgo@latest found (v0.0.0-20220412181549-3b716bc4b575), but does not contain package git.example.com/Codebreaker101/testgo/b ``` You can use this script to test (just replace `git.example.com/Codebreaker101/testgo` with your own repo) ``` # init repo go mod init git.example.com/Codebreaker101/testgo git add go.mod git commit -q -am 'Initial commit' git push -q # create b submodule mkdir b cd b cat <<EOD >b.go package b const Name = "Gopher" EOD go mod init git.example.com/Codebreaker101/testgo/b go test # commit and tag b submodule cd .. git add b git commit -q -am 'Add package b' git push -q git tag b/v0.1.1 git push -q origin b/v0.1.1 # create example mkdir a cd a cat <<EOD >a.go package main import ( "git.example.com/Codebreaker101/testgo/b" "fmt" ) const Name = b.Name func main() { fmt.Println(Name) } EOD go mod init git.example.com/Codebreaker101/testgo/a go mod tidy ``` Relevant docs: 1. https://go.googlesource.com/proposal/+/master/design/24301-versioned-go.md#proposal 2. https://github.com/golang/go/wiki/Modules#publishing-a-release ### Screenshots _No response_
GiteaMirror added the type/featuretype/proposal labels 2025-11-02 08:19:52 -06:00
Author
Owner

@42wim commented on GitHub (Apr 12, 2022):

Didn't test your script yet, but we're using go submodules on our instance and this works just fine.

@42wim commented on GitHub (Apr 12, 2022): Didn't test your script yet, but we're using go submodules on our instance and this works just fine.
Author
Owner

@Codebreaker101 commented on GitHub (Apr 13, 2022):

I don't know then what am I doing wrong.

// go.mod
module git.example.com/Codebreaker101/testgo

go 1.17

// a/go.mod
module git.example.com/Codebreaker101/testgo/a

go 1.17

// a/a.go
package main

import (
        "git.example.com/Codebreaker101/testgo/b"
        "fmt"
)

const Name = b.Name

func main() {
        fmt.Println(Name)
}

// b/go.mod
module git.example.com/Codebreaker101/testgo/b

go 1.17

// b/b.go
package b

const Name = "Gopher"

Screenshot from 2022-04-13 07-17-37

@Codebreaker101 commented on GitHub (Apr 13, 2022): I don't know then what am I doing wrong. ``` // go.mod module git.example.com/Codebreaker101/testgo go 1.17 // a/go.mod module git.example.com/Codebreaker101/testgo/a go 1.17 // a/a.go package main import ( "git.example.com/Codebreaker101/testgo/b" "fmt" ) const Name = b.Name func main() { fmt.Println(Name) } // b/go.mod module git.example.com/Codebreaker101/testgo/b go 1.17 // b/b.go package b const Name = "Gopher" ``` ![Screenshot from 2022-04-13 07-17-37](https://user-images.githubusercontent.com/16204269/163105481-42420144-d604-43fe-b62a-b6a3bca9e5f7.png)
Author
Owner

@Codebreaker101 commented on GitHub (Apr 13, 2022):

I was running an older version of Gitea (1.14.1)

Using the latest version fixes the problem.

@Codebreaker101 commented on GitHub (Apr 13, 2022): I was running an older version of Gitea (`1.14.1`) Using the latest version fixes the problem.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#8820