This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - govendor init: 初始化govendor 配置文件 | |
| - govendor list: 查看当前项目依赖包列表 | |
| - 左英文字母表示当前包 | |
|  |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Vue Native | |
| 你是 React Native 的粉丝吗?就像 React Native 一样,Vue Native 框架允许你使用 JavaScript 来构建跨平台的原生移动应用程序。 | |
| [地址](https://vue-native.io/) | |
| ## Vue Autosuggest | |
| 一个很棒的 Vue.js 自动提示组件。 | |
| [地址](https://github.com/Educents/vue-autosuggest) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### Go语言源码目录结构 | |
| ```shell | |
| $ go version | |
| $ go1.12.1 darwin/amd64 | |
| ``` | |
| ├──api:目录,包含所有API列表,方便IDE使用 | |
| ├──bin:一些Go的二进制命令文件 | |
| ├──doc:目录,Go语言的各种文档,官网上有的,这里基本会有,这也就是为什么说可以本地搭建“官网”。这里面有不少其他资源,比如gopher图标之类的 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### 切片 | |
| ```go | |
| slice := []int{1,2,3,4,5} | |
| newSlice := slice[i:j:k] | |
| ``` | |
| - newSlice长度:j-i | |
| - newSlice容量:k-i | |
| ```go | |
| slice := []int{1,2,3,4,5} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### 数组 | |
| ```go | |
| slice := [...]int{1, 2, 3, 4, 5} | |
| for _, v := range slice { | |
| v = 0 | |
| fmt.Println(v) | |
| // Output: 0 | |
| } | |
| fmt.Println(slice) | |
| // Output: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### Map | |
| - map是基于散列表来实现,就是我们常说的Hash表 | |
| - map存储的是无序的键值对集合 | |
| - map的key,可以重复,如果重复了,则相当于覆盖,后面覆盖前者 | |
| - map中的key可以是很多种类型,比如bool、数字、string、指针等,但是含有切片或函数的复杂类型则不能作为键使用,因为这几个没法用 == 来判断 | |
| - 对于map的值来说,就没有什么限制了,切片这种在键里不能用的,完全可以用在值里 | |
| ```go | |
| func main() { | |
| var m map[int]string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### Goroutine | |
| 一个程序运行的时候 | |
| - 一个进程 --> 多个线程 | |
| - 一个逻辑处理器(默认和当前电脑CPU数目一致)`(P)` --> 多个线程 | |
| - 一个线程`(M)`--> 多个协程 | |
| - 调度器:go运行时中的,分配goroutine给不同的逻辑处理器,等待线程处理 | |
| - 协程由go运行时实现 | |
| - 全局运行队列:所有刚创建的goroutine都会放到这里 | |
| - 本地运行队列:逻辑处理器的goroutine队列`(G)`,不超过256个 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### make和new的区别 | |
| ```go | |
| // The new built-in function allocates memory. The first argument is a type, | |
| // not a value, and the value returned is a pointer to a newly | |
| // allocated zero value of that type. | |
| func new(Type) *Type | |
| ``` | |
| - `new`只接受一个参数,这个参数是一个类型,分配好内存后,返回一个指向该类型内存地址的指针。同时请注意它同时把分配的内存置为零,也就是类型的零值 | |
| ```go |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### 函数传递是传值还是传引用 | |
| **Go中是没有引用传递的** | |
| - 基础类型是对值拷贝传递 | |
| - 引用类型是对指针拷贝传递 |