aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Mita <mita.charles@gmail.com>2024-03-19 15:40:13 +0100
committerGitHub <noreply@github.com>2024-03-19 14:40:13 +0000
commitaeb83e878033ef357642c87122e193df44da03fe (patch)
tree9885fdc55a87db4c804aa82bfb13519cc806d72c
parentcac338e5c869116cbe86758001dced886a38b39c (diff)
downloadbazelbuild-rules_go-aeb83e878033ef357642c87122e193df44da03fe.tar.gz
Replace instances of to_json() method with json.encode(..) (#3896)
The to_json and to_proto methods on struct are deprecated and will be removed. The "json" and "proto" builtin modules should be used instead. This replaces instances of `foo.to_json()` with `json.encode(foo)`.
-rw-r--r--go/private/tools/path.bzl2
-rw-r--r--go/tools/gopackagesdriver/aspect.bzl2
2 files changed, 2 insertions, 2 deletions
diff --git a/go/private/tools/path.bzl b/go/private/tools/path.bzl
index f23677a2..dffebaed 100644
--- a/go/private/tools/path.bzl
+++ b/go/private/tools/path.bzl
@@ -112,7 +112,7 @@ def _go_path_impl(ctx):
f.basename,
)
manifest_file = ctx.actions.declare_file(ctx.label.name + "~manifest")
- manifest_entries_json = [e.to_json() for e in manifest_entries]
+ manifest_entries_json = [json.encode(e) for e in manifest_entries]
manifest_content = "[\n " + ",\n ".join(manifest_entries_json) + "\n]"
ctx.actions.write(manifest_file, manifest_content)
inputs.append(manifest_file)
diff --git a/go/tools/gopackagesdriver/aspect.bzl b/go/tools/gopackagesdriver/aspect.bzl
index 36703c75..d76f7f65 100644
--- a/go/tools/gopackagesdriver/aspect.bzl
+++ b/go/tools/gopackagesdriver/aspect.bzl
@@ -77,7 +77,7 @@ def _go_archive_to_pkg(archive):
def make_pkg_json(ctx, name, pkg_info):
pkg_json_file = ctx.actions.declare_file(name + ".pkg.json")
- ctx.actions.write(pkg_json_file, content = pkg_info.to_json())
+ ctx.actions.write(pkg_json_file, content = json.encode(pkg_info))
return pkg_json_file
def _go_pkg_info_aspect_impl(target, ctx):