Go 와일드카드 패턴 파일 목록 + 파일크기 얻기

1 개요[ | ]

Go 와일드카드 패턴 파일 목록 + 파일크기 얻기
package main

import (
	"fmt"
	"os"
	"path/filepath"
)

func main() {
	files, err := filepath.Glob("/etc/*")
	if err != nil {
		fmt.Printf("error: %s", err)
		panic(err)
	}
	for _, file := range files {
		f, err := os.Stat(file)
		if err != nil || f.IsDir() {
			continue
		}
		fmt.Printf("%8d %s\n", f.Size(), file)
	}
}

2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}