예제 #1
0
// WriteString is like Write, but writes the contents of string s rather than
// an array of bytes.
func (file *File) WriteString(s string) (ret int, err Error) {
	if file == nil {
		return 0, EINVAL
	}
	b := syscall.StringByteSlice(s)
	b = b[0 : len(b)-1]
	return file.Write(b)
}
예제 #2
0
// Setenv sets the value of the environment variable named by the key.
// It returns an Error, if any.
func Setenv(key, value string) Error {
	if len(key) == 0 {
		return EINVAL
	}

	f, e := Create("/env/" + key)
	if iserror(e) {
		return e
	}
	defer f.Close()

	_, e = f.Write(syscall.StringByteSlice(value))
	return nil
}
예제 #3
0
func (s *stringIO) WriteString(str string) (ret int, err error) {
	b := syscall.StringByteSlice(str)
	return s.Write(b[0 : len(b)-1])
}