Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pluralsh/polly
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.1.3
Choose a base ref
...
head repository: pluralsh/polly
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.1.4
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Sep 25, 2023

  1. add tempfile utility

    michaeljguarino committed Sep 25, 2023
    Copy the full SHA
    c914ce3 View commit details
Showing with 14 additions and 0 deletions.
  1. +14 −0 fs/file.go
14 changes: 14 additions & 0 deletions fs/file.go
Original file line number Diff line number Diff line change
@@ -8,3 +8,17 @@ func Exists(path string) bool {
_, err := os.Stat(path)
return !os.IsNotExist(err)
}

func TmpFile(name string, contents []byte) (string, error) {
f, err := os.CreateTemp("", name)
if err != nil {
return "", err
}
defer f.Close()

if _, err := f.Write(contents); err != nil {
return "", err
}

return f.Name(), nil
}