MCPcopy
hub / github.com/cloudfoundry/cli / TempFileWithContent

Function TempFileWithContent

integration/helpers/file.go:19–29  ·  view source on GitHub ↗

TempFileWithContent writes a temp file with given content and return the file name.

(contents string)

Source from the content-addressed store, hash-verified

17// TempFileWithContent writes a temp file with given content and return the
18// file name.
19func TempFileWithContent(contents string) string {
20 tempFile, err := os.CreateTemp("", "*")
21 Expect(err).NotTo(HaveOccurred())
22 defer tempFile.Close()
23
24 bytes := []byte(contents)
25 _, err = tempFile.Write(bytes)
26 Expect(err).NotTo(HaveOccurred())
27
28 return tempFile.Name()
29}
30
31// TempDirAbsolutePath wraps `os.MkdirTemp`, ensuring symlinks are expanded
32// before returning the path

Calls 3

WriteMethod · 0.80
NameMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected