grantzheng / kit Goto Github PK
View Code? Open in Web Editor NEWThis project forked from kujtimiihoxha/kit
GoKit CLI
License: MIT License
This project forked from kujtimiihoxha/kit
GoKit CLI
License: MIT License
建议把修改BUG的代码合并到源代码中,维护共同维护一份代码会省事点
Usage:
kit generate service [flags]
Aliases:
service, s
Flags:
-w, --dmw Generate default middleware for service and endpoint
--endpoint-mdw If set a default Logging and Tracking middleware will be created and attached to the endpoint
--gorilla Generate http using gorilla mux
-h, --help help for service
-m, --methods stringArray Specify methods to be generated
-i, --pb_import_path string Specify path to import pb
-p, --pb_path string Specify path to store pb dir
--svc-mdw If set a default Logging and Instrumental middleware will be created and attached to the service
-t, --transport string The transport you want your service to be initiated with (default "http")
Global Flags:
-d, --debug If you want to see the debug logs.
-b, --folder string If you want to specify the base folder of the project.
-f, --force Force overide existing files without asking.
what's the correct way to specify methods with stringArray
?
// SayHi implements Service. Primarily useful in a client.
func (e Endpoints) SayHi(ctx context.Context, name string) (reply string, err error) {
request := SayHiRequest{
Name: name,
}
response, err := e.SayHiEndpoint(ctx, request)
if err != nil {
return
}
return response.(SayHiResponse).Reply, response.(SayHiResponse).Err
}
The above is the an endpoint code generated by kit,both req&rsp aren't pointer type,why is it?
I think convert req&rsp to pointer type is better way, it avoids value copy, isn't it ?
Firstly, thank you so much for continuing this amazing tool. If there is a donation link somewhere, please let me know.
I would like to know:
Is there any "Magic" happening in these files?
What is their function/purpose?
Is it possible for these files to change randomly and break an application?
Should we be checking them into the repo and is there an option to not have to use extra files?
Thank you so much once again, hope you are well.
Hi,
Thanks for the great work maintaining and adding features to this repo.
How do you recommend to structure a real life set of micro services using kit?
Every time I generate a new service it will create a new pkg and cmd folder, however it looks like the best practice for a real project is to have one pkg and cmd and then a folder for each service (under cmd and pkg) as well as other folders for other shared packages. (https://github.com/peterbourgon/gattaca)
Am I doing something wrong whilst generating my services hence getting the wrong folder structure?
Would be great help if you know of any tutorial/instruction showing how to use kit for creating at least two services with both gRPC and html transport and ideally clean architecture (I searched a lot but couldn't find anything!)
Thanks
this project uses golang/protobuf to generate code(this repository are deprecated), the gRPC code generator is built-in in, so it supports the expression protoc --go_out=plugins=grpc:.
, but when we want to use the new version of protoc-gen-go
, they are two separate files and not support plugin=xxx
mechanism. if we want to generate code, we need to use some separate flags like this:
protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative xxx.proto
but golang/protobuf
is not supporting this expression, as far as I know, many people still use golang/protobuf
as their code generator, so which version should be chosen for this project?
Hello there,
There was a problem when I tried to run the kit command, it is not found but when I check the go directory at go/bin/bin
and execute the kit command it actually work, is this only happen to me?
OS: EndeavourOS
DE: Gnome 43.2
GO: go1.19.4 linux/amd64
Thank you.
Hi @GrantZheng , I check your repo and it seems maintained rather than the original kit. Do you have plan to continue it? if yes, I'll try to make contribution here.
This is the example:
$ grep -ira "kujtimiihoxha"
go.mod:module github.com/kujtimiihoxha/kit
I think above example is one of reason why go get github.com/GrantZheng/kit
not working. I can create PR if this repo will be maintained. I also heavily use kit, so it will better for community too.
I've also check that the LICENSE is MIT, so you free to modify and distribute it by yourself.
I'm try kit n s Hello
in Windows.But Kit throws an exception:
genModule: sh -c cd hello && go mod init hello => err:exec: "sh": executable file not found in %PATH% ,
time="2020-09-16T10:11:30+08:00" level=error msg="genModule: sh -c cd hello && go mod init hello => err:exec: "sh": executable file not found in %PATH%
期待你的回复
Hi Grant,
How could I create one gRPC service as client for other gRPC service. I can NOT import pb folder from other service folder when I'm using go module. Any idea about it?
I wonder if it is a typo here
debug.addr
should it be debug-addr
?
Hi,
I came across a bug whilst generating boilercode for go-kit.
I'm running go version:
go version go1.15.2 linux/amd64
Running the latest version of kit.
The service was generated as follows:
kit new service vavite -m bitbucket.org/tapanito/hello
Then to generate the middleware and other boiler code:
kit generate service -w -t grpc --svc-mdw hello -f
The generates imports block looks as follows:
import (
"context"
service "hello/pkg/service"
endpoint "github.com/go-kit/kit/endpoint"
)
The culprit line is: service "hello/pkg/service"
, as I'm using go modules with the module name bitbucket.org/tapanito/hello
the import service "hello/pkg/service"
is not valid.
→ go version
go version go1.14.2 darwin/amd64
→ kit new service hello
→ kit generate service hello -t grpc
ERRO[0000] exit status 1
→ kit generate service hello --debug -t grpc
ERRO[0000] exit status 1
Friendly to developers using Chinese
Now, this cmd will gen /pb
dir to /pkg/grpc:
kit g s hello -t grpc
but sometimes, put pb
dir in root dir of project is a common practice.
so, could I ask you to add a flag to specify the location of the pb
directory? thanks in advance.
go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/XXX/Library/Caches/go-build"
GOENV="/Users/XXX/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/XXX/go/pkg/mod"
GONOPROXY="github.com/XXXX"
GONOSUMDB="github.com/XXXX"
GOOS="darwin"
GOPATH="/Users/XXX/go"
GOPRIVATE="github.com/XXXX"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/xd/l04f3qld4rd_79_6w9dzhmf00000gn/T/go-build830253790=/tmp/go-build -gno-record-gcc-switches -fno-common"
when kit g s -t grpc --dmw svc
, got ERRO[0000] exit status 1
,
after returned error, cmd dir missing, pkg/grpc/handler missing
but kit g s --dmw svc
is ok.
This is an amazing tool. But can we have an option to read just the input from a proto file, including rpc methods, and generate a service based on that? Does the service interface have to be in a .go file, because a service definition is just as complete in a protobuf file.
Truss does this, but truss does not have as many features as this tool has.
i didnt found the example handler using another methord, i try to hit some endpoint using postman, just post method will be run
When I new a service with this
kit n s hello-world -m github.com/example/hello-world
this will create a service called hello_world
, and github.com/example/hello_world
in go.mod
.
It should be hello-world
and github.com/example/hello-world
in go.mod
.
Hi, When I ran docker-compose up, kit is crashed. The output shows as below. Any idea about this issue?
[6/8] RUN go get -t -v ./...:
#10 0.192 go: go.mod file not found in current directory or any parent directory.
#10 0.192 'go get' is no longer supported outside a module.
#10 0.192 To build and install a command, use 'go install' with a version,
#10 0.192 like 'go install example.com/cmd@latest'
#10 0.192 For more information, see https://golang.org/doc/go-get-install-deprecation
#10 0.192 or run 'go help get' or 'go help install'.
executor failed running [/bin/sh -c go get -t -v ./...]: exit code: 1
ERROR: Service 'hello' failed to build : Build failed
should we consider of moving this article to the project to maintenance? so we can change the content following the project changes. of course, we will mark the original author.
PS D:\projects\go-kit\mydemo> kit g s hello --dmw
panic: Error 5:9: invalid import path: "D:/projects/go-kit/mydemo/hello/pkg/service" while formatting source:
// THIS FILE IS AUTO GENERATED BY GK-CLI DO NOT EDIT!!
package endpoint
import (
service "D:/projects/go-kit/mydemo/hello/pkg/service"
endpoint "github.com/go-kit/kit/endpoint"
)
D:/go-sdk/go-repository/pkg/mod/github.com/kujtimiihoxha/[email protected]/cmd/g_service.go:41 +0x17c
github.com/spf13/cobra.(*Command).execute(0x1131220, {0xc00005ff80, 0x2, 0x2})
D:/go-sdk/go-repository/pkg/mod/github.com/spf13/[email protected]/command.go:860 +0x5f8
github.com/spf13/cobra.(*Command).ExecuteC(0x1130aa0)
D:/go-sdk/go-repository/pkg/mod/github.com/spf13/[email protected]/command.go:974 +0x3bc
github.com/spf13/cobra.(*Command).Execute(...)
D:/go-sdk/go-repository/pkg/mod/github.com/spf13/[email protected]/command.go:902
github.com/kujtimiihoxha/kit/cmd.Execute()
D:/go-sdk/go-repository/pkg/mod/github.com/kujtimiihoxha/[email protected]/cmd/root.go:24 +0x25
main.main()
D:/go-sdk/go-repository/pkg/mod/github.com/!grant!zheng/[email protected]/main.go:14 +0x2b
When I use the command to make a new service with name as first letter capital.
kit new service XYZ
I get the error
exit status 2
ERRO[0000] exit status 2
Please help
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.