2

I have looked all over for an answer for "go.mod has malformed module path" but I have not found an answer to why I can't get a library I am writing to import. To simplify I have made a tiny library repo: https://github.com/buphmin/test-go-pkg

Note: I am using the stripe api library for structure inspiration. https://github.com/stripe/stripe-go

Problem:

I create a library, go mod init , push code and tag to github. Then try to import package to use the library elsewhere and I get an error message: 'go get: github.com/buphmin/[email protected]: invalid version: go.mod has malformed module path "github.com/buphmin/test-go-pkg/v1" at revision v1.0.0'

I have no idea why this is an issue and I have not found an answer thus far.

Steps to Reproduce

Assuming you have go installed.

  • Create local folder
  • go mod init <your_mod>
  • go get github.com/buphmin/test-go-pkg/v1
  • error occurs

Other info

  • go v1.16
  • ubuntu 18 LTS

go mod file Copied from the source of truth listed above: https://github.com/buphmin/test-go-pkg

module github.com/buphmin/test-go-pkg/v1

go 1.16

Edit - Answer:

My understand now with the help of @Steven Penny is that v1, v2, etc has more significance than just organization. This article explains how go treats that versioning https://www.honeybadger.io/blog/golang-go-package-management.

1
  • 1
    If you need help debugging your go.mod, it would be prudent to include the contents of that file in your question. Commented May 30, 2021 at 21:24

1 Answer 1

5

This:

module github.com/buphmin/test-go-pkg/v1

is not valid. Should be this:

module github.com/buphmin/test-go-pkg
Sign up to request clarification or add additional context in comments.

2 Comments

Hmm, how does it work here then? github.com/stripe/stripe-go/blob/master/go.mod what am I missing? module github.com/stripe/stripe-go/v72
@buphmin you dont have version v72 you have version 1. Anything less than 2, you dont use the v syntax

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.