当前位置:网站首页>First go program
First go program
2022-04-21 10:42:00 【genispan】
1. stay GO In language , All independently running programs must include package main, And all go The document must be marked with package <name> start
2. Use import Import required library files . As in the example code fmt
An example of variables and formatted output :
package main
import (
"fmt"
)
func main() {
var a int //define int var a, defalt 0
var b string //define string var b defalt ""
fmt.Printf("a = %d\n", a)
fmt.Printf("b = %s\n", b)
c := 10 //define int var c with value 10
d := true //define bool var d with value true
fmt.Printf("c = %d\n", c)
if d {
fmt.Println("d is true,so we get here.")
}
e, f := 20, 16 //also we can define two var in one line
fmt.Printf("e = %d\n", e)
fmt.Printf("f = %d\n", f)
//define const enum var
const (
g = iota //0
h = iota //1
)
fmt.Printf("g = %d\n", g)
fmt.Printf("h = %d\n", h)
s := `Charles'
first GO program!`
/* //same with following code
s := "Charles" +
"first GO program!"*/
fmt.Println(s)
//var i int /* if defined a var, and never use it, there will be a error*/
hello := "hello"
Arr := []byte(hello) // convert hello to a byte array
Arr[0] = 'c'
s2 := string(Arr)
fmt.Printf("%s\n", s2)
}
版权声明
本文为[genispan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211042160434.html
边栏推荐
- Android learning ① various reasons why Android cannot connect to MySQL database and Solutions
- ConvBERT: Improving BERT with Span-based Dynamic Convolution论文的阅读笔记
- Impact of AOT and single file release on program performance
- AcWing 1761. 阻挡广告牌 (计算几何,两个矩形的交集)
- What is the future development prospect of automated operation and maintenance platform?
- 【acwing】1459. 奶牛体操(模拟、思维)
- GO函数的使用
- GO 使用channel进行同步 (缓冲channel)
- 24 pictures to conquer border image
- 本地IP地址使用域名访问
猜你喜欢

最通俗易懂的依赖注入与控制反转

Pytoch gradient check torch autograd. gradcheck

微信公众号网页分享设置及问题

本地IP地址使用域名访问

如何阅读一份源代码?

Project scheme of shopping guide system based on Runhe Dayu development board

MKL与VS2019配置方法

AOT和单文件发布对程序性能的影响

Digital Economy & Green Innovation matching: Green Patent matching data of digital finance enterprises of 3169 companies in China, 2011-2019

Vulnhub PRIME: 1
随机推荐
A collection of econometric models and empirical Stata codes, with top publication examples
手把手教你:基于深度学习的滚动轴承故障诊断
The prospectus of quwan group is "invalid", and its TT voice has been taken off the shelf. How to achieve stable growth?
Release announcement of HMS core version 6.4.0
GO 使用channel进行同步 (缓冲channel)
2022 information and future preparation topic 4 new online judge 2034: pruning shrubs
比SQL還好用,又一門國產數據庫語言誕生了
postman设置环境变量,简单又实用
AcWing 1725. 组队井字游戏(枚举)
Signal and system 2022 spring semester: assignment content and reference answers
Microsoft updates the verifier application for Android / IOS to support the generation of more secure strong passwords
Design a high-quality API interface
torch.autograd.Function 自定义
页面导航-声明式/编程式导航
24 pictures to conquer border image
NFT中的版权漏洞:产品设计需考虑法律层面
What is the future development prospect of automated operation and maintenance platform?
zsh: segmentation fault 解决方法
二分查找符合要求的值及局部最小值
看完这篇 教你玩转渗透测试靶机vulnhub——DC9