31 lines
408 B
Go
31 lines
408 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"encoding/csv"
|
||
|
"fmt"
|
||
|
"io"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
fmt.Println("vim-go")
|
||
|
var b bytes.Buffer
|
||
|
writer := csv.NewWriter(&b)
|
||
|
err := writer.Write([]string{
|
||
|
"foo",
|
||
|
"bar",
|
||
|
"blah",
|
||
|
})
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
writer.Flush()
|
||
|
b.WriteString("Hello World")
|
||
|
content, err := io.ReadAll(&b)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
fmt.Printf("%s\n", content)
|
||
|
fmt.Println("bye")
|
||
|
}
|