Install go scenery - cannot use &SceneryDefinition - go

I've got go installed. However, when I do this:
go get -u github.com/dmlittle/scenery
I get:
# github.com/dmlittle/scenery/pkg/parser
go/src/github.com/dmlittle/scenery/pkg/parser/parser.go:98:20: cannot use &SceneryDefinition literal (type *SceneryDefinition) as type lexer.Definition in argument to participle.Lexer:
*SceneryDefinition does not implement lexer.Definition (wrong type for Lex method)
have Lex(io.Reader) (lexer.Lexer, error)
want Lex(string, io.Reader) (lexer.Lexer, error)
go/src/github.com/dmlittle/scenery/pkg/parser/parser.go:116:21: not enough arguments in call to p.ParseString
have (string, *Plan)
want (string, string, interface {}, ...participle.ParseOption)
go/src/github.com/dmlittle/scenery/pkg/parser/scanner.go:39:10: undefined: lexer.Errorf
go/src/github.com/dmlittle/scenery/pkg/parser/scanner.go:82:26: undefined: lexer.Errorf
Any suggestions?

Same issue, seems the prj use dep. I've fixed cloning the repo, then configuring the go module that find the right project dependencies. Then run go get again and the build success:
~/go/src/github.com/dmlittle/scenery (master ✔) ᐅ go run main.go
# github.com/dmlittle/scenery/pkg/parser
pkg/parser/parser.go:98:20: cannot use &SceneryDefinition literal (type *SceneryDefinition) as type lexer.Definition in argument to participle.Lexer:
*SceneryDefinition does not implement lexer.Definition (wrong type for Lex method)
have Lex(io.Reader) (lexer.Lexer, error)
want Lex(string, io.Reader) (lexer.Lexer, error)
pkg/parser/parser.go:116:21: not enough arguments in call to p.ParseString
have (string, *Plan)
want (string, string, interface {}, ...participle.ParseOption)
pkg/parser/scanner.go:39:10: undefined: lexer.Errorf
pkg/parser/scanner.go:82:26: undefined: lexer.Errorf
Init go mod:
~/go/src/github.com/dmlittle/scenery (master ✔) ᐅ go mod init
go: creating new go.mod: module github.com/dmlittle/scenery
go: copying requirements from Gopkg.lock
Check dependencies:
go mod tidy
go: downloading github.com/spf13/cobra v0.0.3
go: downloading github.com/fatih/color v1.7.0
....
Install package:
go get -u github.com/dmlittle/scenery
Works as expected :
~/go/src/github.com/dmlittle/scenery (master ✘)✭ ᐅ ./scenery
Usage:
scenery [flags]
Examples:
terraform plan | scenery
Flags:
-h, --help help for scenery
-n, --no-color Print output without color
--version version for scenery

Related

gcloud functions deploy go runtime error "undefined: unsafe.Slice; Error ID: 2f5e35a0"

While deploying to google cloud function, I am getting this error:
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: # projectname/vendor/golang.org/x/sys/unix
src/projectname/vendor/golang.org/x/sys/unix/syscall.go:83:16: undefined: unsafe.Slice
src/projectname/vendor/golang.org/x/sys/unix/syscall_linux.go:2255:9: undefined: unsafe.Slice
src/projectname/vendor/golang.org/x/sys/unix/syscall_unix.go:118:7: undefined: unsafe.Slice
src/projectname/vendor/golang.org/x/sys/unix/sysvshm_unix.go:33:7: undefined: unsafe.Slice; Error ID: 2f5e35a0
Here's my command:
gcloud functions deploy servicename --region=us-central1 --entry-point=gofunctionname --runtime=go116 --source=.
I am using vendoring to package my dependencies. It's been a while I have updated this function. And first time I noticed this error.
Any help would be much appreciated.
As DazWilkin suggested above, unsafe.Slice was added as part of Go 1.17 and GCP Functions support Go 1.16 as of now.
I had to revert back the golang.org/x/sys module in the go.mod file and it worked for me.
From
golang.org/x/sys v0.0.0-20221010170243-090e33056c14 // indirect
To
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
With this change, I am able to build and deploy the code to Google Cloud Functions.
As of the time of writing this, Google Cloud Functions now supports Go 1.18 and Go 1.19.
Update your project to go119 and you shouldn't have this issue anymore. For example:
gcloud functions deploy servicename --runtime=go119 --region=us-central1

go get github.com/beego/bee Error install

Using the advised install command
go get github.com/beego/bee
Results in the below error:
github.com/gadelkareem/delve/service/rpc2
go/src/github.com/gadelkareem/delve/service/rpc2/client.go:23:5: cannot use &RPCClient literal (type *RPCClient) as type service.Client in assignment:
*RPCClient does not implement service.Client (wrong type for ExamineMemory method)
go/src/github.com/gadelkareem/delve/service/rpc2/server.go:96:52: not enough arguments in call to s.debugger.Restart
Does anyone have an idea on how to solve this?
Refer from this issue, export export GO111MODULE=on before go get.

gcloud app deploy says: exec: "git": executable file not found in $PATH

I am struggling to deploy a simple Go app to Google App Engine flexible environment. (This is a very cut-down version of a larger app.) When I run gcloud app deploy --project=<projectID> it terminates with an error, and has this in its output:
...
Step #0: Status: Downloaded newer image for gcr.io/gcp-runtimes/go1-builder#sha256:68b86e4c97438df4c9e36c55ad724079b453398a0a44c29748fb5685eef73895
Step #0: gcr.io/gcp-runtimes/go1-builder#sha256:68b86e4c97438df4c9e36c55ad724079b453398a0a44c29748fb5685eef73895
Step #0: go: github.com/go-stack/stack#v1.8.0: git init --bare in /workspace/_gopath/pkg/mod/cache/vcs/6963ea18be763686e7a9697733dd92bfcc0d45b687afce82da04992523d91cd1: exec: "git": executable file not found in $PATH
Step #0: go: github.com/inconshreveable/log15#v0.0.0-20200109203555-b30bc20e4fd1: git init --bare in /workspace/_gopath/pkg/mod/cache/vcs/fe2a07d0f4107d9daa39043733e909094a5b926cca44d0f7269e7a2185dbef15: exec: "git": executable file not found in $PATH
Step #0: go: github.com/mattn/go-colorable#v0.1.6: git init --bare in /workspace/_gopath/pkg/mod/cache/vcs/f7e99db597f4d2fe3e4509a9af308dace72a13292b505deb909cd0df29c1468a: exec: "git": executable file not found in $PATH
Step #0: go: error loading module requirements
Finished Step #0
It does work if I delete go.mod, but (I think) I need go.mod to compile and test it locally. It does work if I don't import the external package, but of course I need external packages in my larger app. It does work if I choose the standard environment, but I need the flexible environment for my larger app.
How can I deploy this app successfully to a flexible environment?
My local Go is 1.13, and I have the latest version (292.0.0) of gcloud. Apart from go.sum, the contents of my directory is...
app.yaml:
runtime: go1.12
env: flex
go.mod:
module mymodulename
go 1.13
require (
github.com/go-stack/stack v1.8.0 // indirect
github.com/inconshreveable/log15 v0.0.0-20200109203555-b30bc20e4fd1
github.com/mattn/go-colorable v0.1.6 // indirect
)
main.go:
package main
import (
"fmt"
"net/http"
"os"
"github.com/inconshreveable/log15"
)
func main() {
log := log15.New()
http.HandleFunc("/", helloHandler)
port := os.Getenv("PORT")
if port == "" {
port = "8080"
log.Info("Using default port", "port", port)
}
log.Info("Listening", "port", port)
if err := http.ListenAndServe(":"+port, nil); err != nil {
log.Crit("ListenAndServe", "error", err)
os.Exit(1)
}
}
func helloHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello, there")
}
Thank you.
IIUC Flexible doesn't support modules (Standard does, go figure!).
You can:
either use a custom runtime;
or, delete the go.mod|go.sum and try again.
I copied your app.yaml and main.go and it worked for me.
One change to your app.yaml:
runtime: go
env: flex
Then:
go get github.com/inconshreveable/log15
go run main.go
INFO[05-15|09:33:26] Using default port port=8080
INFO[05-15|09:33:26] Listening port=8080
and:
curl --silent http://localhost:8080
Hello, there
and:
gcloud app deploy --project=${PROJECT}
curl --silent $(\
gcloud app describe \
--project=${PROJECT} \
--format="value(defaultHostname)")
Hello, there

Error when instantiate chaincode

Please help me this issue, error happened when I instantiate my chaincode:
Currently, I guess the issue related to shim package, because I remove it in my utils package, instantiate successfully.
MyChainCode:
import (
"bytes"
"encoding/hex"
"encoding/json"
"fmt"
"strconv"
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric/core/chaincode/shim"
"github.com/hyperledger/fabric/protos/msp"
pb "github.com/hyperledger/fabric/protos/peer"
"github.com/myproj/models"
"github.com/myproj/packages/utils"
)
APIstub shim.ChaincodeStubInterface
...
username, _ = utils.GetCurrentUser(APIstub)
...
My packages
package utils
import (
"github.com/hyperledger/fabric/core/chaincode/shim"
"golang.org/x/crypto/bcrypt"
)
func GetCurrentUser(stub shim.ChaincodeStubInterface) (string, error) {
cert, err := GetCreatorCert(stub)
return cert.Subject.CommonName, err
}
Issue:
Error: Error endorsing chaincode: rpc error: code = Unknown desc =
error starting container: Failed to generate platform-specific docker
build: Error returned from build: 2 "#
~vendor/github.com/hyperledger/fabric/vendor/github.com/docker/docker/pkg/archive
~vendor/github.com/hyperledger/fabric/vendor/github.com/docker/docker/pkg/archive/archive.go:364:5:
hdr.Format undefined (type *tar.Header has no field or method Format)
~vendor/github.com/hyperledger/fabric/vendor/github.com/docker/docker/pkg/archive/archive.go:364:15:
undefined: tar.FormatPAX
~/vendor/github.com/hyperledger/fabric/vendor/github.com/docker/docker/pkg/archive/archive.go:1166:7:
hdr.Format undefined (type *tar.Header has no field or method Format)
~/vendor/github.com/hyperledger/fabric/vendor/github.com/docker/docker/pkg/archive/archive.go:1166:17:
undefined: tar.FormatPAX
Fabric ver 1.1.0
Go ver 1.9.2
I faced the same problem after upgrading fabric to 1.2.0. Fabric 1.2.0 requires go 1.10.x. So I upgraded go lang to 1.10.3 and it worked like a charm.
That can be because you have old version in some files inside your hyperledger/fabric folder.
If you are following the chaincode tutorial, you can just remove your hyperledger/fabric folder.
Regards
I had the same issue by following the documentation.
Switching to branch 'release-1.1' solves the issue.
After cloning the repository proceed with:
hyperleger$ cd fabric
hyperledger/fabric$ git fetch
hyperledger/fabric$ git checkout release-1.1

Golang failes to change the name of imported module

I'm trying to bring SkyDNSv1 back to life and build it from my fork (here is Dockerfile). SkyDNS was really good and simple tool for the quick service discovery, but it wasn't updated for a long time.
There is an error in build process and it's caused by third party library. I cannot figure out why does it happen:
$ docker build --no-cache -t skydns1 .
Sending build context to Docker daemon 1.566 MB
Sending build context to Docker daemon
Step 0 : FROM golang:1.4.2
---> 3e8cb8e0c765
Step 1 : WORKDIR /go/src
---> Running in 3a06cf460ad9
---> 1dd14a099164
Removing intermediate container 3a06cf460ad9
Step 2 : RUN go get github.com/codegangsta/cli
---> Running in eabcfd6fe621
---> c9ea222f2d74
Removing intermediate container eabcfd6fe621
Step 3 : RUN go get github.com/vitalyisaev2/skydns1
---> Running in 3264582b2e7a
# github.com/rcrowley/go-metrics/influxdb
github.com/rcrowley/go-metrics/influxdb/influxdb.go:19: undefined: client.ClientConfig
github.com/rcrowley/go-metrics/influxdb/influxdb.go:38: undefined: client.Series
github.com/rcrowley/go-metrics/influxdb/influxdb.go:44: undefined: client.Series
github.com/rcrowley/go-metrics/influxdb/influxdb.go:52: undefined: client.Series
github.com/rcrowley/go-metrics/influxdb/influxdb.go:60: undefined: client.Series
github.com/rcrowley/go-metrics/influxdb/influxdb.go:70: undefined: client.Series
github.com/rcrowley/go-metrics/influxdb/influxdb.go:82: undefined: client.Series
github.com/rcrowley/go-metrics/influxdb/influxdb.go:93: undefined: client.Series
github.com/rcrowley/go-metrics/influxdb/influxdb.go:106: client.WriteSeries undefined (type *client.Client has no field or method WriteSeries)
INFO[0075] The command [/bin/sh -c go get github.com/vitalyisaev2/skydns1] returned a non-zero code:
But if you look through the file causing this error, you'll notice that Golang is confused about influxdb/client. I think that compiler doesn't replace imported name client with influxClient as it should do:
package influxdb
import (
"fmt"
influxClient "github.com/influxdb/influxdb/client"
"github.com/rcrowley/go-metrics"
"log"
"time"
)
Probably I just missing an obvious mistake. Any help will be appreciated.
The Go compiler doesn't replace or rewrite anything, the code is just wrong. The github.com/rcrowley/go-metrics/influxdb package was written with some other influxdb client code that no longer exists. (Looks like there are a couple github issues open about this already)
If you look at the current influxdb/client package, you'll see there's no Series, ClientConfig, or Client.WriteSeries at all. You'll need to drop the dependency on github.com/rcrowley/go-metrics/influxdb in order to get your project to build.

Resources