#install _go

  • install version (v1.16.4 or above)

  • To find and download latest version available version go to official: https://go.dev/dl/

  • download file go with prefix ……linux-amd64.tar.gz

  • extract: sudo tar -xvf go1.19.linux-amd64.tar.gz

  • move file extact: sudo mv go /usr/local

  • GOROOT is the location where Go package is installed on your system:

  • export GOROOT=/usr/local/go

  • GOPATH is the location of your work directory. For example my project directory is ~/go

  • export GOPATH=$HOME/go

  • Now set the PATH variable to access go binary system wide:

  • export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

  • detail $PATH

 

#install_protoc

  • install version (v3.17.3 or above)

  • download binary from https://github.com/protocolbuffers/protobuf/releases/tag/v3.17.3

  • extract file download, sudo unzip protoc-3.17.3-linux-x86_64.zip

  • masuk ke folder extract

  • pindah file hasil extract ke path yang sudah diarahkan, kita bisa check dengan cara

  • which protoc

    usr/local/bin/protoc
  • move to this directory, sudo cp protoc /usr/local/bin/protoc

  • check version protoc: protoc —version


#issue_protoc

2023/02/21 09:56:19 protoc-gen-go: error:inconsistent package import paths: "google.golang.org/genproto/googleapis/api/annotations", "google.golang.org/genproto/googleapis/api/httpbody" 2023/02/21 09:56:19 protoc-gen-go: error:inconsistent package import paths: "google.golang.org/protobuf/types/known/anypb", "google.golang.org/protobuf/types/descriptorpb" Failure: plugin go: exit status 1; context canceled; exit status 1; context canceled; signal: killed; signal: killed; signal: killed; context canceled
  • This issue is because the system has protobuf-compiler installed, it must be removed first
  • sudo apt remove protobuf-compiler


#install_buf

  • install version (recommended 1.4.0)

  • create file name_file.sh and enter the following data:

BIN="/usr/local/bin" && \ VERSION="1.4.0" && \ curl -sSL \ "https://github.com/bufbuild/buf/releases/download/v${VERSION}/buf-$(uname -s)-$(uname -m)" \ -o "${BIN}/buf" && \ chmod +x "${BIN}/buf"
  • run: sudo sh name_file.sh

  • reference: https://docs.buf.build/installation


#install_mockery

  • install version (v2.10.6 or above)

  • go install github.com/vektra/mockery/v2@v2.20.0

  • reference: https://vektra.github.io/mockery/installation/

I found a problem when i will run golang project, this is my message error


2023/02/16 09:43:29 Service RUN on DEBUG mode
2023/02/16 09:43:29 this user requires mysql native password authentication.
exit status 1

Solution:

1. Change the password setting of the user to connect to the database, like this


- mysql -u root -p
- ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '[password]'
- ALTER USER 'root'@'localhost' IDENTIFIED BY '#d4esUqzQpS9XZNv';

2. Go to /etc/mysql/my.cnf and add this config



[mysqld]
default-authentication-plugin=mysql_native_password

it's work for me


2023/02/16 10:01:33 Service RUN on DEBUG mode

   ____    __
  / __/___/ /  ___
 / _// __/ _ \/ _ \
/___/\__/_//_/\___/ v3.3.5
High performance, minimalist Go web framework
https://echo.labstack.com