Skip to content

Commit

Permalink
docs(post): reading flag
Browse files Browse the repository at this point in the history
  • Loading branch information
yangwenmai committed Feb 23, 2019
1 parent 8a25f1a commit 5c857c7
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions content/reading/31-2019-02-23-flag.md
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" >}}

0 comments on commit 5c857c7

Please sign in to comment.