Skip to content

Commit 5985c37

Browse files
committed
fix: small refactor
Signed-off-by: Andrew Steurer <[email protected]>
1 parent 258b5be commit 5985c37

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

crates/go/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ fn remote_pkg(name: &str) -> String {
3838
format!(r#""github.com/bytecodealliance/wit-bindgen/{name}""#)
3939
}
4040

41-
/// This is the literal location of the Go package.
42-
const REPLACEMENT_PKG: &str = concat!(
43-
"github.com/bytecodealliance/wit-bindgen/crates/go/src/package v",
44-
env!("CARGO_PKG_VERSION")
45-
);
46-
4741
#[derive(Default, Debug, Copy, Clone)]
4842
pub enum Format {
4943
#[default]
@@ -853,18 +847,24 @@ impl WorldGenerator for Go {
853847
// If a module name is specified, the generated files will be used as a library.
854848
("wit_exports/wit_exports.go", "wit_exports", "")
855849
} else {
856-
// If a module name is NOT specified, the generated files will be used as a
857-
// standalone executable.
850+
// This is the literal location of the Go package.
851+
let replacement_pkg = concat!(
852+
"github.com/bytecodealliance/wit-bindgen/crates/go/src/package v",
853+
env!("CARGO_PKG_VERSION")
854+
);
855+
858856
files.push(
859857
"go.mod",
860858
format!(
861859
"module {}\n\ngo 1.25\n\nreplace github.com/bytecodealliance/wit-bindgen => {}",
862860
self.opts.mod_name.as_deref().unwrap_or("wit_component"),
863-
REPLACEMENT_PKG
861+
replacement_pkg
864862
)
865863
.as_bytes(),
866864
);
867865

866+
// If a module name is NOT specified, the generated files will be used as a
867+
// standalone executable.
868868
(
869869
"wit_exports.go",
870870
"main",

0 commit comments

Comments
 (0)