GithubHelp home page GithubHelp logo

tools's Introduction

dubbo-go-cli

1. Problem we solved.

For the running dubbo-go server, we need a telnet-cli tool to test if the server works healthily. The tool should support dubbo protocol. It makes it easy for you to define your own request pkg and gets rsp struct of your server, and total costing time.

2. How to get cli-tool

go get -u github.com/dubbogo/tools/cmd/dubbogo-cli

3. How to get dubbo

go get -u github.com/dubbogo/tools/cmd/protoc-gen-dubbo

4. How to get dubbo3

go get -u github.com/dubbogo/tools/cmd/protoc-gen-dubbo3

5. How to get imports-formatter

go get -u github.com/dubbogo/tools/cmd/imports-formatter

6. Quick start:example

imports-formatter

1. Problem we solved.

For simplifying imports, we provider a tool named imports-formatter.it is a tool that help you format the imports of the project. it is easy to use with several commandline arguments.

2. How to get imports-formatter

go get -u github.com/dubbogo/tools/cmd/imports-formatter

3. Quick start

Note: Before use it, you need to set environment variable GOROOT(like export GOROOT=/usr/local/go). take an example of imports-formatter when we try to format the apache/dubbo-go

suppose that we have a go file in this project(github.com/dubbogo/tools) with these imports:

    import (
    	"os"
    	"github.com/dubbogo/tools/cmd/main"
        "dubbo.apache.org/dubbo-go/v3/config"
        "dubbo.apache.org/dubbo-go/v3/common"
    )

after execution of imports-formatter -path . -module github.com/dubbogo/tools -bl false, it will act like following:

    import (
        "os"
    )

    import (
        "dubbo.apache.org/dubbo-go/v3/common"
        "dubbo.apache.org/dubbo-go/v3/config"
    )

    import (
        "github.com/dubbogo/tools/cmd/main"	
    )

imports-formatter will split illegal format imports to three blocks:

  1. the first import block is some built-in modules/packages in go language.
  2. the second import block is some third party modules/packages.
  3. the third import block is the modules/packages in this module.

now we explain the usage of this tool with above command:

imports-formatter -path . -module github.com/dubbogo/tools -bl false

  • path: the directory that you want to format imports, the default value is current work directory.
  • module: the go module name, you can find it in go.mod of the project. if not set, it will find go.mod in path that you set.
  • bl: in second import block, we may have many third party modules, if bl is true, the tool will split these modules with a blank line. The default value is true.

so you can simplified the above command to imports-formatter -path . -module github.com/dubbogo/tools, and if you execute this command in the project root path, you can even ignore remaining 2 parameter, only need to type imports-formatter on your screen.

tools's People

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

Watchers

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

tools's Issues

go-triple_out not honor module=xxx go_opt option

my protoc command is like

protoc --proto_path="gfast/app/info/province_rpc/proto" --go_opt=module=gfast --go_out=. --go-triple_out=. province.proto

The province.proto was specified a full qualified package name

option go_package = "gfast/app/info/province_rpc/model";

The province.pb.go file was correctly generated at

MY_PROJECT_ROOT/app/info/province_rpc/model

with "gfast" prefix removed, but the province_triple.pb.go file was mistakenly placed into

MY_PROJECT_ROOT/gfast/app/info/province_rpc/model

protoc命令生成的pb文件缺少 common.ErrorWithAttachment

安装和生成pb

export GO111MODULE="on"
export GOPROXY="http://goproxy.io"
go install github.com/dubbogo/tools/cmd/protoc-gen-triple
cd api
protoc -I . helloworld.proto --triple_out=plugins=triple:.

结果:

image

环境信息:
dubbo.apache.org/dubbo-go/v3 v3.0.0-rc2
github.com/dubbogo/triple v1.0.1

Dubbogo-cli-v2 show zk with no dubbo service, cause panic.

problem 1:

 dubbogo-cli-v2 show --r zookeeper --h 127.0.0.1:2181
2022/03/16 16:27:53 Connected to 127.0.0.1:2181
2022/03/16 16:27:53 Authenticated: id=72060066796601349, timeout=15000
2022/03/16 16:27:53 Re-submitting `0` credentials after reconnect
panic: Error while invoking zk.Children(path:/dubbo), the reason maybe is: : zk: node does not exist

problem2:

Dubbogo-cli-v2 show interface twice?

dubbogo-cli-v2 show --r zookeeper --h 127.0.0.1:2181
2022/03/16 16:29:35 Connected to 127.0.0.1:2181
2022/03/16 16:29:35 Authenticated: id=72060066796601357, timeout=15000
2022/03/16 16:29:35 Re-submitting `0` credentials after reconnect
interface: grpc.reflection.v1alpha.ServerReflection
methods: [ServerReflectionInfo]
interface: org.apache.dubbo.demo.Greeter
methods: [SayHello,SayHelloStream]
interface: grpc.reflection.v1alpha.ServerReflection
methods: [ServerReflectionInfo]
interface: org.apache.dubbo.demo.Greeter
methods: [SayHello,SayHelloStream]

imports-formatter 在 Dubbo-go 3.0 分支运行时报错

  1. 注释导致的错误
$ imports-formatter -module dubbo.apache.org/dubbo-go/v3
panic: unexpected import format: * <a href="http://en.wikipedia.org/wiki/Failback">Failback</a> in file /Users/laurence/Desktop/workplace/dubbogo/dubbo-go/cluster/cluster_impl/failback_cluster_invoker.go

goroutine 1 [running]:
main.main()
        /Users/laurence/go/pkg/mod/github.com/dubbogo/[email protected]/cmd/imports-formatter/main.go:75 +0x18c
laurence@B-V9HYQ05P-1223 dubbo-go % imports-formatter -module dubbo.apache.org/dubbo-go/v3
panic: unexpected import format: * <a href="http://en.wikipedia.org/wiki/Fail-safe">Fail-safe</a> in file /Users/laurence/Desktop/workplace/dubbogo/dubbo-go/cluster/cluster_impl/failsafe_cluster_invoker.go

goroutine 1 [running]:
main.main()
        /Users/laurence/go/pkg/mod/github.com/dubbogo/[email protected]/cmd/imports-formatter/main.go:75 +0x18c
l
  1. 单个 import block 为什么会增加空行?
    我认为单个import block内不需要增加任何空行。单个import block 内条目的顺序这个工具无需关心。开发者最终需要执行 go fmt project来保证条目顺序正确。这个工具只关心3 block 拆分。
    @Mulavar

support dubbo-curl to send dubbo requests quickly

We need a curl-like tool to send dubbo requests quickly which can be used in dubbo api test.

the cmd may be like.

dubbo-curl -X POST 'http://localhost:8883/UserService/com.dubbogo.pixiu.UserService/GetUserByName'  \
-d '{"types":"string","values":"tc"}' \
-H 'Content-Type: application/json'  \
-H 'x-dubbo-http1.1-dubbo-version':'1.0.0' \ 
-H 'x-dubbo-service-protocol':"dubbo"  \
-H 'x-dubbo-service-version':'1.0.0'  \
-H 'x-dubbo-service-group':'test'

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.