This answers works in Go1:
f, err := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
panic(err)
}
defer f.Close()
if _, err = f.WriteString(text); err != nil {
panic(err)
}
More Related Contents:
- What’s the de-facto way of reading and writing files in Rust 1.x?
- Write lines of text to a file in R
- Ant: How to execute a command for each file in directory?
- Reading comment lines correctly in an input file using Fortran 90
- Write extracted data to a file using jmeter
- File I/O in a Linux kernel module
- Check if a file exists with Lua
- Why does a read-only open of a named pipe block?
- Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on
- How to idiomatically log auth information with middleware
- Read/write files within a Linux kernel module
- How to write a UTF-8 file with Java?
- My structures are not marshalling into json [duplicate]
- Reading a file used by another process [duplicate]
- Elegant ways to count the frequency of words in a file
- Iterate through the fields of a struct in Go
- How to delete a file via PHP?
- is it possible to call overridden method from parent struct in Golang?
- jQuery: get the file name selected from
- How to match a regex with backreference in Go?
- How to read a file into vector in C++?
- []byte(string) vs []byte(*string)
- Cannot delete file used by some other process
- How can I read a whole file into a string variable
- Why does golang compiler think the variable is declared but not used?
- Golang templates (and passing funcs to template)
- Convert unicode code point to literal character in Go
- Why can’t I append to a slice that’s the property of a struct in golang?
- How to know TCP connection is closed in net package?
- Slice chunking in Go