Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

genswagger fails on Ubuntu on Windows (WSL): value of type genswagger.alias is not assignable to type genswagger.alias #1092

Closed
leonbloy opened this issue Dec 4, 2019 · 4 comments

Comments

@leonbloy
Copy link

leonbloy commented Dec 4, 2019

I cannot make genswagger work on Ubuntu 18 on Windows (WSL1)

My setup:

$ uname -a
Linux DESKTOP-BGT2SIH 4.4.0-18362-Microsoft #476-Microsoft x86_64 x86_64 x86_64 GNU/Linux
$ go version
go version go1.10.3 gccgo (Ubuntu 8.3.0-6ubuntu1~18.04.1) 8.3.0 linux/amd64

I'm using protoc 3.0.0 from Ubuntu package protobuf-compiler 3.0.0-9.1ubuntu1 amd64
The same happens if I replace the binary (and the include files) from latest version 3.11.1

Tested with this sample.proto file

syntax = "proto3";

message SearchRequest {
  string query = 1;
  int32 page_number = 2;
  int32 result_per_page = 3;
}

message SearchResponse {
  repeated Result results = 1;
}

message Result {
  string url = 1;
  string title = 2;
  repeated string snippets = 3;
}

service SearchService {
  rpc Search (SearchRequest) returns (SearchResponse);
}

Generation works ok

$ protoc --go_out=. sample.proto

But the swagger generation fails systematically:

$ protoc --swagger_out=logtostderr=true:. -I. sample.proto
panic: reflect.Set: value of type genswagger.alias is not assignable to type genswagger.alias [recovered]
        panic: reflect.Set: value of type genswagger.alias is not assignable to type genswagger.alias [recovered]
        panic: reflect.Set: value of type genswagger.alias is not assignable to type genswagger.alias

goroutine 1 [running]:
panic
        ../../../src/libgo/go/runtime/panic.go:554
json.r
        ../../../src/libgo/go/encoding/json/encode.go:293
json.func1
        ../../../src/libgo/go/encoding/json/encode.go:287
panic
        ../../../src/libgo/go/runtime/panic.go:495
json.r
        ../../../src/libgo/go/encoding/json/encode.go:293
json.func1
        ../../../src/libgo/go/encoding/json/encode.go:287
panic
        ../../../src/libgo/go/runtime/panic.go:495
reflect.Value.assignTo
        ../../../src/libgo/go/reflect/value.go:2075
reflect.Value.Set
        ../../../src/libgo/go/reflect/value.go:1213
genswagger.extensionMarshalJSON
        /home/hernan/go/src/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/generator.go:134
github_com_grpc_ecosystem_grpc_gateway_protoc_gen_swagger_genswagger.swaggerInfoObject.MarshalJSON
        /home/hernan/go/src/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/generator.go:86
json.marshalerEncoder
        ../../../src/libgo/go/encoding/json/encode.go:445
encoding_json.structEncoder.encode
        ../../../src/libgo/go/encoding/json/encode.go:639
encoding_json.encodeState.reflectValue
        ../../../src/libgo/go/encoding/json/encode.go:325
encoding_json.encodeState.marshal
        ../../../src/libgo/go/encoding/json/encode.go:298
encoding_json.Marshal
        ../../../src/libgo/go/encoding/json/encode.go:161
genswagger.extensionMarshalJSON
        /home/hernan/go/src/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/generator.go:138
github_com_grpc_ecosystem_grpc_gateway_protoc_gen_swagger_genswagger.swaggerObject.MarshalJSON
        /home/hernan/go/src/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/generator.go:81
json.marshalerEncoder
        ../../../src/libgo/go/encoding/json/encode.go:445
encoding_json.encodeState.reflectValue
        ../../../src/libgo/go/encoding/json/encode.go:325
encoding_json.encodeState.marshal
        ../../../src/libgo/go/encoding/json/encode.go:298
encoding_json.Encoder.Encode
        ../../../src/libgo/go/encoding/json/stream.go:200
genswagger.encodeSwagger
        /home/hernan/go/src/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/generator.go:146
github_com_grpc_ecosystem_grpc_gateway_protoc_gen_swagger_genswagger.generator.Generate
        /home/hernan/go/src/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/genswagger/generator.go:212
main.main
        /home/hernan/go/src/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/main.go:119
--swagger_out: protoc-gen-swagger: Plugin failed with status code 2.

Using the latest go packages:

$ cd /home/hernan/go/src/github.com/grpc-ecosystem/grpc-gateway
/go/src/github.com/grpc-ecosystem/grpc-gateway$ git log
commit 3c06998610d4d2edea99d12228b1f6ea2d943ce4 (HEAD -> master, origin/master, origin/HEAD)
Author: Guilherme Santos <xguiga@gmail.com>
Date:   Tue Dec 3 18:02:09 2019 +0100

    Override operation_id when available
...
@johanbrandhorst
Copy link
Collaborator

Can you try upgrading your Go version? We only support Go 1.12 and 1.13 (those supported by the Go team).

@johanbrandhorst
Copy link
Collaborator

Also, I would recommend using the standard Go compiler, not gccgo. It can be installed from https://golang.org/dl/.

@leonbloy
Copy link
Author

Problem solved after removing gccgo (I actually removed all go packages and reinstalled golang-go)

Currently working with golang-1.10-go

@johanbrandhorst
Copy link
Collaborator

Good to hear 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants