[go] How I can use imports modules

hi, I have this modul github.com/nikandfor/spintax

I install it go get -u github.com/nikandfor/spintax/...

and how I can to announce it in my program?

Use the import directive:

import "github.com/nikandfor/spintax"

Note that the string after import is NOT a URL although it looks like one. It is a local path.

With Go modules (available as an experimental feature since Go 1.11, go get takes care of storing the code somewhere (the compiler will know where).
With the old GOPATH system, go get stores the code at the path $GOPATH/src/github.com/nikandfor/spintax.

after do that I get 2 folders in directory my app

but I still did not find the answer

“go get” is part of the Go system. It fetches a module from the web and stores it on your computer. When you compile and import it the compiler know where to find it. You dont need to worry about it.

As you use go, you will likely start writing your own modules. The module system is well designed in that the system works as you would want/expect it to work. It is also well documented, so it is a pleasure to RTFM.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.