Just a few weeks until the 2021 JavaScript Full-Stack Bootcamp opens.
Signup to the waiting list!

The following snippet shows how to print the content of a slice of strings into a file, separating each string with a new line.

package main

func main() {
    var text []string

    //... fill text with string values

    // writes a slice of strings to a file, one per line
    sep := "\n"
    for _, line := range text {
        if _, err = f.WriteString(line + sep); err != nil {

The 2021 JavaScript Full-Stack Bootcamp will start at the end of March 2021. Don't miss this opportunity, signup to the waiting list!

More go tutorials: