github.com/verrazzano/verrazzano@v1.7.0/authproxy/internal/testutil/file/file.go (about) 1 // Copyright (c) 2023, Oracle and/or its affiliates. 2 // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. 3 4 package file 5 6 import "os" 7 8 // MakeTempFile creates a temporary file and writes the specified contents 9 func MakeTempFile(content string) (*os.File, error) { 10 tmpFile, err := os.CreateTemp("", "") 11 if err != nil { 12 return nil, err 13 } 14 defer tmpFile.Close() 15 16 _, err = tmpFile.Write([]byte(content)) 17 return tmpFile, err 18 }