Reputation: 41
Usually i import local packages by
import "github.com/crsov/myproj/mypkg"
but when i am editing them i need to go get -u "github.com/crsov/myproj/mypkg"
every save.
That's the best way to import local package? I have found many answers to this question but most of them are for older golang versions.
Upvotes: 1
Views: 2798
Reputation: 1
If you have a local package that is very new and has not stabilized, you can do this instead:
go mod init mypkg
and import like this:
import "mypkg"
then you don't have to worry about pulling from the internet, it will just pull from the local directory. Then once your package stabilizes, you can rename so that it can be properly published for others to use.
https://golang.org/doc/code.html
Upvotes: 2