file

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseFile added in v0.13.0

func CloseFile(f *os.File)

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

func Exists(filename string) (exists bool)

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 GetContents(filename string) string

func Initialize

func Initialize(
	errorHandler func(err error),
	traceHandler func(format string, a ...any))

func OpenFile added in v0.13.0

func OpenFile(filename string) *os.File

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

func WriteString(f *os.File, s string)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL