Golang ProgramsGolang Programs

Create an empty file

package main
 
import (
	"log"
	"os"
)
 
func main() {
	emptyFile, err := os.Create("empty.txt")
	if err != nil {
		log.Fatal(err)
	}
	log.Println(emptyFile)
	emptyFile.Close()
}
C:\golang\working-with-files>go fmt example1.go

C:\golang\working-with-files>golint example1.go

C:\golang\working-with-files>go run example1.go
2018/08/11 15:46:04 &{0xc042060780}

C:\golang\working-with-files>