databricks-cli/libs/dyn/location.go

26 lines
425 B
Go

package dyn
import (
"errors"
"fmt"
"path/filepath"
)
type Location struct {
File string `json:"file"`
Line int `json:"line"`
Column int `json:"column"`
}
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 "", errors.New("no file in location")
}
return filepath.Dir(l.File), nil
}