后端程序员之路 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 ...
随机推荐
- 2019 ccpc秦皇岛
1006 (dfs) #include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const dou ...
- P4718 [模板]Pollard-Rho算法
对一个大质数进行质因数分解 需要引用miller-robin来判素数 一直写的gcd居然挂掉了... 以后用__gcd了 #include <bits/stdc++.h> using na ...
- 使用eclipse写第一个Java_web的hello_world项目
1.先创建一个Java_web项目 如果你没有下载过Tomcat服务器,不会配置,建议看一下我得这一篇博客:https://www.cnblogs.com/kongbursi-2292702937/p ...
- Codeforces Round #647 (Div. 2) C. Johnny and Another Rating Drop(数学)
题目链接:https://codeforces.com/contest/1362/problem/C 题意 计算从 $0$ 到 $n$ 相邻的数二进制下共有多少位不同,考虑二进制下的前导 $0$ .( ...
- 2020杭电多校 C / HDU 6879 - Mine Sweeper
题意: t组输入,每组输入一个s 你需要输出一个r行c列的阵列,这个阵列中'X'代表炸弹,'.'表示没有炸弹 对于'.'这些位置都会有一个数值,这个值取决于这个位置附近8个位置,这8个位置一共有几个炸 ...
- 2020牛客暑期多校训练营(第二场) F.Fake Maxpooling (单调队列)
题意:有一个\(n\)x\(m\)的矩阵,\(A_{i,j}=lcm(i,j)\),对于每个\(k\)x\(k\)的子矩阵,其最大元素贡献给答案,求答案的最大值. 题解:矩阵构成我们直接\(i*j/g ...
- Docker架构分解
Docker总架构分解Docker对使用者来讲是一个C/S模式的架构,而Docker的后端是一个非常松耦合的架构,模块各司其职,并有机组合,支撑Docker的运行. 用户是使用Docker Clien ...
- ArcMobile的CoordinateCollection在逆时针添加点时自动调整节点顺序的问题
为了使用ArcMobile实现量测功能,LZ自定义了一个MapGraphicLayer用于绘图,代码如下: using System.Drawing; using ESRI.ArcGIS.Mobile ...
- C++ 指针 new delete int*与string
一 指针 string和int 都可以认为是四个字节sizeof(string)==4, string是个类,它的空间在堆动态分配 二.delete 只是释放空间 三.new 数组 int size= ...
- 全局ID生成--雪花算法
分布式ID常见生成策略: 分布式ID生成策略常见的有如下几种: 数据库自增ID. UUID生成. Redis的原子自增方式. 数据库水平拆分,设置初始值和相同的自增步长. 批量申请自增ID. 雪花算法 ...