本站源代码
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.

26 lines
711B

  1. package ssh_config
  2. import "fmt"
  3. // Position of a document element within a SSH document.
  4. //
  5. // Line and Col are both 1-indexed positions for the element's line number and
  6. // column number, respectively. Values of zero or less will cause Invalid(),
  7. // to return true.
  8. type Position struct {
  9. Line int // line within the document
  10. Col int // column within the line
  11. }
  12. // String representation of the position.
  13. // Displays 1-indexed line and column numbers.
  14. func (p Position) String() string {
  15. return fmt.Sprintf("(%d, %d)", p.Line, p.Col)
  16. }
  17. // Invalid returns whether or not the position is valid (i.e. with negative or
  18. // null values)
  19. func (p Position) Invalid() bool {
  20. return p.Line <= 0 || p.Col <= 0
  21. }
上海开阖软件有限公司 沪ICP备12045867号-1