当前位置:网站首页>Go, how to become a gopher, and find work related to go language in 7 days, Part 1
Go, how to become a gopher, and find work related to go language in 7 days, Part 1
2022-07-29 07:43:00 【Dream eraser】
List of articles
️ Before learning
The goal of this series of blogs is 7 Learn to Go Language , And find a Go Related work , There must be some preconditions , That is, the front technical point .
You need :
- Have a programming language foundation ,Python,PHP,C# …… Fine ;
- be familiar with Linux Basic operation , At least build small projects on the server side ;
- Skilled computer operation , Typing speed is not bad .
With these foundations , Only when 7 Master quickly within days Go Language , Otherwise, it is difficult to do .
️ Go The background of
To learn a language, you must first understand its background , Among them, we can find the cause of the language , There are also problems solved by the core of the language .
Go It's open source. , And in 2007 R & D started in ,2009 In open source ,2012 Released in 1.0 edition , As a language , Very young .
and Go Language is Unix The author of ,C The author of language , And Google's V8 The engine is built by this person , also Go Is launched by Google , So back to the mountain .
Go The mascot of is a gopher ( Its scientific name is gopher , chipmunk , English name Gopher), So a lot of Go The openers of call themselves Gopher.
Go The official website of language
https://golang.google.cn/learn/
Go Linguistic gihub
https://github.com/golang/go
These two sites are the key locations for future learning work to obtain first-hand materials .
Some more Go Language learning Chinese official website , You can search by yourself through the search engine , There are many communities , The learning stage can absorb a large amount .
Go Of hello world
I downloaded the latest version on the official website , In principle, it is better to choose a lower version in the learning stage , Relatively pure , But this issue is a quick start , So go straight to the new .
Install it and go to the next step , Enter the installation waiting page .
Enter... After installation CMD You can view its version number , Use the following command :
C:\Users\Administrator>go version
go version go1.18.4 windows/amd64
Next, write directly Hello World Code ,Go The suffix of the language is .go
, You can create one in any local directory 01_demo.go
file .
After installation , Found in Go Wrapped in VSCode Some functions are integrated in .
If prompted that it needs to install extensions , You can supplement yourself .
Hello World The code is very simple , Use the following command .
package main
import "fmt"
func main() {
fmt.Println("Hello,World")
}
The operation is also very simple , Use go run file name
that will do .
Because we already have the foundation of other languages , Therefore, the knowledge points at the grammatical level can be directly summarized .
First line code package main
, Define package name ,Go The syntax requires that you specify which package the file belongs to in the first line of the non comment .
This line of code is import Go Linguistic main package ,main The packaging is special , It defines an independent executable program , Not the library . stay main In bag , function main It's also special , It is where the program starts .
Go All files of the language need to specify their packages (package), There are two types of packages , One is to main package , Use package main Import , Another kind of right and wrong main package , Use package Package name
Import , stay Go Use in package Manage source files ,package Must be in a folder , And there can only be one under this folder package.
Lines of code import "fmt"
Indicates the need to use fmt
package , That is, call its variables 、 Functions and so on , This package is used to format I/O, Input and output functions .
Lines of code func main()
Is the start function of the program , Every executable program must contain main
.
Lines of code fmt.Println("Hello,World")
, Output function , You can see fmt
The package is called , According to the experience of other languages Println
Means line break , Print
No line break .
Here we have also experimented with an operation , When the braces {
perhaps }
On a single line , There will be errors .
func main()
{
fmt.Println("Hello,World")
}
Except as mentioned above go run file name
function Go Out of program , You can also use go build file name
take Go Code compiled as exe
Program .
PS F:\go_learn> go build .\01_demo.go
PS F:\go_learn> ls
Catalog : F:\go_learn
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2022/7/20 11:41 1892352 01_demo.exe
-a---- 2022/7/20 10:42 79 01_demo.go
️ Go Grammatical details
stay Go In language , A line is a statement , There is no need to use ;
ending , In fact, in practice, you can also write multiple sentences on one line , And then put ;
On use , But basically no one does this .
func main() {
fmt.Println("Hello");fmt.Println("World")
}
stay VSCode in , It is automatically formatted .
notes
The notes are relatively simple , Single line use //
, Use multiple lines /**/
.
identifier
stay Go in , Used to name variables , function , Type of content , It's an identifier , It needs letters , Numbers , Underline composition , And the first character must be a letter or underscore , It can't be a number , This is also required by other languages , No learning difficulty .
keyword
stay Go in , Yes 25 Keywords or reserved words , These generally do not need special memory , But when you ask for your own identifier to be named , Try to convey the meaning of words .
Declaration of variables
Go Languages are static types , Variable declarations need to have explicit types , The syntax format is as follows :
var name type
among var
Is the key word , name
Is a variable name. , type
It's the type of variable .
Go The basic types of language are :
- string
- int、int8、int16、int32、int64
- uint、uint8、uint16、uint32、uint64、uintptr
- byte(uint8 Another name for )
- rune (int32 Another name for )
- float32、float64
- complex64、complex128
- bool
After the variable is declared , The system automatically assigns a zero value , for example int The type is 0,float The type is 0.0 ……
The naming standard follows the small hump naming method , for example myName,xiaomingAge.
String concatenation and string formatting
Grammar is consistent with other languages , +
Express connection , When formatting strings , %s
, %d
Represent string and number respectively , The formatting function is as follows :
package main
import "fmt"
func main() {
var str_format = " Numbers :%d, character string :%s"
var new_str = fmt.Sprintf(str_format, 100, " Eraser ")
fmt.Println(new_str)
}
️ After learning
This blog is just Go Starting hand type , The next one is coming ~
You are reading 【 Dream eraser 】 The blog of
Finished reading , You can praise it with a little hand
Find the error , Correct it in the direct comment area
The second part of the eraser 696 Original blog
From the date of order , Case study 5 Guaranteed renewal during the year
边栏推荐
- Chaos and future of domestic digital collections
- Sqlmap(SQL注入自动化工具)
- Output 1234 three digits without repetition
- 准备esp32环境
- Sqlmap (SQL injection automation tool)
- [untitled] format save
- IonIcons图标大全
- MapReduce steps of each stage
- RoBERTa:A Robustly Optimized BERT Pretraining Approach
- Starting process of raspberry pie
猜你喜欢
[deep learning] data preparation -pytorch custom image segmentation data set loading
【WPF】通过动态/静态资源实现语言切换
Female graduate students do "mind mapping" and quarrel with their boyfriend! Netizen: the "king of infighting" in the quarrel
【暑期每日一题】洛谷 P7760 [COCI2016-2017#5] Tuna
美智光电IPO被终止:年营收9.26亿 何享健为实控人
[untitled] format save
What are the common error types and solutions of black box testing?
[summer daily question] Luogu p6461 [coci2006-2007 5] trik
Amaze UI 图标查询
What are the answers about older bloggers?
随机推荐
STM32 operation w25q256 w25q16 SPI flash
Logback log level introduction
What are the common error types and solutions of black box testing?
你学习·我奖励,21天学习挑战赛 | 等你来战
Sqlmap (SQL injection automation tool)
Amazon cloud assistant applet is coming!
Docker's latest super detailed tutorial - docker creates, runs, and mounts MySQL
Cs61abc sharing session (VI) detailed explanation of program input and output - standard input and output, file, device, EOF, command line parameters
写点dp
zip gzip tar压缩进阶版
Dilworth theorem
IonIcons图标大全
webapi接口文件下载时跨域问题
MySQL 45 | 08 is the transaction isolated or not?
Output 1234 three digits without repetition
Introduction to logback filter
Getting started with JDBC
【暑期每日一题】洛谷 P6336 [COCI2007-2008#2] BIJELE
Can the subset of the array accumulate K
LANDSCAPE