This is an education project that attempts to reimplement the GNU coreutils in Go. You can find the full manual here:
https://www.gnu.org/software/coreutils/manual/coreutils.html
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
476 B
32 lines
476 B
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"flag"
|
|
"log"
|
|
"io/fs"
|
|
)
|
|
|
|
func PrintStat(stat fs.FileInfo) {
|
|
fmt.Printf("File: %s\nSize: %d\nAccess: %v\nModify: %v",
|
|
stat.Name(),
|
|
stat.Size(),
|
|
stat.Mode(),
|
|
stat.ModTime())
|
|
}
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
files := flag.Args()
|
|
|
|
for _, fname := range files {
|
|
f, err := os.Open(fname)
|
|
if err != nil { log.Fatal(err) }
|
|
|
|
stats, err := f.Stat()
|
|
if err != nil { log.Fatal(err) }
|
|
|
|
PrintStat(stats)
|
|
}
|
|
}
|
|
|