Go local package development

Hi,

I’m new to Go and I’m trying to develop my own library. I can successfully push my code to Github and use these packages in my projects.

 package main
 
 import "github.com/fredericdepuydt/go-libraries/echo"
 
 func main() {
     echo.Error("An error message")
     echo.Warning("A warning")
     echo.Comment("Comment")
 }

I’d like to develop this library further without pushing every line of code to Github before testing.
Currently this isn’t possible as my local repo’s are being ignored and the latest remote git is pulled and used.

I’ve tried to add the folder structure

src
   github.com
      fredericdepuydt
         go-libraries
           echo
             echo.go
           color
             color.go

to both the GOPATH and the GOROOT, but during every build or run, the compiler tries to retrieve everything from the online repository.

I’m developing in VScode using the Go extension (by Google).

How do I force my local repository to be used by Go?

Kind regards,
Frederic Depuydt

You don’t seem to be using Go modules. Doing this is higly recommended.

With modules, you can use the replace directive to point to a local copy of a library.

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