Reading data just written to a temp file

前端 未结 2 1834
广开言路
广开言路 2021-01-29 10:13

In Go, I am trying to write data to a temp file that I then turn around and read but have not been successful. Below is a stripped down test program. I have verified that the

2条回答
  •  被撕碎了的回忆
    2021-01-29 10:55

    package main
    
    import (
        "fmt"
        "io/ioutil"
        "log"
    )
    
    func main() {
        content, err := ioutil.ReadFile("testdata/hello")
        if err != nil {
            log.Fatal(err)
        }
    
        fmt.Printf("File contents: %s", content)
    

    according to the official golang docs.

提交回复
热议问题