4

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/datelist-sdk-golang@v1.0.0: 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

Alexis Clarembeau
  • 2,776
  • 14
  • 27
  • 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. – colm.anseo Aug 08 '21 at 13:29

1 Answers1

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/datelist-sdk-golang@v1.0.1

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

colm.anseo
  • 19,337
  • 4
  • 43
  • 52
  • 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? – Alexis Clarembeau Aug 09 '21 at 04:17
  • [go.mod tagged v1.0.1](https://github.com/Datelist/datelist-sdk-golang/blob/v1.0.1/go.mod) still has the bad suffix. The [latest commit f5c4a5 go.mod](https://github.com/Datelist/datelist-sdk-golang/commit/f5c4a559439199160c5be22c99f59282b902df90) 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 say`v1.0.2`. – colm.anseo Aug 09 '21 at 13:24
  • FYI: your latest command attempt almost worked, I think you meant: `GOPROXY=https://proxy.golang.org GO111MODULE=on go get github.com/datelist/datelist-sdk-golang@v1.0.2-0.20210809041300-f5c4a5594391` (i.e. no `/@v/`) – colm.anseo Aug 09 '21 at 14:08