gotext: extract failed: pipeline: golang.org/x/text/message is not imported - go

I am trying to run the following command from within my template.go file:
//go:generate gotext -srclang=en update -out=catalog.go -lang=en,de_DE,es_MX,fr_CA,pt_BR
I am expected to get a catalog.go generated, but instead, I get the following error:
gotext: extract failed: pipeline: golang.org/x/text/message is not imported
template.go:3: running "gotext": exit status 1
I do have the following import in the template.go after the generate command:
import (
"time"
log "github.com/sirupsen/logrus"
"golang.org/x/text/message"
)
I've tried to move the import before the generate command. I've also tried to run generate ./... from within the root of the project. I've also tried to run gotext by itself, but it's the same error message.
I also found the following thread on github:
https://github.com/golang/go/issues/26312
I've tried what was suggested there, but it didn't seem to have solved the issue either.

I have solved the issue by running rm -rf vendor/golang.org/x/text command from the root of the project. Of course for things to work, I also needed to have gotext installed. This can be done by running go get golang.org/x/text/cmd/gotext.
I believe the issue could be solved if binaries of .../text/message are installed in the GOPATH/bin as well

Related

generating core failed while doing gqlgen init

I'm attempting to follow this tutorial to set up a GraphQL server in Golang: https://www.howtographql.com/graphql-go/1-getting-started/
However, when I get to the part to run go run github.com/99designs/gqlgen init, I keep getting this error:
generating core failed: unable to load github.com/moonlightfight/elo-backend/graph/model - make sure you're using an import path to a package that exists
Not sure what I'm doing wrong...
Did run go mod init github.com/moonlightfight/elo-backend, so don't know if there's anything else I need to run that this didn't mention.

unable to get hashicorp / vault

I need to use kmac Hashicorp's Vault implementation. However, when I run the code, the following simple import:
import (
"encoding/hex"
"fmt"
"github.com/hashicorp/vault/sdk/helper/kmac"
)
throws this error: no required module provides package github.com/hashicorp/vault/sdk/helper/kmac/kmac; to add it: go get github.com/hashicorp/vault/sdk/helper/kmac/kmac
If I run:
go get github.com/hashicorp/vault/sdk/helper/kmac/kmac
I get:
go get: module github.com/hashicorp/vault/sdk#upgrade found (v0.2.0), but does not contain package github.com/hashicorp/vault/sdk/helper/kmac/kmac
I also tested to download the latest version but I get the same error. Can I get help?

How do you install subcommands?

I am getting the following error message in Go v. 1.15.8 darwin/amd64
main.go:8:2: cannot find package "github.com/google/subcommands" in any of:
/usr/local/go/src/github.com/google/subcommands (from $GOROOT)
/Users/user1/go/src/github.com/google/subcommands (from $GOPATH)
The code in main.go looks like:
package main
import (
"flag"
"context"
"os"
"github.com/google/subcommands"
)
I know subcommands is located here: https://github.com/google/subcommands
with the git repo here: https://github.com/google/subcommands.git
But how do I install it?
When I do:
go get github.com/google/subcommands
I get the following error message:
# cd .; git clone -- https://github.com/google/subcommands /Users/user1/go/src/github.com/google/subcommands
Cloning into '/Users/user1/go/src/github.com/google/subcommands'...
fatal: unable to access 'https://github.com/google/subcommands/': Could not resolve host: github.com
package github.com/google/subcommands: exit status 128
When I open my web browser and go to: https://github.com/google/subcommands/ I can see the web page with no problems. So why is the "go get" command having trouble with this?
What am I doing wrong?
In addition of git config, you can also check your environment variable for HTTP_PROXY/HTTPS_PROXY
But more importantly, check if adding GOPROXY=https://proxy.golang.org could help (there are other Go module proxies as well)
This could help getting modules from any provider, GitHub or others.

Problem when installing the cover package for golang

I have some code.
But when
I try run cover test and have response:
'go get -u github.com/gregoryv/uncover/...
go test -coverprofile /tmp/c.out
uncover /tmp/c.out'
I try install cover package:
go get code.google.com/p/go.tools/cmd/cover
but get error
package code.google.com/p/go.tools/cmd/cover: unrecognized import path "code.google.com/p/go.tools/cmd/cover" (parse https://code.google.com/p/go.tools/cmd/cover?go-get=1: no go-import meta tags (meta tag github.com/golang/go did not match import path code.google.com/p/go.tools/cmd/cover))
System: Ubuntu 18.04
The correct path is:
go get golang.org/x/tools/cmd/cover

Why get 'use of internal package not allowed' error when importing an internal package?

I'm running go-ethereum test codes for eth package.
When I run go test . under the eth directory, I get the following error :
eth/api.go:37:2: use of internal package not allowed
37th line of eth/api.go is as follows :
"github.com/ethereum/go-ethereum/internal/ethapi"
From what I understand, this import should not be calling the error, as this file is within go-ethereum project directory.
Running the same test command on others' machine does not produce this error, so I suspect that there is something wrong with my go settings.
What would be the problem? Appreciate your help

Resources