[Java to Go] Quick Start Study Notes (1) Environment Installation Chapter

Preface

I started learning Go two days ago and I need to write a note to summarize it.

Go can also be used for web development. Just like Java, Go can also be used for JavaWeb projects. Go can also be used for GoWeb projects. Of course, Go has more uses than this, and there are many more. Just because I am currently working on JavaWeb projects, the company is also considering using Go as the web backend in the future instead of using Java (because I think Java is too problematic. If there are too many, loopholes will appear every now and then). Therefore, I am mainly learning Go in the direction of web development.


Learn the basics in the early stage; then send requests, return data, process data, etc.; then you need to connect to the database and operate the database. Here you need to learn the ORM framework; finally, learn the web framework. After learning, you can try to build a complete Goweb project for business developed.

It should be roughly like this process (because I am only learning the basics now, if you have anything to add, please leave it in the comment area~)


The basics include: syntax, basic data types, variables, constants, operators, flow control statements, functions, and parameter transfer (formal parameters, actual parameters). After learning these basics, you can also expand and advance: reference data types, value passing, reference passing, slicing, pointers, anonymous functions, callback functions, generics, etc.

To connect to the database later, regarding the ORM framework, I should learn Gorm, which corresponds to Java's mybatis.

Then the web framework learns fiber, which corresponds to Java's spring boot.

Environment installation

After talking about what we need to learn, let's start installing the environment.

For sdk environment, we go toGo language Chinese website to download. Download the corresponding sdk according to your own operating system. I downloaded it for windows. operating system.

Insert image description here
After downloading, before installation, we first create two folders: one is GOROOT, which is the directory used to install the sdk environment, which is equivalent to the Java jdk installation directory; one is GOPATH, which we will write later. The location where the Go code is stored (code storage location).

My environment installation directory puts it together with jdk

Insert image description here
I also put the code storage location in the workspace folder (including Java and front-end code here)

Insert image description here
Insert image description here
Insert image description here

After you are ready, install the environment. After installation, it will automatically help us configure the environment variables:

Code storage location:
Insert image description here

sdk environment directory:

Insert image description here
After installation, you can use cmd to check whether the installation is successful. Open cmd and enter: go version

Insert image description here


development tools

After the environment is installed, the next step is the development tools. The editor for Go is GoLand. You need to go to the jetbrains official website:GoLand download

You can download the compressed package, which means you don’t need to install it, just unzip it and use it. However, like idea, it also needs to be activated when using it.

Of course, you can do it without GoLand. You can directly use vscode or idea. The configuration of vscode should be a little more troublesome, but idea is very simple. Just download the Go plug-in. So I didn’t download GoLand and developed directly with idea.

Insert image description here

After idea installs the Go plug-in, you can create a new project. At this time, we can choose to create a Go project.

Insert image description here
Insert image description here

Click create to create a Go project, and we can start writing code happily~

Guess you like

Origin blog.csdn.net/weixin_43165220/article/details/132289429