GrantZheng / kit

GoKit CLI
MIT License
268 stars 54 forks source link

panic: illegal line number (line numbering starts at 1) #7

Open kaisawind opened 4 years ago

kaisawind commented 4 years ago
kit g s device --dmw

深度截图_选择区域_20200802042848

GrantZheng commented 4 years ago

@kaisawind Hi, I can not reproduce the problem ,could you show some details: 1) go version; 2) go env; 3) the command for installing the kit; 4) the command for creating the service ; 5) the detail of your service file; thanks:)

kaisawind commented 4 years ago

import "context"

// DeviceService describes the service. type DeviceService interface { // Add your methods here Ping(ctx context.Context, s string) (rs string, err error) }

type basicDeviceService struct{}

func (b *basicDeviceService) Ping(ctx context.Context, s string) (rs string, err error) { // TODO implement the business logic of Ping return rs, err }

// NewBasicDeviceService returns a naive, stateless implementation of DeviceService. func NewBasicDeviceService() DeviceService { return &basicDeviceService{} }

// New returns a DeviceService with all of the expected middleware wired in. func New(middleware []Middleware) DeviceService { var svc DeviceService = NewBasicDeviceService() for _, m := range middleware { svc = m(svc) } return svc }

GrantZheng commented 4 years ago
  • go info
# go version
go version go1.14.5 linux/amd64
# go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/pana/.cache/go-build"
GOENV="/home/pana/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY="dev.yunxing.tech,github.com/kaisawind"
GONOSUMDB="dev.yunxing.tech,github.com/kaisawind"
GOOS="linux"
GOPATH="/home/pana/go"
GOPRIVATE="dev.yunxing.tech,github.com/kaisawind"
GOPROXY="https://goproxy.io,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build973303776=/tmp/go-build -gno-record-gcc-switches"
  • install kit
git clone https://github.com/GrantZheng/kit.git
cd kit
go install 
  • create service
kit n s -b /home/pana/go/src/github.com/kaisawind/iotx -m github.com/kaisawind/iotx/device
# change service file(Add ping api)
kit g s device              # ok
kit g s device --dmw  # error happend
kit g s device -t grpc # ok
kit g c device              # ok
  • service file
package service

import "context"

// DeviceService describes the service.
type DeviceService interface {
  // Add your methods here
  Ping(ctx context.Context, s string) (rs string, err error)
}

type basicDeviceService struct{}

func (b *basicDeviceService) Ping(ctx context.Context, s string) (rs string, err error) {
  // TODO implement the business logic of Ping
  return rs, err
}

// NewBasicDeviceService returns a naive, stateless implementation of DeviceService.
func NewBasicDeviceService() DeviceService {
  return &basicDeviceService{}
}

// New returns a DeviceService with all of the expected middleware wired in.
func New(middleware []Middleware) DeviceService {
  var svc DeviceService = NewBasicDeviceService()
  for _, m := range middleware {
      svc = m(svc)
  }
  return svc
}

Thank you for providing me information. I can reproduce the case, and you could use it without -b flag first. I will fix it as soon as possible. :)