后端程序员之路 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 ...
随机推荐
- 【poj 2976】Dropping tests(算法效率--01分数规划 模版题+二分){附【转】01分数规划问题}
P.S.又是一个抽时间学了2个小时的新东西......讲解在上半部分,题解在下半部分. 先说一下转的原文:http://www.cnblogs.com/perseawe/archive/2012/05 ...
- c语言实现链表增、删、改、查及文件读写 && 链表实现程序
一.链表实现增删改查 1.链表定义 1 #include<stdio.h> 2 #include<string.h> 3 #include<windows.h> 4 ...
- .net webapi 中使用session是出错 HttpContext.Current.Session==null
最近在写.net webapi时发现 HttpContext.Current.Session==null ,导致报错,后来查资料发现webapi中使用session时首先需要开启session功能, ...
- 数据可视化 -- Python
前提条件: 熟悉认知新的编程工具(jupyter notebook) 1.安装:采用pip的方式来安装Jupyter.输入安装命令pip install jupyter即可: 2.启动:安装完成后,我 ...
- SpringSecurity简单使用
什么是SpringSecurity? Spring Security是一个能够为基于Spring的企业应用系统提供声明式的安全访问控制解决方案的安全框架.它提供了一组可以在Spring应用上下文中配置 ...
- LSTM - 长短期记忆网络
循环神经网络(RNN) 人们不是每一秒都从头开始思考,就像你阅读本文时,不会从头去重新学习一个文字,人类的思维是有持续性的.传统的卷积神经网络没有记忆,不能解决这一个问题,循环神经网络(Recurre ...
- Docker网络模式详解
一.Docker四种工作模式 安装Docker时,它会自动创建三个网络,bridge(创建容器默认连接到此网络). none .hosthost:容器将不会虚拟出自己的网卡,配置自己的IP等,而是使用 ...
- PyQt5 问题集
PyQt5中遇到的一些问题 1.多线程中界面异步刷新 我这里需要给界面动态添加新的控件,但是多线程中似乎并不能直接更新页面? 对于逻辑和界面分离的情况,使用自定义信号的方式进行页面控件的动态添加.注意 ...
- C# wpf window
使用vs2017 新建wpf 项目 MainWindow 被定义为partial,是因为他要和xaml的一些属性组合在一起,然后再运行起来,这正是 InitailizeCompoent 这个函数要干的 ...
- Linux下为Chromium安装Flash插件
方案1: http://askubuntu.com/questions/158388/how-do-i-make-chromium-use-flash-from-google-chrome/21647 ...