Skip to content

Commit

Permalink
Merge pull request #57 from izumin5210/izumin5210/fix
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
izumin5210 authored Apr 14, 2018
2 parents 4201514 + c6ffe52 commit df11cb8
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@ required = [
"github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger",
]

[prune]
go-tests = true
unused-packages = true

[[prune.project]]
name = "github.com/grpc-ecosystem/grpc-gateway"
non-go = false
unused-packages = false

[[constraint]]
name = "github.com/izumin5210/grapi"
version = ""
Expand Down
2 changes: 1 addition & 1 deletion pkg/grapicmd/internal/module/generator/template/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
var _Command9acbc40e153d42b0b3e06ca83e7c53e3670d8cdc = "package main\n\nimport (\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc main() {\n\tos.Exit(run())\n}\n\nfunc run() int {\n\tfmt.Println(\"It works!\")\n\treturn 0\n}\n"

// Command returns go-assets FileSystem
var Command = assets.NewFileSystem(map[string][]string{"/": []string{}, "/cmd": []string{}, "/cmd/{{ .name }}": []string{"run.go.tmpl"}}, map[string]*assets.File{
var Command = assets.NewFileSystem(map[string][]string{"/cmd/{{ .name }}": []string{"run.go.tmpl"}, "/": []string{}, "/cmd": []string{}}, map[string]*assets.File{
"/cmd/{{ .name }}": &assets.File{
Path: "/cmd/{{ .name }}",
FileMode: 0x800001ed,
Expand Down
90 changes: 45 additions & 45 deletions pkg/grapicmd/internal/module/generator/template/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,84 +6,84 @@ import (
"github.com/jessevdk/go-assets"
)

var _Initbc4053f4dd26ceb67e4646e8c1d2cc75897c4dd0 = "package app\n\nimport (\n\t\"github.com/izumin5210/grapi/pkg/grapiserver\"\n)\n\n// Run starts the grapiserver.\nfunc Run() error {\n\ts := grapiserver.New(\n\t\tgrapiserver.WithDefaultLogger(),\n\t\tgrapiserver.WithServers(\n\t\t// TODO\n\t\t),\n\t)\n\treturn s.Serve()\n}\n"
var _Init38e76c5db8962fa825cf2bd8b23a2dc985c4513e = "*.so\n/vendor\n/bin\n/tmp\n"
var _Init8d21956ba8abe388f964e47be0f7e5d170a2fce5 = ""
var _Init23b808cac963edf44a497827f2a6eff5ddac970f = "required = [\n \"github.com/golang/protobuf/protoc-gen-go\",\n \"github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway\",\n \"github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger\",\n]\n\n[prune]\n go-tests = true\n unused-packages = true\n\n [[prune.project]]\n name = \"github.com/grpc-ecosystem/grpc-gateway\"\n non-go = false\n unused-packages = false\n\n[[constraint]]\n{{- if .headUsed }}\n branch = \"master\"\n{{- end }}\n name = \"github.com/izumin5210/grapi\"\n{{- if not .headUsed }}\n version = \"{{ .version }}\"\n{{- end }}\n"
var _Initc051c9ff1a8e446bc9636d3144c2775a7e235322 = "[protoc]\nprotos_dir = \"./api/protos\"\nout_dir = \"./api\"\nimport_dirs = [\n \"./vendor/github.com/grpc-ecosystem/grpc-gateway\",\n \"./vendor/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis\",\n]\n\n [[protoc.plugins]]\n path = \"./vendor/github.com/golang/protobuf/protoc-gen-go\"\n name = \"go\"\n args = { plugins = \"grpc\" }\n\n [[protoc.plugins]]\n path = \"./vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway\"\n name = \"grpc-gateway\"\n args = { logtostderr = true }\n\n [[protoc.plugins]]\n path = \"./vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger\"\n name = \"swagger\"\n args = { logtostderr = true }\n"
var _Init23b808cac963edf44a497827f2a6eff5ddac970f = "required = [\n \"github.com/golang/protobuf/protoc-gen-go\",\n \"github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway\",\n \"github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger\",\n]\n\n[[constraint]]\n{{- if .headUsed }}\n branch = \"master\"\n{{- end }}\n name = \"github.com/izumin5210/grapi\"\n{{- if not .headUsed }}\n version = \"{{ .version }}\"\n{{- end }}\n"
var _Init38e76c5db8962fa825cf2bd8b23a2dc985c4513e = "*.so\n/vendor\n/bin\n/tmp\n"
var _Initbc4053f4dd26ceb67e4646e8c1d2cc75897c4dd0 = "package app\n\nimport (\n\t\"github.com/izumin5210/grapi/pkg/grapiserver\"\n)\n\n// Run starts the grapiserver.\nfunc Run() error {\n\ts := grapiserver.New(\n\t\tgrapiserver.WithDefaultLogger(),\n\t\tgrapiserver.WithServers(\n\t\t// TODO\n\t\t),\n\t)\n\treturn s.Serve()\n}\n"
var _Init71ed560e812a4261bc8b56d9feaef4800830e0b7 = ""
var _Initd135936e91856b6159ac2eedcf89aa9f07773f82 = "package main\n\nimport (\n\t\"os\"\n\n\t\"{{ .importPath }}/app\"\n)\n\nfunc main() {\n\tos.Exit(run())\n}\n\nfunc run() int {\n\terr := app.Run()\n\tif err != nil {\n\t\treturn 1\n\t}\n\treturn 0\n}\n"
var _Initc051c9ff1a8e446bc9636d3144c2775a7e235322 = "[protoc]\nprotos_dir = \"./api/protos\"\nout_dir = \"./api\"\nimport_dirs = [\n \"./vendor/github.com/grpc-ecosystem/grpc-gateway\",\n \"./vendor/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis\",\n]\n\n [[protoc.plugins]]\n path = \"./vendor/github.com/golang/protobuf/protoc-gen-go\"\n name = \"go\"\n args = { plugins = \"grpc\" }\n\n [[protoc.plugins]]\n path = \"./vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway\"\n name = \"grpc-gateway\"\n args = { logtostderr = true }\n\n [[protoc.plugins]]\n path = \"./vendor/github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger\"\n name = \"swagger\"\n args = { logtostderr = true }\n"

// Init returns go-assets FileSystem
var Init = assets.NewFileSystem(map[string][]string{"/api": []string{}, "/api/protos": []string{".keep.tmpl"}, "/app": []string{"run.go.tmpl"}, "/app/server": []string{".keep.tmpl"}, "/cmd": []string{}, "/cmd/server": []string{"run.go.tmpl"}, "/": []string{".gitignore.tmpl", "Gopkg.toml.tmpl", "grapi.toml.tmpl"}}, map[string]*assets.File{
"/app/server": &assets.File{
Path: "/app/server",
FileMode: 0x800001ed,
Mtime: time.Unix(1521042119, 1521042119000000000),
Data: nil,
}, "/cmd": &assets.File{
Path: "/cmd",
FileMode: 0x800001ed,
var Init = assets.NewFileSystem(map[string][]string{"/app": []string{"run.go.tmpl"}, "/app/server": []string{".keep.tmpl"}, "/cmd": []string{}, "/cmd/server": []string{"run.go.tmpl"}, "/": []string{".gitignore.tmpl", "Gopkg.toml.tmpl", "grapi.toml.tmpl"}, "/api": []string{}, "/api/protos": []string{".keep.tmpl"}}, map[string]*assets.File{
"/cmd/server/run.go.tmpl": &assets.File{
Path: "/cmd/server/run.go.tmpl",
FileMode: 0x1a4,
Mtime: time.Unix(1520753819, 1520753819000000000),
Data: nil,
}, "/grapi.toml.tmpl": &assets.File{
Path: "/grapi.toml.tmpl",
Data: []byte(_Initd135936e91856b6159ac2eedcf89aa9f07773f82),
}, "/.gitignore.tmpl": &assets.File{
Path: "/.gitignore.tmpl",
FileMode: 0x1a4,
Mtime: time.Unix(1520753819, 1520753819000000000),
Data: []byte(_Initc051c9ff1a8e446bc9636d3144c2775a7e235322),
Data: []byte(_Init38e76c5db8962fa825cf2bd8b23a2dc985c4513e),
}, "/app/run.go.tmpl": &assets.File{
Path: "/app/run.go.tmpl",
FileMode: 0x1a4,
Mtime: time.Unix(1521994629, 1521994629000000000),
Mtime: time.Unix(1521995193, 1521995193000000000),
Data: []byte(_Initbc4053f4dd26ceb67e4646e8c1d2cc75897c4dd0),
}, "/app/server/.keep.tmpl": &assets.File{
Path: "/app/server/.keep.tmpl",
FileMode: 0x1a4,
Mtime: time.Unix(1521042119, 1521042119000000000),
Data: []byte(_Init71ed560e812a4261bc8b56d9feaef4800830e0b7),
}, "/cmd/server": &assets.File{
Path: "/cmd/server",
FileMode: 0x800001ed,
Mtime: time.Unix(1520753819, 1520753819000000000),
Data: nil,
}, "/": &assets.File{
Path: "/",
FileMode: 0x800001ed,
Mtime: time.Unix(1521896149, 1521896149000000000),
Data: nil,
}, "/.gitignore.tmpl": &assets.File{
Path: "/.gitignore.tmpl",
FileMode: 0x1a4,
Mtime: time.Unix(1520753819, 1520753819000000000),
Data: []byte(_Init38e76c5db8962fa825cf2bd8b23a2dc985c4513e),
}, "/api/protos/.keep.tmpl": &assets.File{
Path: "/api/protos/.keep.tmpl",
FileMode: 0x1a4,
Mtime: time.Unix(1520753819, 1520753819000000000),
Data: []byte(_Init8d21956ba8abe388f964e47be0f7e5d170a2fce5),
}, "/grapi.toml.tmpl": &assets.File{
Path: "/grapi.toml.tmpl",
FileMode: 0x1a4,
Mtime: time.Unix(1520753819, 1520753819000000000),
Data: []byte(_Initc051c9ff1a8e446bc9636d3144c2775a7e235322),
}, "/": &assets.File{
Path: "/",
FileMode: 0x800001ed,
Mtime: time.Unix(1522493033, 1522493033000000000),
Data: nil,
}, "/api/protos": &assets.File{
Path: "/api/protos",
FileMode: 0x800001ed,
Mtime: time.Unix(1520753819, 1520753819000000000),
Data: nil,
}, "/app": &assets.File{
Path: "/app",
FileMode: 0x800001ed,
Mtime: time.Unix(1521994629, 1521994629000000000),
Mtime: time.Unix(1521995193, 1521995193000000000),
Data: nil,
}, "/app/server": &assets.File{
Path: "/app/server",
FileMode: 0x800001ed,
Mtime: time.Unix(1521042119, 1521042119000000000),
Data: nil,
}, "/Gopkg.toml.tmpl": &assets.File{
Path: "/Gopkg.toml.tmpl",
FileMode: 0x1a4,
Mtime: time.Unix(1520753819, 1520753819000000000),
Data: []byte(_Init23b808cac963edf44a497827f2a6eff5ddac970f),
}, "/api": &assets.File{
Path: "/api",
FileMode: 0x800001ed,
Mtime: time.Unix(1520753819, 1520753819000000000),
Data: nil,
}, "/api/protos": &assets.File{
Path: "/api/protos",
}, "/cmd": &assets.File{
Path: "/cmd",
FileMode: 0x800001ed,
Mtime: time.Unix(1520753819, 1520753819000000000),
Data: nil,
}, "/app/server/.keep.tmpl": &assets.File{
Path: "/app/server/.keep.tmpl",
FileMode: 0x1a4,
Mtime: time.Unix(1521042119, 1521042119000000000),
Data: []byte(_Init71ed560e812a4261bc8b56d9feaef4800830e0b7),
}, "/cmd/server/run.go.tmpl": &assets.File{
Path: "/cmd/server/run.go.tmpl",
}, "/Gopkg.toml.tmpl": &assets.File{
Path: "/Gopkg.toml.tmpl",
FileMode: 0x1a4,
Mtime: time.Unix(1520753819, 1520753819000000000),
Data: []byte(_Initd135936e91856b6159ac2eedcf89aa9f07773f82),
Mtime: time.Unix(1522493033, 1522493033000000000),
Data: []byte(_Init23b808cac963edf44a497827f2a6eff5ddac970f),
}}, "")
48 changes: 24 additions & 24 deletions pkg/grapicmd/internal/module/generator/template/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,14 @@ import (
"github.com/jessevdk/go-assets"
)

var _Serviceba3c18adf9d77d5cbf8a40461aa014bc49f81edc = "syntax = \"proto3\";\noption go_package = \"{{ .PbGo.PackageName }}\";\npackage {{ .Proto.Package }};\n{{range .Proto.Imports}}\nimport \"{{.}}\";\n{{- end}}\n\nservice {{ .ServiceName }}Service {\t\n{{- range .Methods}}\n rpc {{.Method}} ({{.RequestProto}}) returns ({{.ResponseProto}}) {\n option (google.api.http) = {\n {{.HTTP.Method}}: \"/{{.HTTP.Path}}\"\n {{- if .HTTP.Body}}\n body: \"{{.HTTP.Body}}\"\n {{- end}}\n };\n }\n{{- end}}\n}\n{{range .Proto.Messages}}\nmessage {{.Name}} {\n {{- range .Fields}}\n {{- if .Repeated}}\n repeated {{.Type}} {{.Name}} = {{.Tag}};\n {{- else}}\n {{.Type}} {{.Name}} = {{.Tag}};\n {{- end}}\n {{- end}}\n}\n{{end -}}\n"
var _Serviceef91c225ded973f86ca6b58050abcc766e9d41c3 = "package {{.Go.Package }}\n\nimport (\n\t\"context\"\n{{range .Go.Imports}}\n\t\"{{.}}\"\n{{- end}}\n\n\t{{.PbGo.PackageName}} \"{{ .PbGo.PackagePath }}\"\n)\n\n// New{{.Go.ServerName}} creates a new {{.Go.ServerName}} instance.\nfunc New{{.Go.ServerName}}() interface {\n\t{{.PbGo.PackageName }}.{{.Go.ServerName}}\n\tgrapiserver.Server\n} {\n\treturn &{{.Go.StructName}}{}\n}\n\ntype {{.Go.StructName}} struct {\n}\n{{$go := .Go -}}\n{{$pbGo := .PbGo -}}\n{{- range .Methods}}\nfunc (s *{{$go.StructName}}) {{.Method}}(ctx context.Context, req *{{.RequestGo $pbGo.PackageName}}) (*{{.ResponseGo $pbGo.PackageName}}, error) {\n\t// TODO: Not yet implemented.\n\treturn nil, status.Error(codes.Unimplemented, \"TODO: You should implement it!\")\n}\n{{end -}}\n"
var _Service286062ec6e6bb8e20b13dd8d62e442f7cd8288f5 = "package {{.Go.Package }}\n\nimport (\n\t\"context\"\n\n\t\"github.com/grpc-ecosystem/grpc-gateway/runtime\"\n\t\"google.golang.org/grpc\"\n\n\t{{.PbGo.PackageName}} \"{{ .PbGo.PackagePath }}\"\n)\n\n// RegisterWithServer implements grapiserver.Server.RegisterWithServer.\nfunc (s *{{.Go.StructName}}) RegisterWithServer(grpcSvr *grpc.Server) {\n\t{{.PbGo.PackageName}}.Register{{.Go.ServerName}}(grpcSvr, s)\n}\n\n// RegisterWithHandler implements grapiserver.Server.RegisterWithHandler.\nfunc (s *{{.Go.StructName}}) RegisterWithHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {\n\treturn {{.PbGo.PackageName}}.Register{{.ServiceName}}ServiceHandler(ctx, mux, conn)\n}\n"
var _Serviceba3c18adf9d77d5cbf8a40461aa014bc49f81edc = "syntax = \"proto3\";\noption go_package = \"{{ .PbGo.PackageName }}\";\npackage {{ .Proto.Package }};\n{{range .Proto.Imports}}\nimport \"{{.}}\";\n{{- end}}\n\nservice {{ .ServiceName }}Service {\t\n{{- range .Methods}}\n rpc {{.Method}} ({{.RequestProto}}) returns ({{.ResponseProto}}) {\n option (google.api.http) = {\n {{.HTTP.Method}}: \"/{{.HTTP.Path}}\"\n {{- if .HTTP.Body}}\n body: \"{{.HTTP.Body}}\"\n {{- end}}\n };\n }\n{{- end}}\n}\n{{range .Proto.Messages}}\nmessage {{.Name}} {\n {{- range .Fields}}\n {{- if .Repeated}}\n repeated {{.Type}} {{.Name}} = {{.Tag}};\n {{- else}}\n {{.Type}} {{.Name}} = {{.Tag}};\n {{- end}}\n {{- end}}\n}\n{{end -}}\n"
var _Service7664b60536a30580d1374729ea1d6df5fd874e1e = "package {{.Go.Package }}\n{{if .Methods}}\nimport (\n\t\"context\"\n\t\"testing\"\n{{range .Go.TestImports}}\n\t\"{{.}}\"\n{{- end}}\n\n\t{{.PbGo.PackageName}} \"{{ .PbGo.PackagePath }}\"\n)\n{{$go := .Go -}}\n{{$pbGo := .PbGo -}}\n{{- range .Methods}}\nfunc Test_{{$go.ServerName}}_{{.Method}}(t *testing.T) {\n\tsvr := New{{$go.ServerName}}()\n\n\tctx := context.Background()\n\treq := &{{.RequestGo $pbGo.PackageName}}{}\n\n\tresp, err := svr.{{.Method}}(ctx, req)\n\n\tif err != nil {\n\t\tt.Errorf(\"returned an error %v\", err)\n\t}\n\n\tif resp == nil {\n\t\tat.Error(\"response should not nil\")\n\t}\n}\n{{end -}}\n{{end -}}\n"

// Service returns go-assets FileSystem
var Service = assets.NewFileSystem(map[string][]string{"/": []string{}, "/api": []string{}, "/api/protos": []string{"{{.Path}}.proto.tmpl"}, "/app": []string{}, "/app/server": []string{"{{.Path}}_server.go.tmpl", "{{.Path}}_server_register_funcs.go.tmpl", "{{.Path}}_server_test.go.tmpl"}}, map[string]*assets.File{
"/api": &assets.File{
Path: "/api",
FileMode: 0x800001ed,
Mtime: time.Unix(1521913317, 1521913317000000000),
Data: nil,
}, "/api/protos": &assets.File{
Path: "/api/protos",
FileMode: 0x800001ed,
Mtime: time.Unix(1521913317, 1521913317000000000),
Data: nil,
}, "/api/protos/{{.Path}}.proto.tmpl": &assets.File{
Path: "/api/protos/{{.Path}}.proto.tmpl",
FileMode: 0x1a4,
Mtime: time.Unix(1521913317, 1521913317000000000),
Data: []byte(_Serviceba3c18adf9d77d5cbf8a40461aa014bc49f81edc),
}, "/app/server/{{.Path}}_server_test.go.tmpl": &assets.File{
var Service = assets.NewFileSystem(map[string][]string{"/app": []string{}, "/app/server": []string{"{{.Path}}_server.go.tmpl", "{{.Path}}_server_register_funcs.go.tmpl", "{{.Path}}_server_test.go.tmpl"}, "/": []string{}, "/api": []string{}, "/api/protos": []string{"{{.Path}}.proto.tmpl"}}, map[string]*assets.File{
"/app/server/{{.Path}}_server_test.go.tmpl": &assets.File{
Path: "/app/server/{{.Path}}_server_test.go.tmpl",
FileMode: 0x1a4,
Mtime: time.Unix(1521996238, 1521996238000000000),
Expand All @@ -46,16 +31,31 @@ var Service = assets.NewFileSystem(map[string][]string{"/": []string{}, "/api":
}, "/app/server": &assets.File{
Path: "/app/server",
FileMode: 0x800001ed,
Mtime: time.Unix(1523569776, 1523569776000000000),
Mtime: time.Unix(1523623016, 1523623016000000000),
Data: nil,
}, "/app/server/{{.Path}}_server_register_funcs.go.tmpl": &assets.File{
Path: "/app/server/{{.Path}}_server_register_funcs.go.tmpl",
FileMode: 0x1a4,
Mtime: time.Unix(1523623016, 1523623016000000000),
Data: []byte(_Service286062ec6e6bb8e20b13dd8d62e442f7cd8288f5),
}, "/app/server/{{.Path}}_server.go.tmpl": &assets.File{
Path: "/app/server/{{.Path}}_server.go.tmpl",
FileMode: 0x1a4,
Mtime: time.Unix(1523569776, 1523569776000000000),
Mtime: time.Unix(1523623016, 1523623016000000000),
Data: []byte(_Serviceef91c225ded973f86ca6b58050abcc766e9d41c3),
}, "/app/server/{{.Path}}_server_register_funcs.go.tmpl": &assets.File{
Path: "/app/server/{{.Path}}_server_register_funcs.go.tmpl",
}, "/api": &assets.File{
Path: "/api",
FileMode: 0x800001ed,
Mtime: time.Unix(1521913317, 1521913317000000000),
Data: nil,
}, "/api/protos": &assets.File{
Path: "/api/protos",
FileMode: 0x800001ed,
Mtime: time.Unix(1521913317, 1521913317000000000),
Data: nil,
}, "/api/protos/{{.Path}}.proto.tmpl": &assets.File{
Path: "/api/protos/{{.Path}}.proto.tmpl",
FileMode: 0x1a4,
Mtime: time.Unix(1523569745, 1523569745000000000),
Data: []byte(_Service286062ec6e6bb8e20b13dd8d62e442f7cd8288f5),
Mtime: time.Unix(1521913317, 1521913317000000000),
Data: []byte(_Serviceba3c18adf9d77d5cbf8a40461aa014bc49f81edc),
}}, "")

0 comments on commit df11cb8

Please sign in to comment.