#Trouble using a module that I've published to github

18 messages · Page 1 of 1 (latest)

nimble depot
#

Hello,
I published a couple of modules to github, with this folder structure


project/
├─ server/
│  ├─ main.go
│  ├─ go.mod
├─ api-routes/
│  ├─ functionality.go
│  ├─ go.mod
├─ go.work

I'm developing a separate wails app that needs to import api-routes. The error I encounter is that github.com/.../api-routes refers to itself as "api-routes" only.

  1. Is there any way I can preserve this package structure while getting to use the module's functionality? I don't want to break it up into multiple small repositories.
  2. I do know I'm not supposed to publish go.work but I will research a solution to that later.
  3. I could edit the package name to be github.com/.../api-routes, but I'm not sure what the consequences of that are so I haven't done it yet.
forest echo
#

Why are you trying to use multiple go.mod?

chilly zephyr
#

For example, you'd tag it with server/v1.2.3 and api-routes/v1.3.5

#

Then to add those modules as dependencies, you'd go get the github repo name, with the sub-directory on the end. So, if your repo is github.org/user/repo, you'd do go get github.org/user/repo/server

nimble depot
#

server.go is under package main and I would like to commit it to VCS. Is there any other way I can go about it?

forest echo
nimble depot
#

Yeah, I don't want to do it either but I found no other solution when I introduced the main method

#

is there any reference repo that I could look at?

#

@forest echo

forest echo
#

AWS SDK for Go has multiple modules in the same repository.
But you still haven't answered the first question.
Why are you using multiple go.mod?

nimble depot
#

two packages, two go.mod files

forest echo
#

What doesn't work?

nimble depot
#

building

forest echo
#

You don't need multiple go.mod. You need one, in the root of your project.

nimble depot
#

I fixed it, thanks!

#

how can I close this thread?