download download modules to local cache edit edit go.mod from tools or scripts graph print module requirement graph init initialize new module in current directory tidy add missing and remove unused modules vendor make vendored copy of dependencies verify verify dependencies have expected content why explain why packages or modules are needed
结论
Go Module 是 Go 依赖管理的未来。 目前只有 1.11 和 1.12 版本支持该功能,介绍了 Go 依赖管理的功能。更多的功能会在以后补充。也欢迎补充完善。最后如果你是使用 Goland, 请移步这里Working with Go Modules
阅读关于使用 Modules 开发
模拟一下实际的情况,假设 v 变量的地址在 0x12345678 上, for 循环在迭代过程中,所有变量值都是在这地址上迭代的。当最后调用匿名函数的时候,取值也是在这块地址上。所以最后输出的结果都是迭代的最后一个值。至少在 Go 语言中是不用质疑的。这里也是一个陷阱,如果你不清楚的话,肯定会遇到坑。那个该如何修改呢?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
var slice []func()
funcmain() { sli := []int{1, 2, 3, 4, 5} for _, v := range sli { temp := v // 其实很简单 引入一个临时局部变量就可以了,这样就可以将每次的值存储到该变量地址上 fmt.Println(&temp) // 这里内存地址是不同的 slice = append(slice, func(){ fmt.Println(temp * temp) // 直接打印结果 }) } for _, val := range slice { val() } } // 输出 1, 4, 9, 16, 25 预期结果
模拟一下实际的情况,假设 v 变量的地址在 0x12345678 上, for 循环在迭代过程中,所有变量值都是在这地址上迭代的。当最后调用匿名函数的时候,取值也是在这块地址上。所以最后输出的结果都是迭代的最后一个值。至少在 Go 语言中是不用质疑的。这里也是一个陷阱,如果你不清楚的话,肯定会遇到坑。那个该如何修改呢?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
var slice []func()
func main() { sli := []int{1, 2, 3, 4, 5} for _, v := range sli { temp := v // 其实很简单 引入一个临时局部变量就可以了,这样就可以将每次的值存储到该变量地址上 fmt.Println(&temp) // 这里内存地址是不同的 slice = append(slice, func(){ fmt.Println(temp * temp) // 直接打印结果 }) } for _, val := range slice { val() } } // 输出 1, 4, 9, 16, 25 预期结果
由于最近使用 vps 连续被封禁,不知是否是因为切换到 SSR 的缘故?我从网络上看到很多关于 SSR 被封禁的情况,好像是由于墙不需要去特意破解什么加密,而是根据 SSR 某些特征可以大概率查封。对于我而言,我还是信服这种说法,因为在我切换到 SSR 之后不到三天我的两台服务器连续被封禁了,这让我不知所措。因为在这之前没去好好了解实际情况,我面对这种情况真的显得很无奈,好好地两台 VPS 居然都被封了,只好忍痛又买了一台。
发现 V2ray
在论坛上看到很多人也遇到过这种情况,很多都推荐使用 V2ray,新的协议,伪装程度高,各种优点。而且现在 SS 和 SSR 停止更新了,从 V2ray github 上来看,更新很频繁,而且功能也在不停地增加。 对于这个时候的我,其实已经不在乎速度了,更加在乎的是安全和长久,因为我只是用来查查资料,基本很少看视频,对于速度要求不高。当然现在已经搭建的这台代理速度还是可以的,油管的 1080 很流畅。而且好几个人在用。
/** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'email', ];
/** * The attributes excluded from the model's JSON form. * * @var array */ protected $hidden = [ 'password', ];
/** * Get the identifier that will be stored in the subject claim of the JWT. * * @return mixed */ publicfunctiongetJWTIdentifier() { return$this->getKey(); }
/** * Return a key value array, containing any custom claims to be added to the JWT. * * @return array */ publicfunctiongetJWTCustomClaims() { return []; } }