GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - leonklingele/securetemp: Secure temporary directories and files in Go (ram disk, tmpfs)

BranchesTags
Open more actions menu

Latest commit

 

History

34 Commits
34 Commits

Folders and files

NameName
Last commit message
Last commit date
cmd/securetemp
cmd/securetemp
 
 
vendor/golang.org/x/sys
vendor/golang.org/x/sys
 
 
.travis.yml
.travis.yml
 
 
Gopkg.lock
Gopkg.lock
 
 
Gopkg.toml
Gopkg.toml
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
securetemp.go
securetemp.go
 
 
securetemp_darwin.go
securetemp_darwin.go
 
 
securetemp_test.go
securetemp_test.go
 
 
securetemp_unix.go
securetemp_unix.go
 
 
securetemp_windows.go
securetemp_windows.go
 
 

Repository files navigation

Secure temporary directories and files in Go

Build Status

This CLI app and library can be used to create temporary directories and files inside RAM. This is useful if you temporarily need a file to store sensitive data in.

tl;dr

# Install library
go get -u github.com/leonklingele/securetemp

# Install library + CLI app ("securetemp")
go get -u github.com/leonklingele/securetemp/...
securetemp -h
// Create a temporary file inside a RAM disk which is securetemp.DefaultSize big
tmpFile, cleanupFunc, err := securetemp.TempFile(securetemp.DefaultSize)
if err != nil {
	// TODO: Properly handle error
	log.Fatal(err)
}
// `tmpFile` is an *os.File
if _, err := tmpFile.WriteString("Hello, World!"); err != nil {
	// TODO: Properly handle error
	log.Fatal(err)
}
// Call the cleanup func as soon as you no longer need the file.
// The file is deleted and the RAM is freed again.
// The cleanup function also calls `tmpFile.Close()` for you.
cleanupFunc()
// Create a temporary directory inside a RAM disk which is 20MB big
tmpDir, cleanupFunc, err := securetemp.TempDir(20 * securetemp.SizeMB)
if err != nil {
	// TODO: Properly handle error
	log.Fatal(err)
}
// Create one / multiple file/s inside `tmpDir`
file, err := os.Create(path.Join(tmpDir, "myfile.txt"))
if err != nil {
	// TODO: Properly handle error
	log.Fatal(err)
}
defer file.Close()
// Do something with `file`
if _, err := file.WriteString("Hello, World!"); err != nil {
	// TODO: Properly handle error
	log.Fatal(err)
}
file.Close()
// Call the cleanup func as soon as you no longer need the directory.
// The directory is deleted and the RAM is freed again.
// Make sure to close every file inside `tmpDir` before.
cleanupFunc()

Idea

This project was inspired by pass

About

Secure temporary directories and files in Go (ram disk, tmpfs)

Topics

ramdisksecuritytemporary-directoriestemporary-filestmpfiletmpfs

Resources

Readme
AGPL-3.0 license
Activity

Stars

13 stars

Watchers

2 watching

Forks

2 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.