file.go
func FileGetLastLine(filenameOrURL string, timeout ...time.Duration) (line string, err error) {
	if strings.Index(filenameOrURL, "file://") == 0 {
		return FileGetLastLine(filenameOrURL[len("file://"):])
	}

	var data []byte

	if strings.Contains(filenameOrURL, "://") {
		data, err = FileGetBytes(filenameOrURL, timeout...)
		if err != nil {
			return "", err
		}
	} else {
		file, err := os.Open(filenameOrURL)
		if err != nil {
			return "", err
		}
		defer file.Close()
		info, err := file.Stat()
		if err != nil {
			return "", err
		}
		if start := info.Size() - 64*1024; start > 0 {
			file.Seek(start, os.SEEK_SET)
		}
		data, err = ioutil.ReadAll(file)
		if err != nil {
			return "", err
		}
	}

	pos := bytes.LastIndex(data, []byte{'\n'})
	return string(data[pos+1:]), nil
}
func FileGetLastLine(filenameOrURL string, timeout ...time.Duration) (line string, err error) {
	if strings.Index(filenameOrURL, "file://") == 0 {
		return FileGetLastLine(filenameOrURL[len("file://"):])
	}

	var data []byte

	if strings.Contains(filenameOrURL, "://") {
		data, err = FileGetBytes(filenameOrURL, timeout...)
		if err != nil {
			return "", err
		}
	} else {
		file, err := os.Open(filenameOrURL)
		if err != nil {
			return "", err
		}
		defer file.Close()
		info, err := file.Stat()
		if err != nil {
			return "", err
		}
		if start := info.Size() - 64*1024; start > 0 {
			file.Seek(start, os.SEEK_SET)
		}
		data, err = ioutil.ReadAll(file)
		if err != nil {
			return "", err
		}
	}

	pos := bytes.LastIndex(data, []byte{'\n'})
	return string(data[pos+1:]), nil
}
// FileGetLastLine reads the last line from a file.
// In case of a network file, the whole file is read.
// In case of a local file, the last 64kb are read,
// so if the last line is longer than 64kb it is not returned completely.
// The first optional timeout is used for network files only.