Can't download koanf version 2.
rts-gordon opened this issue · comments
Describe the bug
Can't compile koanf latest version 2.
To Reproduce
My code is sample:
go.mod
module koanftest
go 1.18
require github.com/knadh/koanf v2.0.0
main.go
package main
import (
"log"
"github.com/knadh/koanf/parsers/toml"
"github.com/knadh/koanf/providers/file"
"github.com/knadh/koanf/v2"
)
func main() {
var k = koanf.New(".")
// Load toml config.
if err := k.Load(file.Provider("mock/mock.toml"), toml.Parser()); err != nil {
log.Fatalf("error loading config: %v", err)
}
k.Print()
}
run "go mod tidy", there are some errors:
D:\koanftest\go.mod:5: require github.com/knadh/koanf: version "v2.0.0" invalid: should be v0 or v1, not v2
Please provide the following information):
- OS: [windows 10]
- Koanf Version [v2.0.0]
But if I changed to version 1.5.0, it is works.
Did I do something wrong? Can you please have a look at this? thank you.
did you try go get github.com/knadh/koanf/v2@latest
inside of your project directory?
Hi @jxsl13
thanks for your answer.
"go mod tidy" will get/download the source code.
I did executed the command again: "go get github.com/knadh/koanf/v2@latest", there are the same errors.
your require statement in your go.mod must end with koanf/v2 instead of koanf, that's what I'm indicating here.
or remove the one without the /v2 and try my suggestion again:
go get github.com/knadh/koanf/v2@latest
require github.com/knadh/koanf v2.0.0
is incorrect. It should be require github.com/knadh/koanf/v2 v2.0.0
Like @jxsl13 suggested, please remove all koanf references from your go.mod and do a go get -u github.com/knadh/koanf/v2@latest
and run a go mod tidy
after that.
Sorry, that is my mistake.
Thanks for all of your help.