Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A quick test to read the OneDrive Folder in the current user's home directory. (Based off of:
package main
import (
func readCurrentDir() {
usr, err := user.Current()
if err != nil {
log.Fatal( err )
fmt.Println("User's Home Directory: " + usr.HomeDir + "\n")
file, err := os.Open(usr.HomeDir + "\\OneDrive")
if err != nil {
log.Fatalf("failed opening directory: %s", err)
stat, err := os.Stat(usr.HomeDir + "\\OneDrive")
if err != nil {
log.Fatalf("failed stating directory: %s", err)
lstat, err := os.LStat(usr.HomeDir + "\\OneDrive")
if err != nil {
log.Fatalf("failed lstating directory: %s", err)
defer file.Close()
list,_ := file.Readdirnames(0) // 0 to read all files and folders
for _, name := range list {
func main() {

This comment has been minimized.

Copy link

clee231 commented Nov 25, 2017

Following from

I can't seem to build this? It complains that os.Lstat is undefined. Sorry if I'm doing this incorrectly, I'm not all too familiar with go-lang.

Windows 10 (Fall Creator's Update) Version 1709
OS Build: 16299.19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.