os: add File.WriteString and File.WriteAt
WriteString just does the simple and and converts the passed string to a byte-slice. This can be made zero-copy later with unsafe, if needed. WriteAt returns ErrNotImplemented, to match Seek() and ReadAt(). Fixes #2157
Этот коммит содержится в:
родитель
6c9bb96bca
коммит
13891d428f
1 изменённых файлов: 10 добавлений и 0 удалений
|
@ -111,6 +111,16 @@ func (f *File) Write(b []byte) (n int, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
// WriteString is like Write, but writes the contents of string s rather than a
|
||||
// slice of bytes.
|
||||
func (f *File) WriteString(s string) (n int, err error) {
|
||||
return f.Write([]byte(s))
|
||||
}
|
||||
|
||||
func (f *File) WriteAt(b []byte, off int64) (n int, err error) {
|
||||
return 0, ErrNotImplemented
|
||||
}
|
||||
|
||||
// Close closes the File, rendering it unusable for I/O.
|
||||
func (f *File) Close() (err error) {
|
||||
err = f.handle.Close()
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче