예제 #1
0
파일: fs.go 프로젝트: majestrate/nntpchan
// get a temporary file we can use for read/write that deletes itself on close
func (fs FilesystemStorage) obtainTempFile() (f *os.File, err error) {
	fname := fmt.Sprintf("tempfile-%x-%d", crypto.RandBytes(4), time.Now().Unix())
	log.WithFields(log.Fields{
		"pkg":      "fs-store",
		"filepath": fname,
	}).Debug("opening temp file")
	f, err = os.OpenFile(filepath.Join(fs.TempDir(), fname), os.O_RDWR|os.O_CREATE, 0400)
	return
}
예제 #2
0
// generate a new message id given name of server
func GenMessageID(name string) MessageID {
	r := crypto.RandBytes(4)
	t := time.Now()
	return MessageID(fmt.Sprintf("<%x$%d@%s>", r, t.Unix(), name))
}