Presentation is loading. Please wait.

Presentation is loading. Please wait.

GO 杭州联云汽车科技. 安装 1 下载 –https://code.google.com/p/go/downloads/list 2 双击安装

Similar presentations


Presentation on theme: "GO 杭州联云汽车科技. 安装 1 下载 –https://code.google.com/p/go/downloads/list 2 双击安装"— Presentation transcript:

1 GO 杭州联云汽车科技

2 安装 1 下载 –https://code.google.com/p/go/downloads/list 2 双击安装

3 IDE 1 LiteIDE 2 ECLIPSE 3 IntelliJ IDEA 4 记事本 –notepad++ sublime Text vim emacs https://github.com/astaxie/build-web- application-with- golang/blob/master/ebook/01.4.md

4 HELLO WORLD hello.go package main import "fmt" func main() { fmt.Printf("Hello, world.\n") } CMD: go run hello.go

5 WEB 版 HELLO WORLD package main import "net/http" import "fmt" import "html" func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path)) }) http.ListenAndServe(":8080", nil) }

6 GO and Mysql 数据库驱动 –https://code.google.com/p/go-mysql-driver/ db,err := stmt,err := db.Prepare("insert into test(install,day,aid)values(?,?,?)"); result,err := stmt.Exec(1,2,3); rows,err := db.Query("select * from test limit 0,5"); rows.Scan(&id,&install,&day,&aid); fmt.Print(id);

8 GO and GUI go walk go-gtk qml More :

9 GO GUI DEMO go walk go get github.com/lxn/walk go get github.com/akavel/rsrc rsrc -manifest walk.manifest -o rsrc.syso go build walk.exe DEMO 代码来源: https://github.com/lxn/walk/tree/master/examples /imageviewer

10 GO AND CRON https://github.com/rk/go-cron func init() { cron.NewWeeklyJob(1, 23, 59, 59, func (*time.Time) { _, err := conn.Query("OPTIMIZE TABLE mytable;") if(err != nil) { println(err) } }) }

11 GO AND CLOUD 云计算语言 go 适用于大规模网络应用 并发控制 goroutine 语言级别的并发协程 channel 语言级别的队列

12 package main import ( "fmt" "sync" "net/http" ) func main() { var wg sync.WaitGroup var urls = []string{ "http://www.golang.org/", "http://www.google.com/", "http://www.baidu.com/", } for _, url := range urls { wg.Add(1) go func(url string) { // Decrement the counter when the goroutine completes. defer wg.Done() // Fetch the URL. http.Get(url) fmt.Println(url); }(url) } wg.Wait() fmt.Println("over"); }

13 package main import "fmt" func numberGen(start, count int, out chan<- int) { for i := 0; i < count; i++ { out <- start + i } close(out) } func printNumbers(in <-chan int, done chan<- bool) { for num := range in { fmt.Printf("%d\n", num) } done <- true } func main() { numberChan := make(chan int) done := make(chan bool) go numberGen(1, 10, numberChan) go printNumbers(numberChan, done) <-done }

14 书籍 Go Web 编程 –https://github.com/astaxie/build-web- application-with-golang Go 语言编程 Go 语言程序设计 Go 语言 · 云动力

15 Q & A THANKS


Download ppt "GO 杭州联云汽车科技. 安装 1 下载 –https://code.google.com/p/go/downloads/list 2 双击安装"

Similar presentations


Ads by Google