@vercel/go 28.0.1-snapshot-e70db18f5218 → 28.0.2-snapshot-ff25f3f66933

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
Binary file
@@ -0,0 +1,27 @@
1
+ import type { GoModJson } from './go-helpers';
2
+ interface NormalizedModule {
3
+ name: string;
4
+ version: string;
5
+ indirect: boolean;
6
+ }
7
+ /**
8
+ * Applies a `go.mod`'s Replace[] rules to its Require[] list.
9
+ *
10
+ * Version-specific rules (`replace foo v1.2.3 => ...`) only fire when versions match.
11
+ * Version-less rules (`replace foo => ...`) fire for any version of the same module.
12
+ *
13
+ * Local-path replacements (`replace foo => ../local`) drop the module entirely.
14
+ * Module-path replacements (`replace foo => github.com/fork/bar`) substitute name + version.
15
+ *
16
+ * Indirect status is preserved.
17
+ */
18
+ export declare function applyReplaces(goMod: GoModJson): NormalizedModule[];
19
+ export declare function generateProjectManifest({ workPath, goModJson, resolvedGoVersion, framework, serviceType, }: {
20
+ workPath: string;
21
+ goModJson: GoModJson | null;
22
+ resolvedGoVersion: string;
23
+ framework?: string | null;
24
+ serviceType?: string | null;
25
+ }): Promise<void>;
26
+ export declare const diagnostics: import("@vercel/build-utils").Diagnostics;
27
+ export {};
@@ -0,0 +1,13 @@
1
+ import { type DetectEntrypointFn } from '@vercel/build-utils';
2
+ export declare const GO_CANDIDATE_ENTRYPOINTS: string[];
3
+ /**
4
+ * Detect the Go entrypoint for standalone server mode.
5
+ * Checks the configured entrypoint first, then searches candidate locations.
6
+ */
7
+ export declare function detectGoEntrypoint(workPath: string, configuredEntrypoint?: string): Promise<string | null>;
8
+ /**
9
+ * Normalized entrypoint detector for Go services. Wraps {@link detectGoEntrypoint}
10
+ * and returns the result in the shared {@link DetectedEntrypoint} shape consumed
11
+ * by services auto-detection.
12
+ */
13
+ export declare const detectEntrypoint: DetectEntrypointFn;
@@ -0,0 +1,7 @@
1
+ /** Removes a Go cache tree, including read-only module directories. */
2
+ export declare function removeGoCacheTree(path: string): Promise<void>;
3
+ /**
4
+ * Replaces a symlinked Go cache directory with a physical copy. The cache
5
+ * uploader requires physical files inside the repo, not symlinked trees.
6
+ */
7
+ export declare function materializeGoCacheDirectory(goCacheDir: string): Promise<void>;
@@ -0,0 +1,149 @@
1
+ import execa from 'execa';
2
+ import type { Env } from '@vercel/build-utils';
3
+ export declare const localCacheDir: string;
4
+ export declare const goGlobalCachePath: string;
5
+ export declare const OUT_EXTENSION: string;
6
+ interface Analyzed {
7
+ functionName: string;
8
+ packageName: string;
9
+ watch?: boolean;
10
+ }
11
+ /**
12
+ * Parses the AST of the specified entrypoint Go file.
13
+ * @param workPath The work path (e.g. `/path/to/project`)
14
+ * @param entrypoint The path to the entrypoint file (e.g.
15
+ * `/path/to/project/api/index.go`)
16
+ * @param modulePath The path to the directory containing the `go.mod` (e.g.
17
+ * `/path/to/project/api`)
18
+ * @returns The results from the AST parsing
19
+ */
20
+ export declare function getAnalyzedEntrypoint({ entrypoint, modulePath, workPath, }: {
21
+ entrypoint: string;
22
+ modulePath?: string;
23
+ workPath: string;
24
+ }): Promise<Analyzed>;
25
+ export interface GoModJson {
26
+ Module?: {
27
+ Path: string;
28
+ };
29
+ Go?: string;
30
+ Require?: Array<{
31
+ Path: string;
32
+ Version: string;
33
+ Indirect?: boolean;
34
+ }>;
35
+ Replace?: Array<{
36
+ Old: {
37
+ Path: string;
38
+ Version?: string;
39
+ };
40
+ New: {
41
+ Path: string;
42
+ Version?: string;
43
+ };
44
+ }>;
45
+ }
46
+ /** Where the selected Go version came from, for build log messages. */
47
+ export type GoVersionSource = {
48
+ kind: 'go.mod' | 'go.work';
49
+ file: string;
50
+ directive: 'go' | 'toolchain';
51
+ } | {
52
+ kind: 'default';
53
+ };
54
+ export declare class GoWrapper {
55
+ private env;
56
+ private opts;
57
+ readonly resolvedVersion: string;
58
+ readonly versionSource: GoVersionSource;
59
+ constructor(env: Env, opts: execa.Options | undefined, resolvedVersion: string, versionSource?: GoVersionSource);
60
+ private execute;
61
+ mod({ tolerateErrors }?: {
62
+ tolerateErrors?: boolean | undefined;
63
+ }): Promise<execa.ExecaReturnValue<string>>;
64
+ /**
65
+ * Runs `go mod edit -json <path>` and returns the parsed structure.
66
+ */
67
+ modEditJson(goModPath: string): Promise<GoModJson | null>;
68
+ /** Populate and verify the complete module graph before an offline build. */
69
+ downloadModules(): Promise<execa.ExecaReturnValue<string>>;
70
+ verifyModules(): Promise<execa.ExecaReturnValue<string>>;
71
+ vendor(): Promise<execa.ExecaReturnValue<string>>;
72
+ get(src?: string): Promise<execa.ExecaReturnValue<string>>;
73
+ getEnv(): Env;
74
+ build(src: string | string[], dest: string, { vendorMode, release }?: {
75
+ vendorMode?: boolean | undefined;
76
+ release?: boolean | undefined;
77
+ }): Promise<execa.ExecaReturnValue<string>>;
78
+ }
79
+ type CreateGoOptions = {
80
+ /** Directory containing the `go.mod`, if any. */
81
+ modulePath?: string;
82
+ /** Active workspace file; its directives take precedence over `go.mod`. */
83
+ workspaceFile?: string;
84
+ opts?: execa.Options;
85
+ workPath: string;
86
+ /** Treat the `go` directive as a minimum, as upstream `go` does. */
87
+ preferNewestToolchain?: boolean;
88
+ /** Minimum toolchain required by a consuming compiler. */
89
+ minimumVersion?: string;
90
+ };
91
+ export declare function newestSupportedGoVersion(): string;
92
+ /** Finds the nearest `go.mod` up to `stopDir` (inclusive). */
93
+ export declare function findGoModPath(startDir: string, stopDir: string): Promise<string | undefined>;
94
+ /**
95
+ * Honors `GOWORK`, otherwise searches from the Go command's cwd through
96
+ * `stopDir` (inclusive).
97
+ */
98
+ export declare function findGoWorkPath(startDir: string, stopDir: string, goWork?: string): Promise<string | undefined>;
99
+ export declare function compareGoVersions(left: string, right: string): number;
100
+ /** An explicit `toolchain` directive always wins; `go` is a pin or a minimum. */
101
+ export declare function selectGoVersion(preferred: GoVersions | undefined, { preferNewestToolchain }?: {
102
+ preferNewestToolchain?: boolean | undefined;
103
+ }): string;
104
+ export declare function isBelowMinDarwinRunnable(version: string): boolean;
105
+ /**
106
+ * Probes the binary on `env.PATH`; `GOTOOLCHAIN=local` prevents module or
107
+ * workspace directives from switching toolchains during `go version`.
108
+ */
109
+ export declare function getInstalledGoVersion(env: Env): Promise<{
110
+ version: string;
111
+ short: string;
112
+ major: number;
113
+ minor: number;
114
+ patch: number;
115
+ }>;
116
+ /**
117
+ * Creates a wrapper for the selected Go version, checking the local cache,
118
+ * global cache, then PATH before downloading to the global cache.
119
+ */
120
+ export declare function createGo({ modulePath, workspaceFile, opts, workPath, preferNewestToolchain, minimumVersion, }: CreateGoOptions): Promise<GoWrapper>;
121
+ interface GoVersions {
122
+ go: string;
123
+ toolchain?: string;
124
+ }
125
+ /**
126
+ * Checks if a file is an ELF binary by reading the 4-byte magic header.
127
+ */
128
+ export declare function isElfBinary(filePath: string): Promise<boolean>;
129
+ /**
130
+ * Extracts the module name's last path segment from a go.mod file.
131
+ * e.g. "github.com/user/myapp" -> "myapp"
132
+ */
133
+ export declare function getGoModuleName(goModPath: string): Promise<string | undefined>;
134
+ /**
135
+ * Discovers the compiled Go binary after a custom buildCommand.
136
+ *
137
+ * Priority:
138
+ * 1. User wrote directly to `destPath` (via $VERCEL_OUTPUT_FILE)
139
+ * 2. Well-known binary names in workPath (with ELF + mtime check)
140
+ * 3. Scan workPath top-level for new ELF binaries (mtime check)
141
+ * 4. Scan workPath/bin/ for new ELF binaries (mtime check)
142
+ */
143
+ export declare function findGoBinary(workPath: string, destPath: string, goModPath: string | undefined, buildStartTime: number): Promise<void>;
144
+ /**
145
+ * Parses `go` and `toolchain` directives from `go.mod` or `go.work` content.
146
+ * Returns `undefined` without a `go` directive; throws for unsupported versions.
147
+ */
148
+ export declare function parseGoModVersion(content: string): GoVersions | undefined;
149
+ export {};
@@ -0,0 +1,14 @@
1
+ import { BuildOptions, type BuildResultVX, Files, PrepareCacheOptions, ShouldServe, StartDevServerOptions, StartDevServerResult } from '@vercel/build-utils';
2
+ export { detectEntrypoint, detectGoEntrypoint } from './entrypoint';
3
+ import { diagnostics } from './diagnostics';
4
+ export { diagnostics };
5
+ export declare const shouldServe: ShouldServe;
6
+ export declare const version = -1;
7
+ export declare function build(options: BuildOptions): Promise<BuildResultVX>;
8
+ export declare function getNewHandlerFunctionName(originalFunctionName: string, entrypoint: string): string;
9
+ export declare function startDevServer(opts: StartDevServerOptions): Promise<StartDevServerResult>;
10
+ export interface CancelablePromise<T> extends Promise<T> {
11
+ cancel: () => void;
12
+ }
13
+ /** Returns the service-local cache with repo-relative paths for restoration. */
14
+ export declare function prepareCache({ workPath, repoRootPath, }: PrepareCacheOptions): Promise<Files>;