后端程序员之路 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 ...
随机推荐
- 1150 Travelling Salesman Problem
The "travelling salesman problem" asks the following question: "Given a list of citie ...
- AtCoder Beginner Contest 176 D - Wizard in Maze (BFS,双端队列)
题意:给你一张图,"."表示能走,"#表示不能走,步行可以向四周四个方向移动一个单位,使用魔法可以移动到周围\(5\)X\(5\)的空地,问能否从起点都早终点,并求最少使 ...
- 【uva 10570】Meeting with Aliens(算法效率--暴力+贪心)
题意:输入1~N的一个排列,每次可以交换2个整数,问使排列变成1~N的一个环状排列所需的虽少交换次数.(3≤N≤500) 解法:(又是一道我没打代码,光想和看就花了很久时间的题~QwQ)由于n很小,可 ...
- Codeforces Round #646 (Div. 2) 题解 (ABCDE)
目录 A. Odd Selection B. Subsequence Hate C. Game On Leaves D. Guess The Maximums E. Tree Shuffling ht ...
- Linux core dump使用
什么是 core dump? core dump是一个当进程意外终止时包含进程内存内容的文件.当程序崩溃的时候,core dump由kernel触发.core dump可以作为程序崩溃时的事后快照(p ...
- 【转】REST风格框架实战:从MVC到前后端分离(附完整Demo)
版权声明:欢迎转载,注明作者和出处就好!如果不喜欢或文章存在明显的谬误,请留言说明原因再踩哦,谢谢,我也可以知道原因,不断进步! https://blog.csdn.net/justloveyou_/ ...
- VRRP(Virtual Router Redundancy Protocol) 虚拟路由器冗余协议简介
因工作中使用Keepalived配置Nginx代理和MySQL代理的高可用,而Keepalived是VRRP协议在linux上的软件实现.因此了解了下VRRP的基础. 1. VRRP技术的引入 随着I ...
- spring再学习之基本概念
二.spring之IOC与DI 注入的方式: set方法注入: 构造方法注入: 字段注入: 注入类型: 值类型注入:8中基本类型 引用类型注入: BeanFaactory是原始接口:功能比较单一. A ...
- Linux 日志切割方法总结--Logrotate
一.Logrotate 使用方法 对于Linux系统安全来说,日志文件是极其重要的工具.logrotate程序是一个日志文件管理工具.用于分割日志文件,删除旧的日志文件,并创建新的日志文件,起到&qu ...
- woj1016 cherry blossom woj1017 Billiard ball 几何
title: woj1016 cherry blossom date: 2020-03-18 20:00:00 categories: acm tags: [acm,几何,woj] 几何题,判断给出的 ...