Hi everyone,
Can anyone help me with this issue? Any help is APPRECIATED!
I’m trying to access the consul API fully with this package:
“github [slash] github[dot]com/hashicorp/consul/api”
I installed it on my Windows machine and imported it into my Go script, however it seems to have a dependency with this package:
“src[slash] github[dot]com/armon/go-metrics”
Whenever I run the script (which actually should have worked) or run this command “go get -u [github]github[dot]com/armon/go-metrics” to update the version of the package I get this message:
# “src[slash] github[dot]com/armon/go-metrics”
“src[slash] go\src\github[dot]com\armon\go-metrics\start.go:37:17: cannot use generic type iradix.Tree[T any] without instantiation”
“src[slash] go\src\github[dot]com\armon\go-metrics\metrics.go:166:23: cannot infer T (“src[slash]go\src\github[dot]com\hashicorp\go-immutable-radix\iradix.go:32:10”)”
These are my imports:
import (
"encoding/json"
"fmt"
"github[dot]com/go-git/go-git"
"github[dot]com/go-git/go-git/plumbing/transport/http"
"github[dot]com/hashicorp/consul/api"
"github[dot]com/hashicorp/hcl/hclsimple"
)
This is the function where I create an API client (It’s not completed yet!)
func createACLToken(file_name string) {
// Create a new api.Client object to connect to the Consul server
client, err := api.NewClient(api.DefaultConfig())
if err != nil {
log.Fatal(err)
}
// Read the ACL token configuration from the .hcl file
var token_config api.ACLToken
err = hclsimple.DecodeFile(fmt.Sprintf("%s.hcl", file_name), nil, &token_config)
if err != nil {
log.Fatal(err)
}
acl := client.ACL()
/// Create a new policy with the same name as the ACL token
policy := api.ACLPolicy{Name: file_name, Rules: token_config.Rules}
createdPolicy, writeMeta, err := acl.PolicyCreate(&policy, nil)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Policy created: %v\nWriteMeta: %v\n", createdPolicy, writeMeta)
// // Create a new role with the same name as the ACL token
// role := api.ACLRole{Name: file_name, Policies: []string{file_name}}
// _, err = acl.RoleCreate(&role, nil)
// if err != nil {
// log.Fatal(err)
// }
}
I also checked these packages in GOPATH directory and they are available:
“…go\src\github[dot]com\armon\go-metrics”
“…go\src\github[dot]com\armon\go-radix”
“…go\src\github[dot]com\hashicorp\consul\api”
“…go\src\github[dot]com\hashicorp\hcl\hclsimple”