diff --git a/README.md b/README.md index 00a72870..69a0bb93 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ import ( "fmt" "io/ioutil" "os" + "log" "github.com/hashicorp/terraform-exec/tfexec" "github.com/hashicorp/terraform-exec/tfinstall" @@ -36,29 +37,29 @@ import ( func main() { tmpDir, err := ioutil.TempDir("", "tfinstall") if err != nil { - panic(err) + log.Fatalf("error creating temp dir: %s", err) } defer os.RemoveAll(tmpDir) execPath, err := tfinstall.Find(context.Background(), tfinstall.LatestVersion(tmpDir, false)) if err != nil { - panic(err) + log.Fatalf("error locating Terraform binary: %s", err) } workingDir := "/path/to/working/dir" tf, err := tfexec.NewTerraform(workingDir, execPath) if err != nil { - panic(err) + log.Fatalf("error running NewTerraform: %s", err) } err = tf.Init(context.Background(), tfexec.Upgrade(true)) if err != nil { - panic(err) + log.Fatalf("error running Init: %s", err) } state, err := tf.Show(context.Background()) if err != nil { - panic(err) + log.Fatalf("error running Show: %s", err) } fmt.Println(state.FormatVersion) // "0.1"