djigoio
(Antonio Djigo)
1
Hi, I’m having an issue with the Go packages, and maybe someone here can clarify the issue.
I have the project structured like this

Also the main.go file it is at the level of the “content” folder.
How can I import the acnhapi.go package called “package acnhapi.go” into bugs.go file? I’ve tried almost everything I could and I cannot find how.
Thanks in advance
codekid
(Ashish Shekar)
2
So importing Go packages can be viewed something like this:
Your go.mod
module myawesomemodule
now each import of your module can be prefixed by this module name
according to your structure
main.go
package main
import "myawesomemodule/content/bugs"
func main() {
bugs.SomeFunc()
}
bugs.go
package bugs
import "myawsomemodule/api"
func SomeFunc() {
api.CallAPI()
}
and so on …
if you are not using go modules yet then it is time to do so by doing go mod init ${your_module_name}
. It makes your life a lot easier.
3 Likes
djigoio
(Antonio Djigo)
3
Awesome, worked perfectly, thanks for the suggestion!
system
(system)
Closed
4
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.