goversion_pkgpath_lt_go111.go 374 B

123456789101112131415161718
  1. // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
  2. // Use of this source code is governed by a MIT license found in the LICENSE file.
  3. // +build !go1.11
  4. package main
  5. import (
  6. "go/build"
  7. )
  8. func pkgPath(dir string) (string, error) {
  9. pkg, err := build.Default.ImportDir(dir, build.AllowBinary)
  10. if err != nil {
  11. return "", err
  12. }
  13. return pkg.ImportPath, nil
  14. }