package main import ( "fmt" "io/ioutil" "os" ) // read a file and returns its content func readFile(filename string) ([]byte, error) { content, err := ioutil.ReadFile(filename) if err != nil { return nil, err } return content, nil } // creates a file and writes given data to it func writeFile(filename string, data []byte) error { file, err := os.Create(filename) if err != nil { return err } defer file.Close() _, err = file.Write(data) return err } func main() { filename := "example.txt" data := []byte("Hello, World!") err := writeFile(filename, data) if err != nil { panic(err) } fmt.Println("File created and data written successfully!") content, err := readFile(filename) if err != nil { panic(err) } fmt.Printf("File content: %s", content) }In this example, we create a file named `example.txt` and write the bytes "Hello, World!" to it using the `os.Create` and `file.Write` functions. We also read the file content using the `ioutil.ReadFile` function. The `os` package is used in this example to interact with the file system.