当前位置:网站首页>Go language introduction, environment installation, basic structure
Go language introduction, environment installation, basic structure
2022-04-22 14:50:00 【Game programming】
1.Hello Go!
Go Is an open source programming language , It makes construction simple 、 Reliable and efficient software becomes easy .
Go It's from 2007 Year end by Robert Griesemer, Rob Pike, Ken Thompson Host development , Later I joined in Ian Lance Taylor, Russ Cox wait forsomeone , And finally 2009 year 11 In open source , stay 2012 Released earlier this year Go 1 Stable version . Now? Go The development of is completely open , And have an active community .
Go Language features
- concise 、 Fast 、 Security
parallel 、 Interesting 、 Open source
memory management 、 Array security 、 Compile quickly Go The language is designed as an application for carrying Web The server , System programming language for storage cluster or similar giant central server .
For the field of high-performance distributed systems ,Go Language is undoubtedly more efficient than most other languages . It provides massive parallel support , This is no better for the development of the game server .
2. Environmental installation
Check :
C:\Users\dahez>go versiongo version go1.18.1 windows/amd64
GoLand Download address
To configure Go Path
1. Create a new one Gopath Catalog
2. Add to system variable :
3.Goland,File—Setting
4. To configure Goroot:
5. To configure Gopath:
Check here ~
Be accomplished !
3.Go Language structure
Go The basic components of language are as follows :
- Package declaration
Introduction package
function
Variable
sentence & expression
notes Now let's look at the simple code , The code is output "Hello World!":
package mainimport "fmt"func main() { /* This is my first simple program */ fmt.Println("Hello, World!")}
Let's take a look at the various parts of the above program :
- First line of code
package mainThe package name is defined . You have to indicate in the first line of the source file which package this file belongs to , Every Go The application contains a file namedmainMy bag . The next line
import "fmt"tell Go Compiler this program needs to usefmtpackage ( Function of , Or other elements ),fmtPackage implements formatting IO( Input / Output ) Function of .The next line
func main()Is the function that the program starts to execute .main Function is a necessary part of every executable program , Generally speaking, it is the first function executed after startupThe next line
/\*...\*/It's a comment , Will be ignored during program execution .The next line
fmt.Println(...)You can output strings to the console , And at the end automatically add the line feed character\nIt should be noted that { You can't put it on a single line , So the following code will generate errors at run time :
package mainimport "fmt"func main() { // error ,{ Not on a single line fmt.Println("Hello, World!")}
4.Go Compilation execution of
Enter the command go run hello.go And press enter to execute the code
$ go run hello.goHello, World!
We can also use go build Command to generate binary files
$ go build hello.go $ lshello hello.go$ ./hello Hello, World!
Copyright notice : This tutorial is based on the rookie tutorial
author : The end of the world and you
Game programming ️, A game development favorite ~
If the picture is not displayed for a long time , Please use Chrome Kernel browser .
版权声明
本文为[Game programming]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204221444074061.html
边栏推荐
- It people should not only improve their earning ability, but also expand their ways of making money. The "immortal document" released by Tencent's technical officer is a hot network
- 集合类
- When allowCredentials is true, allowedOrigins cannot contain the special value “*“ since that canno
- Android 开发面试题集合整理(内含答案),【工作感悟】
- 中国 AI 的“黄埔军校”?MSRA 被曝停招“国防七子”及北邮学生
- net::ERR_INCOMPLETE_CHUNKED_ENCODING 200 EL表达式字符串拼接
- memcpy( )函数复制二维数组 & memcmp( )函数比较二维数组
- 985 Shuo's difficult transition to Android, plus face-to-face experience sharing, meituan Android interview
- 如何配置 SLO
- C install opencv
猜你喜欢

每周问答精选:PolarDB-X完全兼容MySQL吗?

Alibaba cloud IOT transfer to PostgreSQL database scheme

Alibaba cloud IOT transfer to PostgreSQL database scheme

Collection class

【ELT.ZIP】OpenHarmony啃论文成长计划——多维探秘通用无损压缩

Tencent build project image

Machine learning model fusion method!
智能手表的下半场,机遇与挑战并存

SQL Server 数据库之常量
985 Shuo's difficult transition to Android, plus face-to-face experience sharing, meituan Android interview
随机推荐
[ELT. Zip] openharmony paper club -- counting the compressed bits of life
Ruoyi integrates JSP and thymeleaf solutions at the same time
web自动化测试框架通过js来实现对web元素的操作
Amazon Aurora 的读写能力扩展之 ShardingSphere-Proxy 篇
[mydatanotis.08001] mydatagrid connection error
App+小程序容器 企业也能轻松打造超级应用生态
【ELT.ZIP】《CCF开源高校行第一期》观后感
PCBA/IPQ4019 /openWRT 2.4/5G dual bands IPQ4019 openWRT 2.4/5G dual bands
985 Shuo's difficult transition to Android, plus face-to-face experience sharing, meituan Android interview
*CTF2022 - Web
快捷键删除浏览器缓存,windows组合键,cmd快捷命令
My new jamstack based blog
Wireguard series (1): what is v * *?
vscode settings. JSON location
Whampoa Military Academy of Chinese AI? MsrA was exposed to stop recruiting "national defense seven" and Beiyou students
golang入门笔记—redis
STM32将采集数据以TXT文件形式保存在SD卡的操作实战,小小单片机系统也能便携取出大量本地数据(SD卡+FATFS)
Crossplane - a more advanced cloud infrastructure management platform than terraform?
postMassage留个坑
Quickly understand what the dictionary in redis is