mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-18 11:33:59 +00:00
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
This commit is contained in:
@@ -111,6 +111,16 @@ func (f *File) Write(b []byte) (n int, err error) {
|
|||||||
return
|
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.
|
// Close closes the File, rendering it unusable for I/O.
|
||||||
func (f *File) Close() (err error) {
|
func (f *File) Close() (err error) {
|
||||||
err = f.handle.Close()
|
err = f.handle.Close()
|
||||||
|
|||||||
Reference in New Issue
Block a user