后端程序员之路 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 ...
随机推荐
- F - Courses (学生选课(匈牙利算法模板))
题目大意:一共有N个学生跟P门课程,一个学生可以任意选一门或多门课,问是否达成: 1.每个学生选的都是不同的课(即不能有两个学生选同一门课) 2.每门课都有一个代表(即P门课都被成功选过) 输入为: ...
- 【noi 2.6_6046】数据包的调度机制(区间DP)
题意:给定一个队列延迟值为Di的任务,以任意顺序入栈和出栈,第K个出栈的延迟值为(K-1)*Di.问最小的延迟值. 解法:f[i][l]表示完成以第i个任务开始,长度为l,到第i+l-1个任务的最小延 ...
- Bézout恒等式
写在前面: 记录了个人的学习过程,同时方便复习 整理自网络 非原创部分会标明出处 目录 结论 证明 拓展 n个整数间 拓展欧几里得算法 拓展欧几里得算法的多解 结论 (Bézout / 裴蜀 / 贝祖 ...
- hdu3033 I love sneakers!
Problem Description After months of hard working, Iserlohn finally wins awesome amount of scholarshi ...
- 踏上Revit二次开发之路 3 自己的工具按钮
3 自己的工具按钮 上次的例子只能在"附加模块"→"外部工具"下运行,用作个人作品是没问题,如果打算搞个公司产品的话,估计BOSS是不会满意的.这次我来做一个直 ...
- CF1474-D. Cleaning
CF1474-D. Cleaning 题意: 给出一个长度为\(n\)的正整数序列,你可以对序列进行如下操作: 对序列中相邻的两个数字\(a_{i}, a_{i+1}\)同时减去一个数字\(t(t&l ...
- VScode 相关
1.F5运行py文件,打开terminal终端的时候总是弹出Powershell窗口,只能在powershell窗口中用命令行运行程序,实在很不方便. 解法:右键Powershell属性,取消使用旧版 ...
- Zabbix 监控 SNMP & JMX
Zabbix 配置清华源 # 安装清华源 yum 仓库 [root@db01 ~]# rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabb ...
- 后Low Code时代:聚焦和突破
很多人都不想被贴上标签,我曾经也一样.觉得青春不能被定义,人也不能被分类.但随着学习和工作的变迁,慢慢开始发现标签也是一种名片效应. 比如一个做汽车销售的朋友,他就对BMW的车型非常熟悉,可以说是懂车 ...
- 翻译:《实用的Python编程》01_05_Lists
目录 | 上一节 (1.4 字符串) | 下一节 (1.6 文件) 1.5 列表 本节介绍 Python 原始数据类型列表(list). 列表是一种有序的集合. 创建列表 使用方括号 [] 来定义列表 ...