Simple examples to show golang file actions
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.md
all-examples.go
change-directory-chdir.go
chmod-change-file-permissions.go
create-directory.go
delete-file-directory.go
learn-file-directory-type.go
learn-file-permissions.go
learn-temp-directory.go
list-directory.go
open-file-and-print-content.go
open-file.go
read.txt
rename-file-directory.go
write-file.go
write.txt

README.md

Simple golang file which contains examples about file actions in golang. To keep it simple I only used golang's built-in "os" package.


How to test:

  • Rename any file you want to use as "main.go"
  • Type command "go run main.go"

The main.go file contains these file actions:

  • Open file for READ, WRITE, CREATE and APPEND
  • Learn GID and UID of the user
  • Change user of a file with CHOWN
  • Read and print file content
  • Close file
  • Add/append/write new data into a file
  • Change permission of a file with CHMOD
  • Create directory with MKDIR
  • Rename file or directory with RENAME
  • Remove empty file or directory with REMOVE
  • Remove file or directory with any children it contains with REMOVEALL
  • Change working directory with CHDIR
  • Open a directory with OPEN
  • List files in a directory with READDIR
  • Close directory
  • Learn file/directory type
  • Learn temp directory with TEMPDIR
  • Learn file permissions
  • That's all for now...

License

Please use and re-use however you want.