惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 甩掉裤衩凭风吹

Go学习例子(六) - 甩掉裤衩凭风吹 Go学习例子(五) - 甩掉裤衩凭风吹 Go学习例子(四) Go学习例子(三) Go学习例子(二) 一、Python基础语法 - 甩掉裤衩凭风吹 Python爬虫实战一之爬取糗事百科段子 Python爬虫系列:五、正则表达式 Python爬虫系列:四、Cookie的使用 - 甩掉裤衩凭风吹 python爬虫系列:三、URLError异常处理 - 甩掉裤衩凭风吹 python系列:二、Urllib库的高级用法 - 甩掉裤衩凭风吹 python系列:一、Urllib库的基本使用 - 甩掉裤衩凭风吹 二十七、mysql如何确保数据不丢失?有几点值得我们借鉴 二十六、聊聊mysql如何实现分布式锁 - 甩掉裤衩凭风吹 二十五、sql中where条件在数据库中提取与应用浅析 二十四、如何正确的使用索引? 二十三、mysql索引管理详解 二十二、mysql索引原理详解 二十一、什么是索引?
Go学习例子(一)
甩掉裤衩凭风吹 · 2021-11-29 · via 博客园 - 甩掉裤衩凭风吹

 Go by Example  https://gobyexample.com/

1、Hello World

第一个程序将打印经典的"hello world"消息。这是完整的源代码。

 运行该程序的命令:go run hello-world.go

或者将程序构建为二进制文件:go build hello-world.go  然后再点击执行该二进制文件查看:./hello-world

$ go run hello-world.go
hello world
$ go build hello-world.go
$ ls
hello-world    hello-world.go
$ ./hello-world
hello world

2、Values

Go 有各种值类型,包括字符串、整数、浮点数、布尔值等。以下是一些基本示例。

 

$ go run values.go
golang
1+1 = 2
7.0/3.0 = 2.3333333333333335
false
true
false 

3、Variables

在 Go 中,编译器显式声明并使用变量来检查函数调用的类型正确性。

var声明 1 个或多个变量。

Go 将推断初始化变量的类型。

 

$ go run variables.go
initial
1 2
true
0
apple 

 4、Constants

Go 支持字符、字符串、布尔值和数值的常量。

const声明一个常量值。

语句可以出现在语句可以出现的任何位置。

$ go run constant.go 
constant
6e+11
600000000000
-0.28470407323754404

5、For

for是 Go 唯一的循环结构。下面是循环的一些基本类型。

$ go run for.go
1
2
3
7
8
9
loop
1
3
5