How to import specific version of 3rd party library in Go Playground?

693 Views Asked by At

Let's say I want to import version v0.11.0 of Slack Go package.

In CLI I would call: go get github.com/slack-go/[email protected] but in Go Playground I can only use import.

I've tried import "github.com/slack-go/[email protected]" but that didn't work.

How can I import version v0.11.0 of Slack Go package in Go Playground?

1

There are 1 best solutions below

0
JimB On BEST ANSWER

The version you import is determined by go.mod, and go get modifies go.mod, so include the go.mod in the playground example.

package main

import "github.com/slack-go/slack"

func main() {
    _ = slack.New("YOUR_TOKEN_HERE")
}
-- go.mod --
module play.ground

require github.com/slack-go/slack v0.11.0

https://go.dev/play/p/cBt7MR4Kf03