I started studying go. I started studying gRPC. First, I tried this. I stumbled more than I expected, so I'll keep a record. Quick start – gRPC
I'm not sure about go or gRPC.
The environment used this docker image. By name, I did it because I wanted it. grpc/go - Docker Hub
Docker I launched it like this. Docker I'm not sure.
docker pull grpc/go
docker run --name grpc-go -it grpc/go /bin/bash
Quick Start Execute in order according to Quick Start.
When you execute the following command,
$ go run greeter_server/main.go
I get an error like this.
cannot find package "golang.org/x/net/http2"
And
undefined: "github.com/golang/protobuf/proto".ProtoPackageIsVersion4
I put in something that seems necessary, and put it back in with the following command.
go get golang.org/x/sys/unix
go get golang.org/x/net/http2
go get google.golang.org/genproto/googleapis/rpc/status
go get -u github.com/golang/protobuf/proto
The last one imitated the copy and paste and added -u
, but I'm not sure.
It looks like an update.
go - The Go Programming Language
The -u flag instructs get to update modules providing dependencies of packages named on the command line to use newer minor or patch releases when available. Continuing the previous example, 'go get -u A' will use the latest A with B v1.3.1 (not B v1.2.3). If B requires module C, but C does not provide any packages needed to build packages in A (not including tests), then C will not be updated.
When the above error appeared, I used the following command to erase it and reinsert it, so I couldn't understand the version.
I want to understand it soon. I did rm
, but by the way, I didn't delete the binary file. What happened? Was it overwritten?
rm -rf /go/src/github.com/golang/protobuf/proto
rm -rf /go/src/google.golang.org/grpc/
git clone https://github.com/grpc/grpc-go
When an error occurred, I referred to here. Go Frequently Asked Questions | Protocol Buffers | Google Developers
With the above correspondence, the first server and client worked. After that, when I did SayHello Again, I was told that it was undefined.
$ go run greeter_client/main.go
# command-line-arguments
greeter_client/main.go:59:12: c.SayHelloAgain undefined (type helloworld.GreeterClient has no field or method SayHelloAgain)
The pb" google.golang.org/grpc/examples/helloworld/helloworld "
in main.go
was suspicious, so if you follow the path, you'll see/ go / src / google.golang.org There was an old
helloworld.proto in / grpc / examples / helloworld / helloworld
.
I wasn't sure what to do, but I overwrote the modified ~ / grpc-go / examples / helloworld / helloworld
to the above path.
When I ran server and client again, it worked as expected.
For the time being, it was good. hello world
is done.
The environment when it finally moved is like this.
I'm not sure how to check the version entered with go get
.
GOPATH
is an image of docker pull
and is included by default.
.bashrc
works even if it's empty.
# go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build743505095=/tmp/go-build -gno-record-gcc-switches"
# go version
go version go1.10.4 linux/amd64
# protoc --version
libprotoc 3.6.0
I was able to do something like Hello World. There are so many things I don't understand, so let's study while studying little by little.
Recommended Posts