diff --git a/lib/datasource/go/digest.ts b/lib/datasource/go/digest.ts
new file mode 100644
index 0000000000000000000000000000000000000000..0dd01efcc9d48e6db5e38d53f351d1ce39d191db
--- /dev/null
+++ b/lib/datasource/go/digest.ts
@@ -0,0 +1,39 @@
+import * as github from '../github-tags';
+import type { DigestConfig } from '../types';
+import { bitbucket, getDatasource } from './util';
+
+/**
+ * go.getDigest
+ *
+ * This datasource resolves a go module URL into its source repository
+ *  and then fetches the digest it if it is on GitHub.
+ *
+ * This function will:
+ *  - Determine the source URL for the module
+ *  - Call the respective getDigest in github to retrieve the commit hash
+ */
+export async function getDigest(
+  { lookupName }: Partial<DigestConfig>,
+  value?: string
+): Promise<string | null> {
+  const source = await getDatasource(lookupName);
+  if (!source) {
+    return null;
+  }
+
+  // ignore v0.0.0- pseudo versions that are used Go Modules - look up default branch instead
+  const tag = value && !value.startsWith('v0.0.0-2') ? value : undefined;
+
+  switch (source.datasource) {
+    case github.id: {
+      return github.getDigest(source, tag);
+    }
+    case bitbucket.id: {
+      return bitbucket.getDigest(source, tag);
+    }
+    /* istanbul ignore next: can never happen, makes lint happy */
+    default: {
+      return null;
+    }
+  }
+}
diff --git a/lib/datasource/go/index.spec.ts b/lib/datasource/go/index.spec.ts
index 68be8a79a4f0da77c425a82e3285ab4c0e7811d3..f667468293fdfd2547d5c2d9054bbec523bd479c 100644
--- a/lib/datasource/go/index.spec.ts
+++ b/lib/datasource/go/index.spec.ts
@@ -2,7 +2,8 @@ import { getPkgReleases } from '..';
 import * as httpMock from '../../../test/http-mock';
 import { logger, mocked } from '../../../test/util';
 import * as _hostRules from '../../util/host-rules';
-import { id as datasource, getDigest } from '.';
+import { getDigest } from './digest';
+import { id as datasource } from '.';
 
 jest.mock('../../util/host-rules');
 
diff --git a/lib/datasource/go/index.ts b/lib/datasource/go/index.ts
index e43df2325863aa438b50ea5da86c1df9b7f880e4..99c554cbba3cf40d395a7a06f8e27e15d3bb78f8 100644
--- a/lib/datasource/go/index.ts
+++ b/lib/datasource/go/index.ts
@@ -2,7 +2,7 @@ import { logger } from '../../logger';
 import { regEx } from '../../util/regex';
 import * as github from '../github-tags';
 import * as gitlab from '../gitlab-tags';
-import type { DigestConfig, GetReleasesConfig, ReleaseResult } from '../types';
+import type { GetReleasesConfig, ReleaseResult } from '../types';
 import * as goproxy from './goproxy';
 import { bitbucket, getDatasource } from './util';
 
@@ -115,39 +115,3 @@ export async function getReleases(
 
   return res;
 }
-
-/**
- * go.getDigest
- *
- * This datasource resolves a go module URL into its source repository
- *  and then fetches the digest it if it is on GitHub.
- *
- * This function will:
- *  - Determine the source URL for the module
- *  - Call the respective getDigest in github to retrieve the commit hash
- */
-export async function getDigest(
-  { lookupName }: Partial<DigestConfig>,
-  value?: string
-): Promise<string | null> {
-  const source = await getDatasource(lookupName);
-  if (!source) {
-    return null;
-  }
-
-  // ignore v0.0.0- pseudo versions that are used Go Modules - look up default branch instead
-  const tag = value && !value.startsWith('v0.0.0-2') ? value : undefined;
-
-  switch (source.datasource) {
-    case github.id: {
-      return github.getDigest(source, tag);
-    }
-    case bitbucket.id: {
-      return bitbucket.getDigest(source, tag);
-    }
-    /* istanbul ignore next: can never happen, makes lint happy */
-    default: {
-      return null;
-    }
-  }
-}