databricks-cli/libs/dyn/location.go

25 lines
365 B
Go
Raw Normal View History

package dyn
2023-10-20 12:56:59 +00:00
import (
"fmt"
"path/filepath"
)
2023-10-20 12:56:59 +00:00
type Location struct {
File string
Line int
Column int
}
func (l Location) String() string {
return fmt.Sprintf("%s:%d:%d", l.File, l.Line, l.Column)
}
func (l Location) Directory() (string, error) {
if l.File == "" {
return "", fmt.Errorf("no file in location")
}
return filepath.Dir(l.File), nil
}