Go中的条件变量与Channel
在Go语言中 sync.Cond
代表条件变量,初始化的时候需要传入一个互斥体,它可以是普通锁(Mutex),也可以是读写锁(RWMutex)。如下:
1 | var mutex sync.Mutex // 也可以是 sync.RWMutex |
在Go语言中 sync.Cond
代表条件变量,初始化的时候需要传入一个互斥体,它可以是普通锁(Mutex),也可以是读写锁(RWMutex)。如下:
1 | var mutex sync.Mutex // 也可以是 sync.RWMutex |
https://www.zhihu.com/api/v4/questions/{qid}/answers
is_normal,is_sticky,collapsed_by,suggest_edit,comment_count,collapsed_counts,reviewing_comments_count,can_comment,content,editable_content,voteup_count,reshipment_settings,comment_permission,mark_infos,created_time,updated_time,relationship.is_author,voting,is_thanked,is_nothelp,upvoted_followees;author.is_blocking,is_blocked,is_followed,voteup_count,message_thread_token,badge[?(type=best_answerer)].topics
当Git服务器的SSH端口不是默认22时,可以修改~/.ssh/config
来连接
1 | Host github.com |
1 | sed -i 's/hello/world/g' hello.php |
上面这行代码,可以在 linux 上运行,作用是将找到的 hello 替换为 world,并且直接保存修改到文件。但是如果在 Mac 上,你会发现这行代码会报错。原因是在 Mac 上,sed 命令直接操作文件的时候,必须指定备份的格式,而在 linux 上,却并没有这个要求。
1 | sed -i '' 's/hello/world/g' hello.php |
如上面的代码所示,在 -i 之后加上一对引号,来指定备份格式,如果不需要备份,引号里的内容可以为空。
比如有这样的一个目录结构
1 | --protobuf |
怎样在storyboard.proto
中引入main.proto
?
使用Go解析一个从其他接口返回的JSON字符串,有时会遇到数字以科学计数法的形式展现,比如
源:
1 | {"message": "success", "data": 6566651968} |
处理后:
1 | {"message": "success", "data": 6.566651968e+09} |