SoFunction
Updated on 2025-03-05

Golang simple reading and writing file example

package main
import (
    "fmt"
    "os"
)
func main() {
    f, err := ("", os.O_RDWR | os.O_CREATE | os.O_APPEND, 0x644)
    if err != nil {
        panic(err)
    }
    defer ()
    wint, err := ("helloworld")
    if err != nil {
        panic(err)
    }
    ("%d\n", wint)
    _, err = (0, 0)
    if err != nil {
        panic(err)
    }
    bs := make([]byte, 100)
    rint, err := (bs)
    if err != nil {
        panic(err)
    }
    ("%d, %s\n", rint, bs)
}