Publishing a golang module: Semantic versioning
Asked Answered
H

1

6

I've been trying to create and publish a golang SDK for my web application: https://datelist.io Everything works well on my local setup. However, things are started to get more difficult once I'd like to publish my SDK to the https://pkg.go.dev/ website

The code I'd like to publish is available there: github.com/datelist/datelist-sdk-golang

I've read a few tutorials, and, if I understand correctly, all I needed was to:

  • Create my public repository
  • Add a go.mod file at the root of my repository
  • Ask the proxy.golang.org website to index my changes

I've tried different ways to index my changes, and, according to that link: https://go.dev/about/ Once solution is to visit that page: https://proxy.golang.org/MYMODULE_PATH

I've thus tried: https://proxy.golang.org/github.com/datelist/datelist-sdk-golang/@v/v1.0.0.info

However, I've got the following error: not found: github.com/datelist/[email protected]: invalid version: unknown revision v1.0.0

I've tried different things. I've published two tags on my github repository: v1.0.0 and 1.0.0 and it doesn't work. I've checked: my code looks valid, and the version seems to exist, as I can go to: https://proxy.golang.org/github.com/datelist/datelist-sdk-golang/@v/ce18fa0756c2.info However, I'm stuck when it comes to adding my SDK to go.dev

Thanks in advance

Headway answered 8/8, 2021 at 5:5 Comment(1)
Your module in its current state is not valid which is why its not visible via the proxy. See below on how to remediate your module issue.Holleran
H
2

Your go.mod (latest commit ce18fa) module name is incorrect (/v1.0.0 is not needed):

module github.com/datelist/datelist-sdk-golang/v1.0.0

the go.mod at git release tag v1.0.0 points to an import path datelist.io/sdk that does not exist:

module datelist.io/sdk

Update your go.mod to this (valid URL - with no tag suffix):

module github.com/datelist/datelist-sdk-golang
    
go 1.16

and then git tag this committed release as say v1.0.1 - and that should make your module work.

Consumers of your library can then:

go get github.com/datelist/datelist-sdk-golang

or explicitly:

go get github.com/datelist/[email protected]

The former implicitly chooses the latest semver version via git tags - v1.0.1 in this case.

Holleran answered 8/8, 2021 at 12:52 Comment(3)
Thanks a lot for the detailed reply. Indeed, it looks like a bad mistake. Now that I fixed it, I get the following error: GOPROXY=https://proxy.golang.org GO111MODULE=on go get github.com/datelist/datelist-sdk-golang/@v/v1.0.2-0.20210809041300-f5c4a5594391 go get: package github.com/datelist/datelist-sdk-golang is in the main module, so can't request version v/v1.0.2-0.20210809041300-f5c4a5594391 Could you help me to understand it?Headway
go.mod tagged v1.0.1 still has the bad suffix. The latest commit f5c4a5 go.mod is correct - but not tagged with a semver. You can verify that this works by GOPROXY=https://proxy.golang.org GO111MODULE=on go get github.com/datelist/datelist-sdk-golang@f5c4a559439199160c5be22c99f59282b902df90. But obviously its better to get a semver for this release, so tag f5c4a5... with a git tag of sayv1.0.2.Holleran
FYI: your latest command attempt almost worked, I think you meant: GOPROXY=https://proxy.golang.org GO111MODULE=on go get github.com/datelist/[email protected] (i.e. no /@v/)Holleran

© 2022 - 2024 — McMap. All rights reserved.