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

  1. $ go version

1.2. go [get, install]

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

    1. $ 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:

    1. $ 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:

  1. $ goctl --version

Manual Installation

2.1 Downloads

Microsoft Windows

Windows Intel x86-64 bit processorgoctl-v1.4.3-windows-amd64.zip(14.7MB)

Microsoft Windows

Windows Intel x86-32 bit processorgoctl-v1.4.3-windows-386.zip(14MB)

Apple macOS(ARM64)

Support macOS Apple 64-bit processorgoctl-v1.4.3-darwin-arm64.tar.gz(14.5MB)

Apple macOS(x86-64)

Support macOS 64-bit processorgoctl-v1.4.3-darwin-amd64.tar.gz(14.7MB)

Linux

Support Linux 64 bit processorgoctl-v1.4.3-linux-amd64.tar.gz(14.8MB)

Linux

Support Linux 32 bit processorgoctl-v1.4.3-linux-386.tar.gz(13.9MB)

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:

  1. $ 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:

  1. $ goctl --version

Docker Installation

3.1 pull & run

  • amd64架构
  • arm64(M1)架构
  1. $ docker pull kevinwan/goctl
  2. $ docker run --rm -it -v `pwd`:/app kevinwan/goctl goctl --help
  1. $ docker pull kevinwan/goctl:latest-arm64
  2. $ docker run --rm -it -v `pwd`:/app kevinwan/goctl:latest-arm64 goctl --help

3.2 Validation

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

  • amd64架构
  • arm64(M1)架构
  1. $ goctl docker run --rm -it -v `pwd`:/app kevinwan/goctl:latest goctl --version
  1. $ goctl docker run --rm -it -v `pwd`:/app kevinwan/goctl:latest-arm64 goctl --version