coderit666 / goguide Goto Github PK
View Code? Open in Web Editor NEW「Go语言学习指南」一份涵盖大部分 Golang 程序员所需要掌握的核心知识,拥有 Go语言教程、Go开源书籍、Go语言入门教程、Go语言学习路线。零基础学习 Go语言、Go编程,首选 GoGuide。
「Go语言学习指南」一份涵盖大部分 Golang 程序员所需要掌握的核心知识,拥有 Go语言教程、Go开源书籍、Go语言入门教程、Go语言学习路线。零基础学习 Go语言、Go编程,首选 GoGuide。
数值类型转字符串类型strconv..FormatXxx()中的 str3 := strconv.FormatFloat(num5, 'f', -1, 64)应该是 str3 := strconv.FormatFloat(num5, 'f', -1, 32)
package main
import "fmt"
func main() {
num := 1
if(num <= 10){
fmt.Println(num)
num++
goto outer // 死循环
}
outer:
fmt.Println("come here")
}
这仅仅是个if判断,也没有无限循环,且goto标记位于语句块之外的结尾处,即使循环也只执行一次,为什么要注释为死循环呢?
GO语言有值类型、引用类型
但是参数传递只有 值传递
引用类型传递的其相应的指针,参数的内存是独立的,拷贝过来的指针地址。
关于这点【不能将函数内的指向局部变量的指针作为返回值, 函数结束指向空间会被释放】有疑问,示例如下:
package main
import (
"fmt"
)
func f() *int {
n := 100
fmt.Println("1:", &n, n)
return &n
}
func main() {
n := f()
fmt.Println("2:", n, *n)
(*n) = 99
fmt.Println("3:", n, *n)
}
输出:
1: 0x140000aa008 100
2: 0x140000aa008 100
3: 0x140000aa008 99
os包和flag包获取命令行参数对比
通过os包获取命令行参数
如果用户没有传递参数会报错
需要严格按照代码中的顺序传递参数, 否则会造成数据混乱
不能指定参数的名称
获取到的数据都是字符串类型
这里的 int main() 要换成 func main() 不然编译通不过
package main
import (
"os"
"fmt"
)
// 下面这个 int main( )要换成 func main ( ) ************************************
int main(){
name := os.Args[1]
age := os.Args[2]
fmt.Println("name = ", name)
fmt.Println("age = ", age)
}
操作符^=和|=的含义写反了
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.