Code Monkey home page Code Monkey logo

kit's People

Contributors

bootun avatar chasespace avatar danie1lin avatar dsxack avatar grantzheng avatar kujtimiihoxha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kit's Issues

提个小建议

建议把修改BUG的代码合并到源代码中,维护共同维护一份代码会省事点

what does stringArray mean?

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?

Why not encode/decode endpoint req&rsp as a pointer type?

// 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 ?

I am new to go and would like to understand what the _gen files are for?

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.

real life files structure

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

choose a protoc-gen-go version

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?

resource

command not found: kit

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.

leftover github.com/kujtimiihoxha link

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.

Does the tool require an operating system?

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%

期待你的回复

A typo

I wonder if it is a typo here

debug.addr should it be debug-addr?

Incorect import when using go modules with full project name

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.

ERRO[0000] exit status 1

→ 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

Could kit allow to specify the path of the pb directory?

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.

ERRO[0000] exit status 1

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.

Add support to generate from .proto only

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.

Crashed when running command "docker-compose up"

Hi, When I ran docker-compose up, kit is crashed. The output shows as below. Any idea about this issue?

Building hello
[+] Building 3.0s (10/12)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 345B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/golang:latest 2.7s
=> [internal] load build context 0.0s
=> => transferring context: 1.65kB 0.0s
=> [1/8] FROM docker.io/library/golang@sha256:1860373709cc04bacfcf3bb1aaa8c14bb1243 0.0s
=> CACHED [2/8] RUN mkdir -p /go/src/gokit 0.0s
=> CACHED [3/8] WORKDIR /go/src/gokit 0.0s
=> [4/8] ADD . /go/src/gokit 0.0s
=> [5/8] WORKDIR /go/src/gokit 0.0s
=> ERROR [6/8] RUN go get -t -v ./... 0.2s

[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.

hello, there are some bugs when I used "kit g s hello --dmw" command.

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

ERRO[0000] exit status 2

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.