filepath 를 알고 있을 때 ext 추출
참고 https://pkg.go.dev/path/filepath
import (
"fmt"
"path/filepath"
)
func main() {
ext := filepath.Ext("/tmp/test.go")
fmt.Println("ext 1:", ext)
ext = filepath.Ext("./hello.png")
fmt.Println("ext 2:", ext)
}
// ext 1: .go
// ext 2: .png
'Language > Go' 카테고리의 다른 글
[Go] filetype (MIME type) (0) | 2022.09.16 |
---|---|
[Go] get image width height (image: unknown format) (0) | 2022.09.15 |
[Go] timestamp Asia/Seoul (0) | 2022.09.11 |
[Go] Gin vs Echo vs Fiber Framework (0) | 2022.08.21 |
[Go] Time format (2006-01-02 15:04:05) (0) | 2022.07.20 |