我需要像这样的输出
0 - os.O_APPEND - 1024
1 - os.O_CREATE - 64
2 - os.O_EXCL - 128
3 - os.O_RDONLY - 0
4 - os.O_RDWR - 2
5 - os.O_SYNC - 1052672
6 - os.O_TRUNC - 512
7 - os.O_WRONLY - 1
我能做到一半
func main() {
a := []int{os.O_APPEND,os.O_CREATE,os.O_EXCL,os.O_RDONLY,os.O_RDWR,os.O_SYNC,os.O_TRUNC,os.O_WRONLY}
for index, value := range a {
fmt.Printf("%d - - %d\n", index, value)
}
}
这给了我输出
0 - - 1024
1 - - 64
2 - - 128
3 - - 0
4 - - 2
5 - - 1052672
6 - - 512
7 - - 1
和它的另一半
func main() {
a := []string{"os.O_APPEND","os.O_CREATE","os.O_EXCL","os.O_RDONLY","os.O_RDWR","os.O_SYNC","os.O_TRUNC","os.O_WRONLY"}
for index, value := range a {
fmt.Printf("%d - %-15s -\n", index, value)
}
}
这给了我输出
0 - os.O_APPEND -
1 - os.O_CREATE -
2 - os.O_EXCL -
3 - os.O_RDONLY -
4 - os.O_RDWR -
5 - os.O_SYNC -
6 - os.O_TRUNC -
7 - os.O_WRONLY -
我怎样才能得到想要的输出?
繁星点点滴滴
相关分类