Documentation
¶
Index ¶
- func CloseFile(f *os.File)
- func CreateEmptyIfNotExists(filename string)
- func Exists(filename string) (exists bool)
- func GetContents(filename string) string
- func Initialize(errorHandler func(err error), traceHandler func(format string, a ...any))
- func OpenFile(filename string) *os.File
- func Remove(filename string)
- func WriteString(f *os.File, s string)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateEmptyIfNotExists ¶
func CreateEmptyIfNotExists(filename string)
CreateEmptyIfNotExists creates an empty file with the given filename if it does not already exist. If the parent directory of the file does not exist, the function will create it. The function is useful for ensuring that a file is present before writing to it.
Example ¶
package main import ( "github.com/microsoft/go-sqlcmd/internal/io/file" "os" "path/filepath" ) func main() { filename := filepath.Join(os.TempDir(), "foo.txt") file.CreateEmptyIfNotExists(filename) }
Output:
func Exists ¶
Exists checks if a file with the given filename exists in the file system. It returns a boolean value indicating whether the file exists or not.
func GetContents ¶ added in v0.13.0
func Initialize ¶
func Remove ¶
func Remove(filename string)
Remove is used to remove a file with the specified filename. The function takes in the name of the file as an argument and deletes it from the file system.
func WriteString ¶ added in v0.13.0
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.