protobuf import google/protobuf/timestamp.proto - protocol-buffers

My proto file is:
syntax = "proto3";
import "google/protobuf/timestamp.proto";
service Foo {
rpc now(NowRequest) returns (NowResponse) {}
}
message NowRequest {}
message NowResponse {
google.protobuf.Timestamp now = 1;
}
My command to generate code and the resulting error is:
protoc foo.proto --go_out=plugins=grpc,import_path=proto:internal/proto
foo.proto:3:1: Import "google/protobuf/timestamp.proto" was not found or had errors.
foo.proto:12:3: "google.protobuf.Timestamp" is not defined.
My protoc version is:
protoc --version
libprotoc 3.11.3
I have followed this guide and reviewed this question. How can I import well known types? Do I need to download anything else? How can I tell what are the exact well known types for my current installation? Thank you.

"google/protobuf/timestamp.proto" gets stored in the path : /usr/local/include/google/protobuf
Please check if you have /usr/local/include/google/protobuf directory.
If not, this means there is an error in protobuf installation. Please retrace the installation steps followed or try re-installing.
Please find more help here : https://github.com/grpc-ecosystem/grpc-gateway/issues/422

Related

Golang following container logs undeclared name Log

I'm trying to build a container with testcontainers and output the logs to stdout.
I have followed their documentation (https://golang.testcontainers.org/features/follow_logs/) but when writing the Accept function, I get an error:
func (g *TestLogConsumer) Accept(l Log) {
g.Msgs = append(g.Msgs, string(l.Content))
}
The problem is that I didn't import a certain package, so I can't use "Log".
I get the following error:
undeclared name: Log
The question is, which package should I import. How can I make vscode import these packages automatically for me ? I have installed the go extension, but it doesn't import anything automatically.

golang build at /vendor/github.com/weaveworks/promrus is giving an error: undefined: logrus.Level

I am trying to build the golang package (/vendor/github.com/weaveworks/promrus) in IBM Z (Mainframe). And I am getting an error: ./promrus.go:15:25: undefined: logrus.Level
My go version is: go version go1.16.2 zos/s390x
I have tried to read through the article: https://www.ibm.com/docs/en/sdk-go-zos/1.16?topic=porting-applications-zos
and have added a build constraint (//+build zos) as given below. But still the undefined error is not going away. Is there any way to build? Pls help and thanks in advance.
//+build zos
package promrus
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/sirupsen/logrus" )
// PrometheusHook exposes Prometheus counters for each of logrus' log
levels. type PrometheusHook struct {
counterVec *prometheus.CounterVec }
User opened up an official support Case with IBM and found resolution.

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

How to install ginkgo and gomega using gopkg?

I am trying to install ginkgo and gomega using the gopkg.
It is throwing the following error:
src/gopkg.in/onsi/ginkgo.v1/ginkgo_dsl.go:24:2: use of internal package not allowed
src/gopkg.in/onsi/ginkgo.v1/ginkgo_dsl.go:25:2: use of internal package not allowed
src/gopkg.in/onsi/ginkgo.v1/ginkgo_dsl.go:26:2: use of internal package not allowed
src/gopkg.in/onsi/ginkgo.v1/ginkgo_dsl.go:27:2: use of internal package not allowed
src/gopkg.in/onsi/ginkgo.v1/ginkgo_dsl.go:28:2: use of internal package not allowed
src/gopkg.in/onsi/ginkgo.v1/ginkgo_dsl.go:29:2: use of internal package not allowed
src/gopkg.in/onsi/gomega.v1/gomega_dsl.go:21:2: use of internal package not allowed
src/gopkg.in/onsi/gomega.v1/gomega_dsl.go:22:2: use of internal package not allowed
src/gopkg.in/onsi/gomega.v1/gomega_dsl.go:23:2: use of internal package not allowed
To my understanding, this is not a fatal error. I was able to download both ginkgo and gomega using gopkg even though I got the same warning messages. A brief look at the source code shows that gomega_dsl.go and ginkgo_dsl.go import code from an internal subdirectory. I do not see why that should be a problem, though. Getting the packages worked despite these warnings.

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