go/golang学习之路(1)go指南练习题解答
Contents
go指南练习题
练习:切片
https://tour.go-zh.org/moretypes/18
|
|
终端运行结果:
yan@yanyongs-iMac tour % go run z.go
IMAGE:iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8xAAACJklEQVR42uzX0Q3CMBBEwT3H6b/kowckftgZbQVID19usoFWx0+AAKDUTTJjVjovAE4gEAAIACo/gs8xq5z/AJxAIAAQAAgABAACAAGAAEAAIAAQAPyFSfZ5YtY5LwBOIBAACAAEAAIAAYAAQAAgABAACAAEAAIAAYAAQAAgABAACAAEAAIAAYAAQAAgABAACAAEAAIAAYAAQADwU5PsvTHrnBcAJxAIAAQAAgABgABAACAAEAAIAAQAAgABgABAACAAEAAIAAQAAgABgABAACAAEAAIAAQAAgABgABAACAAEAAIAAQAAgABgABAACAAEAAIAAQAAgABgABAACAAEAAIAASAAEAAIAAQAAgABAACAAGAAEAAIAAQAAgABAACAAGAAEAAIAAQAAgABAACAAGAAEAAIAAQAAgABAACAAGAAEAAIAAQAAgABAACAAGAAOALk+z7xqxzXgCcQCAAEAAIAAQAAgABgABAACAAEAAIAAQAAgABgABAACAAEAAIAAQAAgABgABAACAAEAAIAAQAAgABgABAACAAEAAIAAQAAgABgABAACAAEAAIAAQAAgABgABAACAAEAACAAGAAEAAIAAQAAgABAACAAGAAEAAIAAQAAgABAACAAGAAEAAIAAQAAgABAACAAGAAEAAIAAQAAgABAACAAGAAEAAIAAQAAgABAACAAGAAEAAIAAQAAgABAACAAGAAEAACAAEAI0+AQAA//8Y9yPg0iquogAAAABJRU5ErkJggg==
显示成图片:
练习:映射
https://tour.go-zh.org/moretypes/23
|
|
练习:斐波纳契闭包
https://tour.go-zh.org/moretypes/26
|
|
|
|
|
|
|
|
练习:Stringer
https://tour.go-zh.org/methods/18
|
|
练习:错误
https://tour.go-zh.org/methods/20
|
|
练习:Reader
https://tour.go-zh.org/methods/22
|
|
练习:rot13Reader
https://tour.go-zh.org/methods/23
|
|
练习:图像
https://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gNHawGwGpItcBfSNODcCDNLYT30swgtJ31hM6ysCwsC8vCsrAsLAvLwrKwLCwLy342/B/BupawriWsawnrWsK6lrCuAdY16VaasTRTaeZ0tZ1lj6GFZWFZWBaWhWVhWVgWloVlYVlYFpaFZWGtB9a/AwAA//+UpGahQPb9EAAAAABJRU5ErkJggg==
显示成图片:
练习:等价二叉查找树
https://tour.go-zh.org/concurrency/7
https://tour.go-zh.org/concurrency/8
|
|
参考:https://stackoverflow.com/questions/12224042/go-tour-exercise-7-binary-trees-equivalence
练习:Web 爬虫
Exercise: Web Crawler
https://tour.go-zh.org/concurrency/10
https://go.dev/tour/concurrency/10
|
|
参考:
https://tim.bai.uno/golang-exercise-web-crawler-a-tour-of-go/
https://gist.github.com/harryhare/6a4979aa7f8b90db6cbc74400d0beb49
官方文档链接
golang.org会跳转go.dev域名