學習參考
- 清華大佬196小時講完的Go語言教程 lower
- 8小時轉(zhuǎn)職Golang工程師(如果你想低成本學習Go語言) 61.6萬
- 【尚硅谷】Golang入門到實戰(zhàn)教程丨一套精通GO語言 215.9萬
- 馬士兵教育-2023版GO語言
- 郭宏志Golang入門到項目實戰(zhàn)
- https://duoke360.com/tutorial/path/golang
go包官網(wǎng):https://pkg.go.dev/
- 進入項目目錄
- 初始化:go mod init dirname
- 安裝包:go get github.com/go-sql-driver/mysql
項目創(chuàng)建步驟
- 1.創(chuàng)建項目目錄
- 2.初始化項目 `go mod init 項目名即目錄名 生成go.mod`
- 3.創(chuàng)建包
建user目錄即包地啰,包名首字大寫即公用
- 4.創(chuàng)建模塊
- 5.相互調(diào)用
第一個程序示例
//go.mod
module GoGhz
go 1.21.2
//示例代碼
//user/user.go
package user
func Hello() string {
return "hello"
}
//main.go
package main
import (
"GoGhz/user"
"fmt"
)
func main() {
s := user.Hello()
fmt.Printf("s : %v\n", s)
}
golang 標識符、關(guān)鍵字、命名規(guī)則
標識符的組成
- 標識符由數(shù)字、字母、下劃線(_)組成
- 只能以字母和下劃線開頭
- 標識符區(qū)分大小寫
關(guān)鍵字25個
break default func interface select
case defer go map struct chan else goto package switch
const fallthrough if range type
continue for import return var
預(yù)定義標識符36個
append bool byte