(version: str, dest: str)
| 100 | |
| 101 | |
| 102 | def _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 |
no test coverage detected