Skip to content
/ osfs Public
forked from absfs/osfs

osfs is an implementation of a absfs.FileSystem for the os standard library file access functions

License

Notifications You must be signed in to change notification settings

LittleKey/osfs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

osfs - Abstract File System interface

osfs package implements the absfs.FileSystem interface using the os standard library file access functions.

Install

$ go get github.com/absfs/osfs

Example Usage

package main

import (
	"log"
	"os"

	"github.com/absfs/osfs"
)

func ExitOnError(err error) {
	if err != nil {
		log.Fatal(err)
	}
}

func main() {
	fs, err := osfs.NewFS()
	ExitOnError(err)

	f, err := fs.Create("example.txt")
	ExitOnError(err)

	_, err = f.Write([]byte("Hello, world!\n"))
	ExitOnError(err)

	err = f.Close()
	ExitOnError(err)

	// if "keep" is passed as the first argument, don't delete the file
	if len(os.Args) > 1 && os.Args[1] == "keep" {
		return
	}

	// delete the file
	err = fs.Remove("example.txt")
	ExitOnError(err)
}

absfs

Check out the absfs repo for more information about the abstract filesystem interface and features like filesystem composition

LICENSE

This project is governed by the MIT License. See LICENSE

About

osfs is an implementation of a absfs.FileSystem for the os standard library file access functions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%