8784: Fix test for latest firefox.
[arvados.git] / sdk / go / config / dump.go
1 package config
2
3 import (
4         "errors"
5         "os"
6
7         "github.com/ghodss/yaml"
8 )
9
10 // DumpAndExit writes the given config to stdout as YAML. If an error
11 // occurs, that error is returned. Otherwise, the program exits 0.
12 //
13 // Example:
14 //
15 //      log.Fatal(DumpAndExit(cfg))
16 func DumpAndExit(cfg interface{}) error {
17         y, err := yaml.Marshal(cfg)
18         if err != nil {
19                 return err
20         }
21         _, err = os.Stdout.Write(y)
22         if err != nil {
23                 return err
24         }
25         os.Exit(0)
26         return errors.New("exit failed!?")
27 }