Coverage for lintro / utils / environment / go_info.py: 79%

14 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-04-03 18:53 +0000

1"""Go runtime information.""" 

2 

3from __future__ import annotations 

4 

5from dataclasses import dataclass 

6 

7 

8@dataclass 

9class GoInfo: 

10 """Go runtime information.""" 

11 

12 version: str | None 

13 gopath: str | None 

14 goroot: str | None 

15 

16 @property 

17 def section_title(self) -> str: 

18 """Return the section title for display.""" 

19 return "Go" 

20 

21 def to_display_rows(self) -> list[tuple[str, str]]: 

22 """Return label-value pairs for rendering.""" 

23 return [ 

24 ("Version", self.version or "(unknown)"), 

25 ("GOPATH", self.gopath or "(not set)"), 

26 ("GOROOT", self.goroot or "(not set)"), 

27 ] 

28 

29 def is_available(self) -> bool: 

30 """Return whether this section has data to display.""" 

31 return self.version is not None