Questions tagged [go-generate]

10 questions
5
votes
0 answers

gqlgen: Unwanted Resolver is generated

I'm using gqlgen, and I'd like to add a new method to the Query resolver. The added method looks something like this: type Query { ... Foo(bar: Int!): Foo ... } The type for Foo is already declared in the file and is being mapped properly to a…
Jay K.
  • 546
  • 2
  • 10
  • 17
4
votes
2 answers

GoLand No Tests Were Run

I have a method that I am testing, and everything seems fine. However, when I run the tests in GoLand, I can see in the output that the tests "PASS" but the test runner says "no tests were run". Here's the sample method in calculator.go package…
2
votes
1 answer

golang protobuf can not unmarshal in a generic type

type Msg[T any] interface { *T proto.Message } func Handle[T any, U Msg[T]](cb func(req U) (proto.Message, error)) { msg := new(T) if err := proto.Unmarshal([]byte{}, msg); err != nil { } _, _ = cb(msg) } func main() { …
capsiamese
  • 21
  • 2
2
votes
1 answer

Stringer can't generate constants with values from C enum

I'm trying run generate on CGO project https://github.com/libgit2/git2go locally. I have successfully installed libgit2 system library and can build and test the project with go build -tags static,system_libgit2 and go test -tags…
Kirill
  • 7,580
  • 6
  • 44
  • 95
1
vote
0 answers

Generate code for different requests types from config

I have an app that makes a lot of requests to different urls. Each of them have different request & response structure. Configurations of the requests types located in Mysql databse. It contains next data: URL Method Query params Body…
Bohdan Srdi
  • 144
  • 1
  • 6
1
vote
0 answers

go:generate stringer undeclared name: CONST

I've used stringer to generate a String() method for different types and have put the output directory to stringer/ //go:generate -type TYPE -output stringer/TYPE_string.go But stringer doesn't recognize the package and therefore generates var x…
1
vote
0 answers

gqlgen Resolver func missing OrderBy args in generated code

I am new to go. I am building a project using gqlgen and ent. I have schema.graphql defined as below type IP implements Node { id: ID! created_at: Time! updated_at: Time! response_code: String! ip_address: String! queries(after: Cursor,…
Sujith Shajee
  • 175
  • 5
  • 18
1
vote
1 answer

Go generate only scans main.go

I am having some trouble using go generate to generate a grpc server when running go generate from the root of my project directory. When I run go generate -v it only returns main.go. However, the directives are defined in one the subpackages. If I…
Blokje5
  • 4,763
  • 1
  • 20
  • 37
-1
votes
1 answer

go generate on build stage

In some build systems like gradle or blaze I can generate code (ent or proto) on a build stage and don't add in to a repository. Is it possible to do the same for the go build command?
rdo
  • 3,872
  • 6
  • 34
  • 51
-1
votes
1 answer

generate go files based on protobuf via import

I have two git repositories: common this repository contains protobuf files (.proto), these files should be fetched via git submodule init from other vendor repository. There are also go files with directive: //go:generate protoc --proto_path=a/xxx…
user3930618
  • 99
  • 2
  • 11