I was using this set library golang-set. I get the following error when trying to create a set:
invalid operation: cannot index mapset.NewSet (value of type func(s ...interface{}) mapset.Set)
Here is the full code
package main
import (
mapset "github.com/deckarep/golang-set"
)
func main() {
mySet := mapset.NewSet[string]()
}
I'm using go version 1.18.2 on Ubuntu, the code is exactly how it appears on the documentation.
As Joachim Isaksson noted, it should be imported as
import (
mapset "github.com/deckarep/golang-set/v2"
)
also in go.mod the version should be 2xx, as of now it is at 2.1.0
require github.com/deckarep/golang-set/v2 v2.1.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With