0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

golang 基本语法

Posted at

打包工具

import

import (
    "database/sql"
    _ "github.com/lib/pq" // 只引入, 不运行 init 函数
)

Printf

%d        十进制
%x %o %b  十六进制 八进制 二进制
%f %g %e  浮点数
%t        布尔类型
%c        字符(unicode码点)
%s        字符串
%q        带引号的字符
%v        内置格式的任何类型
%T        任何值的类型( 代替 reflect.TypeOf(x) )
%%        %本身(转义符)
fmt.Printf("|%-6s|%-6s|\n", "foo", "b")
s := fmt.Sprintf("a %s", "string")
fmt.Println(s)
// Printf通过 os.Stdout输出格式化的字符串,Sprintf格式化并返回一个字符串而不带任何输出

fmt.Fprintf(os.Stderr, "an %s\n", "error")
//使用 Fprintf 来格式化并输出到 io.Writers而不是 os.Stdout

Reflect

https://my.oschina.net/solate/blog/715681
http://www.cnblogs.com/coder2012/p/4881854.html


golang context

https://yq.aliyun.com/articles/69662
https://deepzz.com/post/golang-context-package-notes.html


golang 交叉编译


golang 原子操作

原子操作

atomic.CompareAndSwapInt32 //简称CAS

atomic.LoadInt32

atomic.AddUint32

atomic.StoreInt32

atomic.SwapInt32

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?