Files
moxa/_test/file_access.go
Marc Vertes 378252166b fix: correct assign from function call (#155)
The following changes should fix real and potential  problems
regarding how variables are set from function return values.

In assign from call expressions, Values in caller frame are now
directly assigned from function calls (call(), binCall() or builtins).
The assignement is performed with reflect Set methods or variants,
instead of "=" operator, to enforce runtime type checks.

The assignX() and assignX2() builtins are now removed in favor of
above method.

The representation of nil for pointer on struct has been fixed.

The identification of channel is fixed in for-range channel expression.
2019-04-16 15:22:17 +02:00

41 lines
511 B
Go

package main
import (
"fmt"
"io/ioutil"
"os"
)
func main() {
file, err := ioutil.TempFile("", "yeagibench")
if err != nil {
panic(err)
}
n, err := file.Write([]byte("hello world"))
if err != nil {
panic(err)
}
fmt.Println("n:", n)
err = file.Close()
if err != nil {
panic(err)
}
b, err := ioutil.ReadFile(file.Name())
if err != nil {
panic(err)
}
fmt.Println("b:", string(b))
err = os.Remove(file.Name())
if err != nil {
panic(err)
}
}
// Output:
// n: 11
// b: hello world