// // Copyright (c) 2017-2018 Intel Corporation // // SPDX-License-Identifier: Apache-2.0 // package main import ( "fmt" "os" "path/filepath" ) // resolvePath returns the fully resolved and expanded value of the // specified path. func resolvePath(path string) (string, error) { if path == "" { return "", fmt.Errorf("path must be specified") } absolute, err := filepath.Abs(path) if err != nil { return "", err } resolved, err := filepath.EvalSymlinks(absolute) if err != nil { if os.IsNotExist(err) { // Make the error clearer than the default return "", fmt.Errorf("file %v does not exist", absolute) } return "", err } return resolved, nil }