-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a25f1a
commit 5c857c7
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
desc: Go 夜读之 flag 包源码阅读 | ||
title: 第 31 期 Go 夜读之 flag 包源码阅读 | ||
date: 2019-02-23T21:00:00+08:00 | ||
author: mai | ||
--- | ||
|
||
*Go 标准包阅读* | ||
|
||
Go 版本:go 1.11.5 | ||
|
||
### 总结 | ||
|
||
1. \*v.URL = \*u | ||
2. flag 下有 `package flag_test`?? | ||
3. init 中定义相同的 stringvar ; | ||
当一个文件中出现多个 init 函数时,他们都会被加载,并且以 init 出现在文件中的前后顺序执行。 | ||
4. | ||
|
||
```golang | ||
type Value interface { | ||
String() string | ||
Set(string) error | ||
} | ||
type Getter interface { | ||
Value | ||
Get() interface{} | ||
} | ||
type boolFlag interface { | ||
Value | ||
IsBoolFlag() bool | ||
} | ||
``` | ||
|
||
5. `strconv.ParseBool` 的返回值可以被利用 | ||
|
||
```golang | ||
v, err := strconv.ParseBool(s) | ||
*b = boolValue(v) | ||
return err | ||
``` | ||
|
||
## 参考资料 | ||
|
||
1. [Go 语言中值 receiver 和指针 receiver 的对比(收集的一些资料)](https://maiyang.me/post/2018-12-12-values-receiver-vs-pointer-receiver-in-golang/) | ||
|
||
## 观看视频 | ||
|
||
{{< youtube id="z-9WEuUWqu4" >}} |