[go] 파일 경로의 디렉토리 부분 분리하기

다음은 Dir 함수를 사용하여 파일 경로의 디렉토리 부분을 분리하는 예제 코드입니다.

package main

import (
    "fmt"
    "path/filepath"
)

func main() {
    filePath := "/path/to/example/file.txt"
    dir := filepath.Dir(filePath)
    fmt.Println("Directory:", dir)
}

위의 예제 코드를 실행하면 /path/to/example와 같이 파일 경로의 디렉토리 부분이 출력됩니다.

더 자세한 내용은 Go 공식 문서를 참조하시기 바랍니다.