后端程序员之路 52、A Tour of Go-2
# flowcontrol
- for
- for i := 0; i < 10; i++ {
- for ; sum < 1000; {
- For is Go's "while" - for sum < 1000 {
- Forever - for {
- if
- if x < 0 {
- } else {
- if v := math.Pow(x, n); v < lim {
- switch
- switch os := runtime.GOOS; os {
- A case body breaks automatically
- fallthrough
- defer
- A defer statement defers the execution of a function until the surrounding function returns.
- defer fmt.Println("world")
- Deferred function calls are pushed onto a stack(LIFO)
# moretypes
- Pointers - var p *int
- Structs
- type Vertex struct {
- v := Vertex{1, 2}
- Arrays
- var a [10]int
- primes := [6]int{2, 3, 5, 7, 11, 13}
- Slices
- var s []int = primes[1:4]
- A slice does not store any data, it just describes a section of an underlying array.
- q := []int{2, 3, 5, 7, 11, 13}
- var a [10]int -> a[0:10] == a[:10] == a[0:] == a[:]
- printSlice fmt.Printf("len=%d cap=%d %v\n", len(s), cap(s), s)
- The zero value of a slice is nil.
- a := make([]int, 5) // len(a)=5 || b := make([]int, 0, 5) // len(b)=0, cap(b)=5
- Slices of slices - board := [][]string{
- for i, v := range pow { || for i := range pow { || for _, value := range pow {
- Maps
- m[key] = elem
- elem = m[key]
- delete(m, key)
- elem, ok = m[key]
- Function values
- hypot := func(x, y float64) float64 {
- return func(x int) int {
后端程序员之路 52、A Tour of Go-2的更多相关文章
- 后端程序员之路 53、A Tour of Go-3
#method - Methods - Go does not have classes. However, you can define methods on types. ...
- 后端程序员之路 51、A Tour of Go-1
# A Tour of Go - go get golang.org/x/tour/gotour - https://tour.golang.org/ # welcome - ...
- 后端程序员之路 59、go uiprogress
gosuri/uiprogress: A go library to render progress bars in terminal applicationshttps://github.com/g ...
- 后端程序员之路 43、Redis list
Redis数据类型之LIST类型 - Web程序猿 - 博客频道 - CSDN.NEThttp://blog.csdn.net/thinkercode/article/details/46565051 ...
- 后端程序员之路 22、RESTful API
理解RESTful架构 - 阮一峰的网络日志http://www.ruanyifeng.com/blog/2011/09/restful.html RESTful API 设计指南 - 阮一峰的网络日 ...
- 后端程序员之路 16、信息熵 、决策树、ID3
信息论的熵 - guisu,程序人生. 逆水行舟,不进则退. - 博客频道 - CSDN.NEThttp://blog.csdn.net/hguisu/article/details/27305435 ...
- 后端程序员之路 7、Zookeeper
Zookeeper是hadoop的一个子项目,提供分布式应用程序协调服务. Apache ZooKeeper - Homehttps://zookeeper.apache.org/ zookeeper ...
- 后端程序员之路 4、一种monitor的做法
record_t包含_sum._count._time_stamp._max._min最基础的一条记录,可以用来记录最大值.最小值.计数.总和metric_t含有RECORD_NUM(6)份recor ...
- 后端程序员之路 58、go wlog
daviddengcn/go-colortext: Change the color of console text.https://github.com/daviddengcn/go-colorte ...
随机推荐
- 【Azure Redis 缓存】如何得知Azure Redis服务有更新行为?
问题描述 Azure Redis作为微软云提供的一种PaaS服务,由于PaaS的特性,服务端的安装和维护.修补.升级等操作均由平台放负责.虽然最终用户只需要关注当前服务的使用,但是后台的升级和补丁行为 ...
- Luogu 2017 Autumn Camping 游记
颓得不行的我到D2才想起来自己可以写一篇low得不能再low的游记,然后就动笔了...... Day0 愉快地看着三联,想着别人放一天我放四天的悠闲生活,内心甚是平静.然而晚上回到家就开始浪了,看完了 ...
- Codeforces Round #646 (Div. 2) E. Tree Shuffling(树上dp)
题目链接:https://codeforces.com/contest/1363/problem/E 题意 有一棵 $n$ 个结点,根为结点 $1$ 的树,每个结点有一个选取代价 $a_i$,当前 $ ...
- C# Dictionary(字典)源码解析&效率分析
通过查阅网上相关资料和查看微软源码,我对Dictionary有了更深的理解. Dictionary,翻译为中文是字典,通过查看源码发现,它真的内部结构真的和平时用的字典思想一样. 我们平时用的字典主要 ...
- leetcode 1 两数之和 hashmap
主要是hashmap.还有边插入边查找,提高效率和降低空间复杂度. 之前一直用map,结果发现还有hashmap,效率更高. 注意名称空间为 using namespace __gnu_cxx; 问题 ...
- 统计学三大相关性系数:pearson,spearman,kendall
目录 person correlation coefficient(皮尔森相关性系数-r) spearman correlation coefficient(斯皮尔曼相关性系数-p) kendall ...
- JavaScript Engine 可视化
JavaScript Engine 可视化 图解 JavaScript Engine JavaScript 可视化 (7 部曲) ️ JavaScript Visualized: Event Loop
- 网站资源被盗链的:预防方法 VS 网站资源防盗链的:破解技巧
1 www.cnblogs.com 发布文章使用:只允许注册用户才可以访问! 1 资源被盗链:(简明定义) 下载者不是从你的网站直接下载资源,而是通过其他盗链网站提供的你的下载资源链接进行下载你的服务 ...
- webpack OSS All In One
webpack OSS All In One 阿里云 OSS 对象存储(Object Storage Service,简称OSS),是阿里云对外提供的海量.安全和高可靠的云存储服务 https://c ...
- Apple Watch Series 6 字母图案 (图解教程)
Apple Watch Series 6 字母图案 (图解教程) Apple Watch Series 6 自定义文字 如何开启 字母图案 solution 1 选择 彩色 表盘️ PS: 该复杂功能 ...