5-1 file read and write - to open the file

main Package 


/ * 
in a simple manner to open a file, close after one second 
opening in a read-only file, create a buffer zone from the reader, read row by row to the end. 
Ioutil stack package using simple file read 
* / 
Import ( 
    " FMT " 
    " OS " 
    " Time " 
) 

FUNC main () { 

    File, E: = os.Open ( " C: / the Users / Administrator / Desktop / Eth token address .txt " )
     IF E == nil { 
        fmt.Println ( " file open success " ) 
    } the else { 
        fmt.Println ( " file open failure, ERR = " ,
        
        return 
    } 
    the defer FUNC () { 
        File.close () 
        fmt.Println ( " file close Success " ) 
    } () 

    time.sleep ( . 1 * time.Second) 
    fmt.Println ( " file operation " , File) 
}

 

Guess you like

Origin www.cnblogs.com/paad/p/11099295.html