Пример #1
0
func (h *HTTPSession) RecF(name, tfile string) (int64, error) {
	src, _, err := h.R.FormFile(name)
	if err != nil {
		return 0, err
	}
	err = util.FTouch(tfile)
	if err != nil {
		return 0, err
	}
	dst, _ := os.OpenFile(tfile, os.O_RDWR|os.O_APPEND, 0644)
	csize, err := io.Copy(dst, src)
	dst.Close()
	return csize, err
}
Пример #2
0
func main() {
	//create and open log file
	util.FTouch("/tmp/tt.tmp")
	f, err := os.OpenFile("/tmp/tt.tmp", os.O_RDWR|os.O_APPEND, 0666)
	if err != nil {
		panic(err.Error())
		return
	}
	//create file buffer writer.
	bo := bufio.NewWriter(f)
	defer f.Close()
	defer bo.Flush()
	//set the log writer to file and stdout.
	//or log.SetWriter(bo) to only file.
	log.SetWriter(io.MultiWriter(bo, os.Stdout))
	//set the log level
	log.SetLevel(log.DEBUG)
	//use
	log.I("tesing")
	log.D("tesing")
}