package main import ( "fmt" "os" ) func main() { file, err := os.Create("test.txt") if err != nil { fmt.Println("Error creating file:", err) return } defer file.Close() data := []byte("Hello, world!") n, err := file.Write(data) if err != nil { fmt.Println("Error writing to file:", err) return } fmt.Printf("Wrote %d bytes to file\n", n) }In this example, we create a file called "test.txt" and write the text "Hello, world!" to it using the Write() method of the file object. Finally, we close the file using the Close() method. The WriteCloser interface is part of the io package library in Go.