In Go, you can use the Stat() function from the os package to get file information, including file size.

os.Stat() returns a FileInfo object that describes the specified file, which provides the Size() method to get the file size.

Getting File Size

Example for getting file size:

package main

import (
	"os"
)

func getFileSize(filename string)(int64,error){
	fi,err := os.Stat(filename)
	if err != nil{
		return 0,err
	}
	return fi.Size(),nil
}

func main(){
	filesize,_ := getFileSize("example.dat")
	print(filesize)
}