Friday, 30 May 2025

GO LANG change module path

 

  • In the root of your project run, for example:


    cd /path/to/your/project go mod init github.com/yourOrg/go-jwt

    This creates a go.mod whose first line is


    module github.com/yourOrg/go-jwt

    (If you’re not pushing to GitHub, you can use any globally unique path—e.g. module example.com/go-jwt.)

  • Update your imports
    Anywhere you wrote


    import "home/jxiang/go-jwt/ai"

    change it to


    import "github.com/yourOrg/go-jwt/ai"

    and similarly for common, db, initializers, router, etc.

  • Rebuild
    Now go build / go run will use the module path and any other developer can clone from your repo and build without needing your local $GOPATH layout.

  • No comments:

    Post a Comment