-2

I am trying to import a local file into my main.go file and this tutorial (and other similar tutorials) says to run go install <path> in order to import that path as a package. This seems like a slow way to develop local packages because you would have to run go install <path> every time you want to see the changes in your local package.

Is there a faster way to import/update local packages? I am using gomon to auto-reload my code after updating it, so ideally, my code would auto-reload after updating a local package.

sdfsdf
  • 5,052
  • 9
  • 42
  • 75
  • 1
    Use the official documentation, not random blog posts which are often out of date or incorrect. In order to see changes, you need to compile the program. There's no way around that, and `go install` will be the fastest way to do it (if you're not calling it directly, something else is) – JimB Dec 06 '19 at 14:24

1 Answers1

2

You should use go modules. The tutorial you mentioned appears to be older than the modules feature. In short: you can import a package, run go build, and any imported external package will automatically be downloaded for you as needed, no need to do a go get. Start here:

https://blog.golang.org/using-go-modules

https://github.com/golang/go/wiki/Modules

Burak Serdar
  • 46,455
  • 3
  • 40
  • 59