Skip to main content

goctl installation

Overview

goctl is a go-zero's built-in handcuffle that is a major lever to increase development efficiency, generating code, document, deploying k8s yaml, dockerfile, etc.

Golang Direct

::note This installation method is used for Golang, no operating system is required. :::

1.1 View go version

$ go version

1.2. go [get, install]

  • If the go version is before 1.16, use the following command to install:

    $ GO111MODULE=on go get -u github.com/zeromicro/go-zero/tools/goctl@latest
  • If the go version is 1.16 and later, use the following command to install:

    $ GO111MODULE=on go install github.com/zeromicro/go-zero/tools/goctl@latest

1.3. Validation

Open the terminal input below to verify the installation successfully:

$ goctl --version

Manual Installation

2.1 Downloads

Other versions and operating systems can to go to Github to choose.

2.2 Installation

Extract downloads and move them to $GOBIN directory, see $GOBIN directory:

$ go env GOPATH

GOBIN is $GOPATH/bin, if you $GOPATH do not $PATH you need to add it to $PATH.

2.3. Validation

Once installed, you can perform the following instructions to verify whether you have installed successfully:

$ goctl --version

Docker Installation

3.1 pull & run

$ docker pull kevinwan/goctl
$ docker run --rm -it -v `pwd`:/app kevinwan/goctl goctl --help

3.2 Validation

Open the terminal input with the following instructions to verify the installation successfully:

$ docker run --rm -it -v `pwd`:/app kevinwan/goctl:latest goctl --version