예제 #1
0
파일: history.go 프로젝트: pkdevboxy/query
func ReadHistoryFromFile(liner *liner.State, path string) (int, string) {

	var err error
	f, err := os.Open(path)
	if err != nil {
		if os.IsNotExist(err) {
			f, err = os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
			if err != nil {
				return errors.FILE_OPEN, err.Error()
			}

		} else {
			return errors.FILE_OPEN, err.Error()
		}
	}

	defer f.Close()

	reader := bufio.NewReader(f)
	_, err = liner.ReadHistory(reader)
	if err != nil {
		return errors.READ_FILE, err.Error()
	}
	return 0, ""
}
예제 #2
0
func ReadHistoryFromFile(liner *liner.State, path string) {

	f, err := os.Open(path)
	if err != nil {
		return
	}

	defer f.Close()

	reader := bufio.NewReader(f)
	liner.ReadHistory(reader)
}
예제 #3
0
func ReadHistoryFromFile(liner *liner.State, path string) (int, string) {

	var err error
	f, err := os.Open(path)
	if err != nil {
		return errors.FILE_OPEN, err.Error()
	}

	defer f.Close()

	reader := bufio.NewReader(f)
	_, err = liner.ReadHistory(reader)
	if err != nil {
		return errors.READ_FILE, err.Error()
	}
	return 0, ""
}