дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-08 19:02:17 +02:00
Go settings, execution, debugging and test reporting were disconnected, leaving Go projects without editable build/test fields and workspace maintenance actions. - Add project build constraints that update gopls in place, and notices on excluded files. - Add editable Go Build and Go Test configurations with directory, package and file targets, separate tool and program arguments, modules, environment, output selection and build-only execution, and pass the same settings to Delve. - Decode Go JSON test output into the results view, with subtests, failures, skips and rerun failed. Add gutter targets for benchmarks and generate directives. - Add module environment and vendoring settings, read go.work members, and offer tidy, download, sync and use from file menus. - Add file and package generate actions, and format and organize imports through gopls on Save and Reformat. - Show what a Go program prints in the debug console: Delve's debuggee shares its stdio, which no DAP event carries. - Keep the default build output out of version control, and keep configurations produced by an earlier run out of the gutter choices. Fixes #507 Fixes #237
41 рядки
1.4 KiB
TypeScript
41 рядки
1.4 KiB
TypeScript
/**
|
|
* Go module paths (`module example.com/app` in `go.mod`) of the project's Go
|
|
* configurations, for GoLand's configuration names (`go test example.com/app/calc`,
|
|
* `TestAdd in example.com/app/calc`). Read once per module directory.
|
|
*/
|
|
import { call, commands, isTauri, type RunConfig } from "@/platform/ipc";
|
|
import { goModuleDir } from "./producers";
|
|
|
|
const known = new Map<string, string | null>();
|
|
|
|
export function invalidateGoModules() {
|
|
known.clear();
|
|
}
|
|
|
|
export function parseGoModule(gomod: string): string | null {
|
|
const m = /^\s*module\s+("?)([^\s"]+)\1/m.exec(gomod);
|
|
return m?.[2] ?? null;
|
|
}
|
|
|
|
/** The module path of `dir` when already read: `null` without a readable `go.mod`. */
|
|
export function goModulePath(dir: string): string | null | undefined {
|
|
return known.get(dir);
|
|
}
|
|
|
|
/** Reads the `go.mod` of every Go configuration's module not read yet. */
|
|
export async function loadGoModules(root: string | null, configs: readonly RunConfig[]): Promise<void> {
|
|
if (!root || !isTauri()) return;
|
|
const dirs = new Set(configs.filter((c) => c.kind === "go").map((c) => goModuleDir(root, c.params?.module ?? c.cwd)));
|
|
await Promise.all(
|
|
[...dirs]
|
|
.filter((d) => !known.has(d))
|
|
.map(async (d) => {
|
|
try {
|
|
known.set(d, parseGoModule(await call(commands.fsReadText(`${d}/go.mod`))));
|
|
} catch {
|
|
known.set(d, null);
|
|
}
|
|
}),
|
|
);
|
|
}
|