补充内容.
Signed-off-by: rick.chan <chen.yang@yuzhen-iot.com>
This commit is contained in:
parent
fb37ee794a
commit
0bc1c9a8bb
|
@ -11,12 +11,20 @@ go env -w GO111MODULE=on
|
||||||
go env -w GOPROXY=https://goproxy.cn
|
go env -w GOPROXY=https://goproxy.cn
|
||||||
```
|
```
|
||||||
|
|
||||||
## 2.安装 Packages
|
## 2.下载和安装 Packages
|
||||||
|
|
||||||
以安装 guru 为例:
|
通常,开发过程中所需要的 Package 只需要通过 go get 命令下载就可以使用,以 uuid 包为例,下载指定版本的 uuid 包命令如下:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
go get golang.org/x/tools/cmd/guru
|
# 下载 Go Package
|
||||||
go build golang.org/x/tools/cmd/guru
|
go get github.com/satori/go.uuid@v1.2.0
|
||||||
mv guru $(go env GOROOT)/bin
|
```
|
||||||
|
|
||||||
|
有些 go 工具除了下载外还需要编译安装,以 gopls 工具为例,下载、编译和安装命令如下:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 下载 gopls
|
||||||
|
go get -v golang.org/x/tools/gopls
|
||||||
|
# 编译并安装
|
||||||
|
go install golang.org/x/tools/gopls
|
||||||
```
|
```
|
||||||
|
|
|
@ -31,7 +31,7 @@ func Open(name string) (*File, error)
|
||||||
func OpenFile(name string, flag int, perm FileMode) (*File, error)
|
func OpenFile(name string, flag int, perm FileMode) (*File, error)
|
||||||
```
|
```
|
||||||
|
|
||||||
perm 模式如下:
|
flag 如下:
|
||||||
|
|
||||||
```go
|
```go
|
||||||
//打开方式
|
//打开方式
|
||||||
|
@ -55,6 +55,47 @@ O_TRUNC int = syscall.O_TRUNC // if possible, truncate file when opened.
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
perm 模式如下:
|
||||||
|
|
||||||
|
```go
|
||||||
|
const (
|
||||||
|
// The single letters are the abbreviations
|
||||||
|
// used by the String method's formatting.
|
||||||
|
// 文件夹模式
|
||||||
|
ModeDir FileMode = 1 << (32 - 1 - iota) // d: is a directory
|
||||||
|
// 追加模式
|
||||||
|
ModeAppend // a: append-only
|
||||||
|
// 单独使用
|
||||||
|
ModeExclusive // l: exclusive use
|
||||||
|
// 临时文件
|
||||||
|
ModeTemporary // T: temporary file; Plan 9 only
|
||||||
|
// 象征性的关联
|
||||||
|
ModeSymlink // L: symbolic link
|
||||||
|
// 设备文件
|
||||||
|
ModeDevice // D: device file
|
||||||
|
// 命名管道
|
||||||
|
ModeNamedPipe // p: named pipe (FIFO)
|
||||||
|
// Unix 主机 socket
|
||||||
|
ModeSocket // S: Unix domain socket
|
||||||
|
// 设置uid
|
||||||
|
ModeSetuid // u: setuid
|
||||||
|
// 设置gid
|
||||||
|
ModeSetgid // g: setgid
|
||||||
|
// UNIX 字符串设备,当设备模式是设置unix
|
||||||
|
ModeCharDevice // c: Unix character device, when ModeDevice is set
|
||||||
|
// 粘性的
|
||||||
|
ModeSticky // t: sticky
|
||||||
|
// 非常规文件;对该文件一无所知
|
||||||
|
ModeIrregular // ?: non-regular file; nothing else is known about this file
|
||||||
|
|
||||||
|
// bit位遮盖,不变的文件设置为none
|
||||||
|
// Mask for the type bits. For regular files, none will be set.
|
||||||
|
ModeType = ModeDir | ModeSymlink | ModeNamedPipe | ModeSocket | ModeDevice | ModeCharDevice | ModeIrregular
|
||||||
|
// 权限位
|
||||||
|
ModePerm FileMode = 0777 // Unix permission bits
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
### 1.3.获取文件状态
|
### 1.3.获取文件状态
|
||||||
|
|
||||||
```go
|
```go
|
||||||
|
|
Loading…
Reference in New Issue