您如何获取filepath.IsAbs来正确识别绝对路径?

According to the File Paths tutorial on gobyexample.com, the following code should result in a print out of false, and then true for each line respectively:

package main

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

  func main() {
    fmt.Println(filepath.IsAbs("dir/file"))
    fmt.Println(filepath.IsAbs("/dir/file"))
  }

I on Windows 10, Go version go1.12.5 windows/amd64, and building in Cmder.

I get false for both lines, and I cannot figure out why or if there is something different I can do to get the expected output.

Because on Windows root path starts with drive.

Try: ‘C:\dir\file’