Giter VIP home page Giter VIP logo

kit's Introduction

GoKit CLI Build StatusGo Report CardCoverage Status

This project is a more advanced version of gk. The goal of the gokit cli is to be a tool that you can use while you develop your microservices with gokit.

While gk did help you create your basic folder structure it was not really able to be used further on in your project. This is what GoKit Cli is aiming to change.

Prerequisites

GoKit Cli needs to be installed using go get and go install so Go is a requirement to be able to test your services gokit is needed.

To utilise generation of gRPC service code through kit generate service <SERVICE_NAME> -t grpc you will need to install the grpc prequisites.

go get -u google.golang.org/grpc
go get -u github.com/golang/protobuf/protoc-gen-go

Table of Content

Installation

Before you install please read prerequisites

go get github.com/kujtimiihoxha/kit

Usage

kit help

Also read this medium story

Create a new service

kit new service hello
kit n s hello # using aliases

This will generate the initial folder structure and the service interface

service-name/pkg/service/service.go

package service

// HelloService describes the service.
type HelloService interface {
	// Add your methods here
	// e.x: Foo(ctx context.Context,s string)(rs string, err error)
}

Generate the service

kit g s hello
kit g s hello --dmw # to create the default middleware
kit g s hello -t grpc # specify the transport (default is http)

This command will do these things:

  • Create the service boilerplate: hello/pkg/service/service.go
  • Create the service middleware: hello/pkg/service/middleware.go
  • Create the endpoint: hello/pkg/endpoint/endpoint.go and hello/pkg/endpoint/endpoint_gen.go
  • If using --dmw create the endpoint middleware: hello/pkg/endpoint/middleware.go
  • Create the transport files e.x http: service-name/pkg/http/handler.go
  • Create the service main file 💥
    hello/cmd/service/service.go
    hello/cmd/service/service_gen.go
    hello/cmd/main.go

⚠️ Notice all the files that end with _gen will be regenerated when you add endpoints to your service and you rerun kit g s hello ⚠️

You can run the service by running:

go run hello/cmd/main.go

Generate the client library

kit g c hello

This will generate the client library ✨ http/client/http/http.go that you can than use to call the service methods, you can use it like this:

package main

import (
	"context"
	"fmt"

	client "hello/client/http"
	"github.com/go-kit/kit/transport/http"
)

func main() {
	svc, err := client.New("http://localhost:8081", map[string][]http.ClientOption{})
	if err != nil {
		panic(err)
	}

	r, err := svc.Foo(context.Background(), "hello")
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	fmt.Println("Result:", r)
}

Generate new middleware

kit g m hi -s hello
kit g m hi -s hello -e # if you want to add endpoint middleware

The only thing left to do is add your middleware logic and wire the middleware with your service/endpoint.

Enable docker integration

kit g d

This will add the individual service docker files and one docker-compose.yml file that will allow you to start your services. To start your services just run

docker-compose up

After you run docker-compose up your services will start up and any change you make to your code will automatically rebuild and restart your service (only the service that is changed)

kit's People

Contributors

dsxack avatar kujtimiihoxha avatar philloliver-dev 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kit's Issues

undefined: addDefaultServiceMiddleware

`func getServiceMiddleware(logger log.Logger) (mw []service.Middleware) {
mw = []service.Middleware{}
mw = addDefaultServiceMiddleware(logger, mw)

return

}
func getEndpointMiddleware(logger log.Logger) (mw map[string][]endpoint1.Middleware) {
mw = map[string][]endpoint1.Middleware{}
duration := prometheus.NewSummaryFrom(prometheus1.SummaryOpts{
Help: "Request duration in seconds.",
Name: "request_duration_seconds",
Namespace: "example",
Subsystem: "user",
}, []string{"method", "success"})
addDefaultEndpointMiddleware(logger, duration, mw)

return

}`

$ mygkdemo1 go run user/cmd/main.go

mygkdemo1/user/cmd/service

user/cmd/service/service.go:107:7: undefined: addDefaultServiceMiddleware
user/cmd/service/service.go:119:2: undefined: addDefaultEndpointMiddleware

kit cmd error

I install the kit follow the doc, but when I try "kit help", the error happen.
ERRO[0000] The project must be in the $GOPATH/src folder for the generator to work.

Panics when create new service: panic: Error 5:7: illegal floating-point exponent while formatting source

Code is simple with platform win10 x64:

kit n s 360.exapi.wy

and it panics:

panic: Error 5:7: illegal floating-point exponent while formatting source:
package service


 // 360ExapiWyService describes the service.
 type 360ExapiWyService interface{
// Add your methods here
 // e.x: Foo(ctx context.Context,s string)(rs string, err error)
}


goroutine 1 [running]:
github.com/dave/jennifer/jen.(*File).GoString(0xc000207c20, 0xc0000755c0, 0x11)
        E:/GoProjects/src/github.com/dave/jennifer/jen/file.go:235 +0x10a
github.com/kujtimiihoxha/kit/generator.(*NewService).Generate(0xc0000cf320, 0xc, 0xce1340)
        E:/GoProjects/src/github.com/kujtimiihoxha/kit/generator/new_service.go:54 +0x33f
github.com/kujtimiihoxha/kit/cmd.glob..func8(0x11864e0, 0xc000168d00, 0x1, 0x1)
        E:/GoProjects/src/github.com/kujtimiihoxha/kit/cmd/service.go:19 +0x64
github.com/spf13/cobra.(*Command).execute(0x11864e0, 0xc000168cb0, 0x1, 0x1, 0x11864e0, 0xc000168cb0)
        E:/GoProjects/src/github.com/spf13/cobra/command.go:766 +0x2b5
github.com/spf13/cobra.(*Command).ExecuteC(0x1186280, 0x0, 0x22, 0xc0000753c0)
        E:/GoProjects/src/github.com/spf13/cobra/command.go:850 +0x303
github.com/spf13/cobra.(*Command).Execute(...)
        E:/GoProjects/src/github.com/spf13/cobra/command.go:800
github.com/kujtimiihoxha/kit/cmd.Execute()
        E:/GoProjects/src/github.com/kujtimiihoxha/kit/cmd/root.go:24 +0x39
main.main()
        E:/GoProjects/src/github.com/kujtimiihoxha/kit/main.go:40 +0x306

wrong type for Extract method in service_gen.go

github.com/gocli_kit/hello/cmd/service

hello/cmd/service/service_gen.go:21:172: cannot use tracer (type "github.com/opentracing/opentracing-go".Tracer) as type "github.com/go-kit/kit/vendor/github.com/opentracing/opentracing-go".Tracer in argument to "github.com/go-kit/kit/tracing/opentracing".HTTPToContext:
"github.com/opentracing/opentracing-go".Tracer does not implement "github.com/go-kit/kit/vendor/github.com/opentracing/opentracing-go".Tracer (wrong type for Extract method)
have Extract(interface {}, interface {}) ("github.com/opentracing/opentracing-go".SpanContext, error)
want Extract(interface {}, interface {}) ("github.com/go-kit/kit/vendor/github.com/opentracing/opentracing-go".SpanContext, error)

Cannot install On MacOS with go 1.18.2 release

#go version
go version go1.18.2 darwin/arm64
#go install github.com/kujtimiihoxha/kit@latest
# golang.org/x/sys/unix
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:28:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:43:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:59:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:75:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:90:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:105:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:121:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:136:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:151:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:166:3: //go:linkname must refer to declared function or variable
../go/pkg/mod/golang.org/x/[email protected]/unix/zsyscall_darwin_arm64.go:166:3: too many errors

Generate service error

version

go version

go version go1.14.8 darwin/amd64

Error

The build service must be in the gopath / SRC directory

ERRO[0000] lstat /opt/gopath/src: no such file or directory

undefined: zipkingoopentracing.NewHTTPCollector

I follow the example but get this error when run : go run hello/cmd/main.go
hello/cmd/service/service.go:56:21: undefined: zipkintracer.NewHTTPCollector
hello/cmd/service/service.go:62:15: undefined: zipkintracer.NewRecorder
hello/cmd/service/service.go:63:17: undefined: zipkintracer.NewTracer

docker-compose up error

☁ $ gokitdemo docker-compose up
Building users
Step 1/7 : FROM golang
---> 52b59e9ead8e
Step 2/7 : RUN mkdir -p /go/src/gokitdemo
---> Using cache
---> f8ea05a13ff0
Step 3/7 : ADD . /go/src/gokitdemo
---> Using cache
---> 9561e67a6dc0
Step 4/7 : RUN go get -t -v ./...
---> Running in 14d6e1b9a597
github.com/go-kit/kit (download)

cd .; git clone -- https://github.com/go-kit/kit /go/src/github.com/go-kit/kit

Cloning into '/go/src/github.com/go-kit/kit'...
error: RPC failed; curl 56 GnuTLS recv error (-9): Error decoding the received TLS packet.
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
package github.com/go-kit/kit/endpoint: exit status 128
package github.com/go-kit/kit/log: cannot find package "github.com/go-kit/kit/log" in any of:
/usr/local/go/src/github.com/go-kit/kit/log (from $GOROOT)
/go/src/github.com/go-kit/kit/log (from $GOPATH)
package github.com/go-kit/kit/metrics/prometheus: cannot find package "github.com/go-kit/kit/metrics/prometheus" in any of:
/usr/local/go/src/github.com/go-kit/kit/metrics/prometheus (from $GOROOT)
/go/src/github.com/go-kit/kit/metrics/prometheus (from $GOPATH)
package github.com/go-kit/kit/tracing/opentracing: cannot find package "github.com/go-kit/kit/tracing/opentracing" in any of:
/usr/local/go/src/github.com/go-kit/kit/tracing/opentracing (from $GOROOT)
/go/src/github.com/go-kit/kit/tracing/opentracing (from $GOPATH)
package github.com/go-kit/kit/transport/grpc: cannot find package "github.com/go-kit/kit/transport/grpc" in any of:
/usr/local/go/src/github.com/go-kit/kit/transport/grpc (from $GOROOT)
/go/src/github.com/go-kit/kit/transport/grpc (from $GOPATH)
github.com/lightstep/lightstep-tracer-go (download)

cd .; git clone -- https://github.com/lightstep/lightstep-tracer-go /go/src/github.com/lightstep/lightstep-tracer-go

Cloning into '/go/src/github.com/lightstep/lightstep-tracer-go'...
error: RPC failed; curl 56 GnuTLS recv error (-9): Error decoding the received TLS packet.
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
package github.com/lightstep/lightstep-tracer-go: exit status 128
github.com/oklog/oklog (download)

Many component library addresses have changed, resulting in errors

Question

Why don't you add support for go modules?

Command not generating .pb.go files

This error occurs while executing the following command :
kit generate service <service name> grpc --dmw

The /grpc/pb folder only contains the .proto file. The compile.sh and .pb.go files seem to be missing.

go-kit generate service error

This error occurs while executing the following command :
kit generate service -t grpc --dmw

The /grpc/pb folder only contains the .proto file. The compile.sh and .pb.go files seem to be missing.

I installed the protoc compiler and protocol compiler plugins for Go. But still got that "ERRO[0000] exit status 1 error"

Generated Go files are executable

The generated Go files all have the permissions -rwxr-xr-x. They don't need to be executable, so we should remove the xs so that it is -rw-r--r--.

thrift.TClient undefined

I'm trying out this CLI tool as it looks the most capable from what I see so far but i have this issue with thrift.TClient

# user/vendor/github.com/openzipkin/zipkin-go-opentracing/thrift/gen-go/scribe
vendor/github.com/openzipkin/zipkin-go-opentracing/thrift/gen-go/scribe/scribe.go:210:5: undefined: thrift.TClient

It this point the only thing i did is to follow your tutorial. Can you please help me with this?
Thanks you.

Make easy update : Separate gen file et hand written file

The need to modify generated .go file, looks like the need to modify the .asm file generated by a c compiler.

It's complex to update the generated part, when the generator need to be re-run and the file are modified by hand.

It will be great if kit could be used with "go generate", and if there inputs are considered as source code.

Docker compose up crashes on go get command

when using the generated docker compose file by calling sudo docker-compose up. It fails with the following error:

ERROR: Service 'bugs' failed to build: The command '/bin/sh -c go get -t -v ./...' returned a non-zero code: 1

Looking at the logs it outputs, it seems like a lot of packages are not being installed.
Trying to execute go get -t -v ./... locally in the root folder of the project works just fine.

Installation Instructions are missing key context/steps to be successful in modern Go versions

Hi,

I'm admittedly brand new in go. I'm familiar with Go modules, and with none of the older outdated setup methods. I've installed Go 1.15 based on the most up to date install instructions (https://golang.org/doc/install - I am using a system-wide install in /usr/local/)

I can't figure out if I am meant to be in a project or just anywhere when I run

go get github.com/kujtimiihoxha/kit

The command runs fine when I am in a project, but it installs it in the project (expected) and the next command go install kit fails as it is looking in /usr/local for the file:

❯ go install kit
package kit is not in GOROOT (/usr/local/go/src/kit)

Trying to run go get github.com/kujtimiihoxha/kit in any shell outside a project just fails silently.

I imagine I could clone the whole repo into /usr/local/go/src/kit - but is that the proper method? Is that going to mess things up? I don't know - as no context is given in the instructions.

Can you please update the directions to provide the missing context here? This application is aim at people new to Go-Kit, and presumably go, so as such I feel they are somewhat lacking.

"kit g s" cannot generate function with optional parameter defined.

When using "kit g s servicename", if a function is defined with optional parameter, seems kit not recognize "..."
my interface defined as below:

package service

import (
        "context"
        "github.com/burxtx/fault/fault/pkg/model"
)

// FaultService describes the service.
type FaultService interface {
        // Add your methods here
        Find(ctx context.Context, condiBeans...interface{}) (m []model.Fault, error error)
        Get(ctx context.Context, id string) (m model.Fault, error error)
        Add(ctx context.Context, fault model.Fault) (i int64, error error)
}

then type "kit g s fault -w --gorilla"

INFO[0000] Type Expresion not supported                 
panic: Error 1:76: expected type, found ')' while formatting source:
func (b *basicFaultService) Find (ctx context.Context,condiBeans ) (m0 []model.Fault,e1 error) {
// TODO implement the business logic of Find
return m0,e1
} 

goroutine 1 [running]:
github.com/dave/jennifer/jen.(*Statement).GoString(0xc4200cfbc0, 0x1, 0x1)
	/root/go/src/github.com/dave/jennifer/jen/statement.go:93 +0x102
github.com/kujtimiihoxha/kit/generator.(*PartialGenerator).String(0xc42000e1f0, 0xc420018c01, 0x5ea)
	/root/go/src/github.com/kujtimiihoxha/kit/generator/generator.go:213 +0x2e
github.com/kujtimiihoxha/kit/generator.(*GenerateService).Generate(0xc420290000, 0x5, 0xa5b916)
	/root/go/src/github.com/kujtimiihoxha/kit/generator/generate_service.go:91 +0x356
github.com/kujtimiihoxha/kit/cmd.glob..func3(0xe75880, 0xc42014ecc0, 0x1, 0x3)
	/root/go/src/github.com/kujtimiihoxha/kit/cmd/g_service.go:41 +0x175
github.com/spf13/cobra.(*Command).execute(0xe75880, 0xc42014ec30, 0x3, 0x3, 0xe75880, 0xc42014ec30)
	/root/go/src/github.com/spf13/cobra/command.go:750 +0x2c1
github.com/spf13/cobra.(*Command).ExecuteC(0xe76180, 0x0, 0x0, 0xc420197ed8)
	/root/go/src/github.com/spf13/cobra/command.go:831 +0x30e
github.com/spf13/cobra.(*Command).Execute(0xe76180, 0x2, 0x2)
	/root/go/src/github.com/spf13/cobra/command.go:784 +0x2b
github.com/kujtimiihoxha/kit/cmd.Execute()
	/root/go/src/github.com/kujtimiihoxha/kit/cmd/root.go:24 +0x31
main.main()
	/root/go/src/github.com/kujtimiihoxha/kit/main.go:29 +0x117```

install error

→ go get github.com/kujtimiihoxha/kit

github.com/spf13/cobra

../gopath/src/github.com/spf13/cobra/command.go:31:25: undefined: pflag.ParseErrorsWhitelist

getting below error when generating middleware

Debap@LAPTOP-02U9U7J5 MINGW64 ~/Documents/goworkspace/src
$ kit generate service users --dmw
panic: Error 5:9: invalid import path: "c:/Users/Debap/Documents/goworkspace/src/users/pkg/service" while formatting source:
// THIS FILE IS AUTO GENERATED BY GK-CLI DO NOT EDIT!!
package endpoint

import (
service "c:/Users/Debap/Documents/goworkspace/src/users/pkg/service"
endpoint "github.com/go-kit/kit/endpoint"
)

// Endpoints collects all of the endpoints that compose a profile service. It's
// meant to be used as a helper struct, to collect all of the endpoints into a
// single parameter.
type Endpoints struct{
CreateEndpoint endpoint.Endpoint
}
// New returns a Endpoints struct that wraps the provided service, and wires in all of the
// expected endpoint middlewares
func New (s service.UsersService,mdw map[string] [] endpoint.Middleware) Endpoints {
eps := Endpoints {CreateEndpoint:MakeCreateEndpoint (s)}
for _,m := range mdw ["Create"] {
eps . CreateEndpoint = m (eps . CreateEndpoint)
}
return eps
}

goroutine 1 [running]:
github.com/dave/jennifer/jen.(*File).GoString(0xc0001cfe00, 0xc00015b6d0, 0xd0e260)
C:/Users/Debap/Documents/goworkspace/src/github.com/dave/jennifer/jen/file.go:235 +0x107
github.com/kujtimiihoxha/kit/generator.(*generateServiceEndpointsBase).Generate(0xc00010e360, 0x5, 0xc00010da34)
C:/Users/Debap/Documents/goworkspace/src/github.com/kujtimiihoxha/kit/generator/generate_service.go:967 +0x3274
github.com/kujtimiihoxha/kit/generator.(*GenerateService).Generate(0xc0000e40e0, 0x5, 0xbcad42)
C:/Users/Debap/Documents/goworkspace/src/github.com/kujtimiihoxha/kit/generator/generate_service.go:106 +0x599
github.com/kujtimiihoxha/kit/cmd.glob..func3(0x116a1a0, 0xc0002022e0, 0x1, 0x2)
C:/Users/Debap/Documents/goworkspace/src/github.com/kujtimiihoxha/kit/cmd/g_service.go:41 +0x1ab
github.com/spf13/cobra.(*Command).execute(0x116a1a0, 0xc0002022a0, 0x2, 0x2, 0x116a1a0, 0xc0002022a0)
C:/Users/Debap/Documents/goworkspace/src/github.com/spf13/cobra/command.go:833 +0x2b1
github.com/spf13/cobra.(*Command).ExecuteC(0x116aba0, 0x28, 0xc13af0, 0xc000018d20)
C:/Users/Debap/Documents/goworkspace/src/github.com/spf13/cobra/command.go:917 +0x302
github.com/spf13/cobra.(*Command).Execute(...)
C:/Users/Debap/Documents/goworkspace/src/github.com/spf13/cobra/command.go:867
github.com/kujtimiihoxha/kit/cmd.Execute()
C:/Users/Debap/Documents/goworkspace/src/github.com/kujtimiihoxha/kit/cmd/root.go:24 +0x38
main.main()
C:/Users/Debap/Documents/goworkspace/src/github.com/kujtimiihoxha/kit/main.go:40 +0x2c4

Debap@LAPTOP-02U9U7J5 MINGW64 ~/Documents/goworkspace/src
$ kit generate service bugs --dmw
time="2019-10-08T09:39:58-04:00" level=error msg="Could not find the service interface in bugs"

Debap@LAPTOP-02U9U7J5 MINGW64 ~/Documents/goworkspace/src
$ kit new service bugs

Debap@LAPTOP-02U9U7J5 MINGW64 ~/Documents/goworkspace/src
$ kit generate service bugs --dmw
panic: Error 5:9: invalid import path: "c:/Users/Debap/Documents/goworkspace/src/bugs/pkg/service" while formatting source:
// THIS FILE IS AUTO GENERATED BY GK-CLI DO NOT EDIT!!
package endpoint

import (
service "c:/Users/Debap/Documents/goworkspace/src/bugs/pkg/service"
endpoint "github.com/go-kit/kit/endpoint"
)

// Endpoints collects all of the endpoints that compose a profile service. It's
// meant to be used as a helper struct, to collect all of the endpoints into a
// single parameter.
type Endpoints struct{
CreateEndpoint endpoint.Endpoint
}
// New returns a Endpoints struct that wraps the provided service, and wires in all of the
// expected endpoint middlewares
func New (s service.BugsService,mdw map[string] [] endpoint.Middleware) Endpoints {
eps := Endpoints {CreateEndpoint:MakeCreateEndpoint (s)}
for _,m := range mdw ["Create"] {
eps . CreateEndpoint = m (eps . CreateEndpoint)
}
return eps
}

goroutine 1 [running]:
github.com/dave/jennifer/jen.(*File).GoString(0xc000240960, 0xc0001776d0, 0xd0e260)
C:/Users/Debap/Documents/goworkspace/src/github.com/dave/jennifer/jen/file.go:235 +0x107
github.com/kujtimiihoxha/kit/generator.(*generateServiceEndpointsBase).Generate(0xc00026c1b0, 0x4, 0xc0002262a4)
C:/Users/Debap/Documents/goworkspace/src/github.com/kujtimiihoxha/kit/generator/generate_service.go:967 +0x3274
github.com/kujtimiihoxha/kit/generator.(*GenerateService).Generate(0xc000258000, 0x4, 0xbcad42)
C:/Users/Debap/Documents/goworkspace/src/github.com/kujtimiihoxha/kit/generator/generate_service.go:106 +0x599
github.com/kujtimiihoxha/kit/cmd.glob..func3(0x116a1a0, 0xc000230140, 0x1, 0x2)
C:/Users/Debap/Documents/goworkspace/src/github.com/kujtimiihoxha/kit/cmd/g_service.go:41 +0x1ab
github.com/spf13/cobra.(*Command).execute(0x116a1a0, 0xc000230100, 0x2, 0x2, 0x116a1a0, 0xc000230100)
C:/Users/Debap/Documents/goworkspace/src/github.com/spf13/cobra/command.go:833 +0x2b1
github.com/spf13/cobra.(*Command).ExecuteC(0x116aba0, 0x28, 0xc13af0, 0xc00008e9c0)
C:/Users/Debap/Documents/goworkspace/src/github.com/spf13/cobra/command.go:917 +0x302
github.com/spf13/cobra.(*Command).Execute(...)
C:/Users/Debap/Documents/goworkspace/src/github.com/spf13/cobra/command.go:867
github.com/kujtimiihoxha/kit/cmd.Execute()
C:/Users/Debap/Documents/goworkspace/src/github.com/kujtimiihoxha/kit/cmd/root.go:24 +0x38
main.main()
C:/Users/Debap/Documents/goworkspace/src/github.com/kujtimiihoxha/kit/main.go:40 +0x2c4

Debap@LAPTOP-02U9U7J5 MINGW64 ~/Documents/goworkspace/src
$ kit generate service bugs --dmw
panic: Error 5:9: invalid import path: "c:/Users/Debap/Documents/goworkspace/src/bugs/pkg/service" while formatting source:
// THIS FILE IS AUTO GENERATED BY GK-CLI DO NOT EDIT!!
package endpoint

import (
service "c:/Users/Debap/Documents/goworkspace/src/bugs/pkg/service"
endpoint "github.com/go-kit/kit/endpoint"
)

// Endpoints collects all of the endpoints that compose a profile service. It's
// meant to be used as a helper struct, to collect all of the endpoints into a
// single parameter.
type Endpoints struct{
CreateEndpoint endpoint.Endpoint
}
// New returns a Endpoints struct that wraps the provided service, and wires in all of the
// expected endpoint middlewares
func New (s service.BugsService,mdw map[string] [] endpoint.Middleware) Endpoints {
eps := Endpoints {CreateEndpoint:MakeCreateEndpoint (s)}
for _,m := range mdw ["Create"] {
eps . CreateEndpoint = m (eps . CreateEndpoint)
}
return eps
}

goroutine 1 [running]:
github.com/dave/jennifer/jen.(*File).GoString(0xc0001cfb80, 0xc00015b6d0, 0xd0e260)
C:/Users/Debap/Documents/goworkspace/src/github.com/dave/jennifer/jen/file.go:235 +0x107
github.com/kujtimiihoxha/kit/generator.(*generateServiceEndpointsBase).Generate(0xc00010e510, 0x4, 0xc00010d824)
C:/Users/Debap/Documents/goworkspace/src/github.com/kujtimiihoxha/kit/generator/generate_service.go:967 +0x3274
github.com/kujtimiihoxha/kit/generator.(*GenerateService).Generate(0xc00023c000, 0x4, 0xbcad42)
C:/Users/Debap/Documents/goworkspace/src/github.com/kujtimiihoxha/kit/generator/generate_service.go:106 +0x599
github.com/kujtimiihoxha/kit/cmd.glob..func3(0x116a1a0, 0xc000208160, 0x1, 0x2)
C:/Users/Debap/Documents/goworkspace/src/github.com/kujtimiihoxha/kit/cmd/g_service.go:41 +0x1ab
github.com/spf13/cobra.(*Command).execute(0x116a1a0, 0xc000208120, 0x2, 0x2, 0x116a1a0, 0xc000208120)
C:/Users/Debap/Documents/goworkspace/src/github.com/spf13/cobra/command.go:833 +0x2b1
github.com/spf13/cobra.(*Command).ExecuteC(0x116aba0, 0x28, 0xc13af0, 0xc000018d20)
C:/Users/Debap/Documents/goworkspace/src/github.com/spf13/cobra/command.go:917 +0x302
github.com/spf13/cobra.(*Command).Execute(...)
C:/Users/Debap/Documents/goworkspace/src/github.com/spf13/cobra/command.go:867
github.com/kujtimiihoxha/kit/cmd.Execute()
C:/Users/Debap/Documents/goworkspace/src/github.com/kujtimiihoxha/kit/cmd/root.go:24 +0x38
main.main()
C:/Users/Debap/Documents/goworkspace/src/github.com/kujtimiihoxha/kit/main.go:40 +0x2c4

Connecting Zipkin

Do you have any examples connecting zipkin? I've added the zipkin url argument but I don't see any tracing.

how to set GET,POST and so on to a handle

just like title,how to...

func makeCreateHandler(m *http.ServeMux, endpoints endpoint.Endpoints, options []http1.ServerOption) {
m.Handle("/create", http1.NewServer(endpoints.CreateEndpoint, decodeCreateRequest, encodeCreateResponse, options...))
}

Support jennifer ImportName, ImportAlias

There are new mechanism to add alias in https://github.com/dave/jennifer
It will be great if Gokit-cli will not generate code like

package http

import (
        context "context"
        json "encoding/json"
        errors "errors"
        endpoint "github.com/User/project/pkg/endpoint"
        http1 "github.com/go-kit/kit/transport/http"
        http "net/http"
)

If you have thoughts how to do that i could help

Invalid import path

Hi,

I am facing an issue with the gen.
From $GOPATH/src, I run the following commands :

  1. New service

$kit new service bugs

  1. Implementation of a basic method in the service interface :

type BugsService interface { // Add your methods here // e.x: Foo(ctx context.Context,s string)(rs string, err error) Create(ctx context.Context, bug string) error }

  1. Generate MW

kit generate service bugs --dmw

=> Error

`$ kit generate service bugs --dmw
panic: Error 5:9: invalid import path: "C:/Users/Vincent/go/src/bugs/pkg/service" while formatting source:
// THIS FILE IS AUTO GENERATED BY GK-CLI DO NOT EDIT!!
package endpoint

import (
service "C:/Users/Vincent/go/src/bugs/pkg/service"
endpoint "github.com/go-kit/kit/endpoint"
)

...
`

The import path is absolute instead of relative.
There is maybe something wrong with my dev environment.

$ go env set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\Vincent\AppData\Local\go-build set GOEXE=.exe set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOOS=windows set GOPATH=C:\Users\Vincent\go set GOPROXY= set GORACE= set GOROOT=C:\Go set GOTMPDIR= set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64 set GCCGO=gccgo set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD= set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2 set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\Vincent\AppData\Local\Temp\go-build688545542=/tmp/go-build -gno-record-gcc-switches
I will appreciate your help.
Vincent

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.