-3
A
回答
6
它在Go os軟件包源代碼註釋中進行了說明。
例如,這是安全的:
package main
import "os"
func main() {
f, err := os.Create("/tmp/atestfile")
if err != nil {
*f = os.File{}
}
// finalizer runs
}
軟件包OS
go/src/os/types.go: // File represents an open file descriptor. type File struct { *file // os specific } go/src/os/file_plan9.go: // file is the real representation of *File. // The extra level of indirection ensures that no clients of os // can overwrite this data, which could cause the finalizer // to close the wrong file descriptor. type file struct { fd int name string dirinfo *dirInfo // nil unless directory being read } go/src/os/file_unix.go: // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris // file is the real representation of *File. // The extra level of indirection ensures that no clients of os // can overwrite this data, which could cause the finalizer // to close the wrong file descriptor. type file struct { pfd poll.FD name string dirinfo *dirInfo // nil unless directory being read nonblock bool // whether we set nonblocking mode } go/src/os/file_windows.go: // file is the real representation of *File. // The extra level of indirection ensures that no clients of os // can overwrite this data, which could cause the finalizer // to close the wrong file descriptor. type file struct { pfd poll.FD name string dirinfo *dirInfo // nil unless directory being read }
相關問題
- 1. JavaScript:空數組,[]在條件結構中計算爲true。爲什麼是這樣?
- 2. 爲什麼在這個Golang結構創建中有逗號?
- 3. 這是什麼樣的數據結構?
- 4. 這是什麼樣的設計模式?
- 5. Golang的Go Routine的結構是什麼?
- 6. 爲什麼Google新聞提要有這樣奇怪的結構?
- 7. 爲什麼GUID結構是這樣聲明的?
- 8. 爲什麼我不能使用這樣的結構?
- 9. C++發生結構錯誤,爲什麼不允許這樣做?
- 10. 爲什麼元素和環結構爲golang list/ring?
- 11. 爲什麼sizeof()這個結構體8?
- 12. JDK的概念,爲什麼它是這樣的設計
- 13. 爲什麼String類是這樣設計的?
- 14. CakePHP文件夾結構 - 這是什麼使用庫文件夾?
- 15. 設計這樣
- 16. 這是什麼C#結構
- 17. 這是什麼linux結構
- 18. jQuery:這是什麼結構?
- 19. 什麼使這種結構?
- 20. 這是什麼C++結構?
- 21. 這是什麼javascript結構?
- 22. Golang地圖JSON爲結構
- 23. 爲什麼golang具有結構類型的值和指針
- 24. golang foment沒有文件結構嗎?
- 25. 請解釋一下這個結構,以及它爲什麼會這樣使用?
- 26. Express文件結構和Yeoman文件結構有什麼區別?
- 27. golang沒有這樣的設備在syscall.Mount
- 28. Golang net.ListenTCP結構
- 29. Golang - 結構
- 30. 這是什麼樣的散列文件?
@YandryPozo:這不回答這個問題。 – peterSO