I have this repo in github that have library for cpp and go in same repo. Now how can I create go.mod
in the go
to import it ?
I searched google about that but all are have Separate repo. How can i do it ?
Thanks.
I have this repo in github that have library for cpp and go in same repo. Now how can I create go.mod
in the go
to import it ?
I searched google about that but all are have Separate repo. How can i do it ?
Thanks.
1️⃣. init module in sub dir:
cd /art/art-go
go mod init github.com/srilakshmikanthanp/art/art-go
2️⃣. add missing and remove unused modules for go.mod
file
cd /art/art-go
go mod tidy
3️⃣.❗️ Because you have multimodule project, you have to add version tag with submodule declaration (<submodul_dir_name>/<version>
) to submodule witch fit to Semantic Version specification
git commit -a - m "art/art-go - some changes"
git tag art-go/v1.0.0
git push
git push --tags
4️⃣. ☝ thus, you can import it in other projects
module go mod init github.com/srilakshmikanthanp/otherproject
require github.com/srilakshmikanthanp/art/art-go v1.0.0
go 1.15
4️⃣. ✌ or get
it
go get github.com/srilakshmikanthanp/art/art-go@v1.0.0
Output
go: finding github.com/srilakshmikanthanp/art/art-go v1.0.0