Created
April 18, 2015 09:43
-
-
Save mfischer-zd/b79481e3f0bd7514dd8f to your computer and use it in GitHub Desktop.
Go language: How to get the number of links to a file (Unix)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "os" | |
import "log" | |
import "fmt" | |
import "syscall" | |
func main() { | |
fi, err := os.Stat("testfile1") | |
if err != nil { | |
log.Fatal(err) | |
} | |
stat := fi.Sys().(*syscall.Stat_t) | |
fmt.Printf("%v\n", stat.Nlink) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment