| // Copyright 2015 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| r := strings.NewReader("Go is a general-purpose language designed with systems programming in mind.") |
| b, err := ioutil.ReadAll(r) |
| // Go is a general-purpose language designed with systems programming in mind. |
| files, err := ioutil.ReadDir(".") |
| for _, file := range files { |
| content := []byte("temporary file's content") |
| dir, err := ioutil.TempDir("", "example") |
| defer os.RemoveAll(dir) // clean up |
| tmpfn := filepath.Join(dir, "tmpfile") |
| if err := ioutil.WriteFile(tmpfn, content, 0666); err != nil { |
| content := []byte("temporary file's content") |
| tmpfile, err := ioutil.TempFile("", "example") |
| defer os.Remove(tmpfile.Name()) // clean up |
| if _, err := tmpfile.Write(content); err != nil { |
| if err := tmpfile.Close(); err != nil { |