You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

position.go 744B

1234567891011121314151617181920212223242526272829
  1. // Position support for go-toml
  2. package toml
  3. import (
  4. "fmt"
  5. )
  6. // Position of a document element within a TOML document.
  7. //
  8. // Line and Col are both 1-indexed positions for the element's line number and
  9. // column number, respectively. Values of zero or less will cause Invalid(),
  10. // to return true.
  11. type Position struct {
  12. Line int // line within the document
  13. Col int // column within the line
  14. }
  15. // String representation of the position.
  16. // Displays 1-indexed line and column numbers.
  17. func (p Position) String() string {
  18. return fmt.Sprintf("(%d, %d)", p.Line, p.Col)
  19. }
  20. // Invalid returns whether or not the position is valid (i.e. with negative or
  21. // null values)
  22. func (p Position) Invalid() bool {
  23. return p.Line <= 0 || p.Col <= 0
  24. }