package json import ( "os" "testing" "git.twelvetwelve.org/library/core/testutil/assert" ) type testIoStruct struct { Value string Count int } func TestIo(t *testing.T) { tmpFile := "io_test.tmp" v := testIoStruct{ Value: "test", Count: 999, } defer os.Remove(tmpFile) err := ReadFromFile(tmpFile, &v) assert.NotNil(t, err) err = WriteToFile(tmpFile, &v, 0644) assert.NoError(t, err) read := testIoStruct{} err = ReadFromFile(tmpFile, &read) assert.NoError(t, err) assert.Equal(t, v, read) }