Created
November 11, 2025 12:43
-
-
Save yanmhlv/70f0dbba16ad2c6c563a757a42251439 to your computer and use it in GitHub Desktop.
generates launch config for vscode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import os | |
| import json | |
| CMD_DIR = "./cmd" | |
| LAUNCH_JSON = ".vscode/launch.json" | |
| os.makedirs(".vscode", exist_ok=True) | |
| configs = [] | |
| if os.path.isdir(CMD_DIR): | |
| for name in sorted(os.listdir(CMD_DIR)): | |
| path = os.path.join(CMD_DIR, name) | |
| if os.path.isdir(path): | |
| configs.append({ | |
| "name": f"Debug {name}", | |
| "type": "go", | |
| "request": "launch", | |
| "mode": "auto", | |
| "program": '${workspaceFolder}' + f"/cmd/{name}", | |
| "cwd": "${workspaceFolder}", | |
| "args": [], | |
| "envFile": [ | |
| "${workspaceFolder}/.env" | |
| ] | |
| }) | |
| launch = { | |
| "version": "0.2.0", | |
| "configurations": configs | |
| } | |
| with open(LAUNCH_JSON, "w") as f: | |
| json.dump(launch, f, indent=2) | |
| f.write("\n") | |
| print("launch.json updated with debug configs for each /cmd subdirectory.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment