MCPcopy Index your code
hub / github.com/pre-commit/pre-commit / _install_go

Function _install_go

pre_commit/languages/golang.py:102–120  ·  view source on GitHub ↗
(version: str, dest: str)

Source from the content-addressed store, hash-verified

100
101
102def _install_go(version: str, dest: str) -> None:
103 try:
104 resp = urllib.request.urlopen(_get_url(version))
105 except urllib.error.HTTPError as e: # pragma: no cover
106 if e.code == 404:
107 raise ValueError(
108 f'Could not find a version matching your system requirements '
109 f'(os={platform.system().lower()}; arch={_ARCH})',
110 ) from e
111 else:
112 raise
113 else:
114 with tempfile.TemporaryFile() as f:
115 shutil.copyfileobj(resp, f)
116 f.seek(0)
117
118 with _open_archive(f) as archive:
119 archive.extractall(dest)
120 shutil.move(os.path.join(dest, 'go'), os.path.join(dest, '.go'))
121
122
123@contextlib.contextmanager

Callers 1

install_environmentFunction · 0.85

Calls 3

_get_urlFunction · 0.85
_open_archiveFunction · 0.85
extractallMethod · 0.80

Tested by

no test coverage detected