Essential Go gob  Suggest an edit

How to encode data and write to file with gob?

package main

import (
    "encoding/gob"
    "os"
)

type User struct {
    Name string
    Password string
}

func main() {

    user := User{
        Name: "Angus",
        Password: "1234",
    }

    file, _ := os.Create("user.gob")

    defer file.Close()

    encoder := gob.NewEncoder(file)

    encoder.Encode(user)

}
  ↑ ↓ to navigate     ↵ to select     Esc to close