Skip to content

Commit 822fdb1

Browse files
authored
fix(go): change 'mod-name' flag to 'pkg-name' (#1505)
Signed-off-by: Andrew Steurer <[email protected]>
1 parent da3f633 commit 822fdb1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

crates/go/src/lib.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,11 @@ pub struct Opts {
9595
#[cfg_attr(feature = "clap", clap(long))]
9696
pub generate_stubs: bool,
9797

98-
/// The name of the Go module housing the generated bindings
99-
/// (or "wit_component" if `None`).
98+
/// If specified, organize the bindings into a package for use as a library;
99+
/// otherwise (if `None`), the bindings will be organized for use as a
100+
/// standalone executable.
100101
#[cfg_attr(feature = "clap", clap(long))]
101-
pub mod_name: Option<String>,
102+
pub pkg_name: Option<String>,
102103
}
103104

104105
impl Opts {
@@ -189,7 +190,7 @@ struct Go {
189190
impl Go {
190191
/// Adds the bindings module prefix to a package name.
191192
fn mod_pkg(&self, name: &str) -> String {
192-
let prefix = self.opts.mod_name.as_deref().unwrap_or("wit_component");
193+
let prefix = self.opts.pkg_name.as_deref().unwrap_or("wit_component");
193194
format!(r#""{prefix}/{name}""#)
194195
}
195196

@@ -843,7 +844,7 @@ impl WorldGenerator for Go {
843844
.collect::<Vec<_>>()
844845
.join("\n");
845846

846-
let (exports_file_path, package_name, main_func) = if self.opts.mod_name.is_some() {
847+
let (exports_file_path, package_name, main_func) = if self.opts.pkg_name.is_some() {
847848
// If a module name is specified, the generated files will be used as a library.
848849
("wit_exports/wit_exports.go", "wit_exports", "")
849850
} else {
@@ -857,7 +858,7 @@ impl WorldGenerator for Go {
857858
"go.mod",
858859
format!(
859860
"module {}\n\ngo 1.25\n\nreplace github.com/bytecodealliance/wit-bindgen => {}",
860-
self.opts.mod_name.as_deref().unwrap_or("wit_component"),
861+
self.opts.pkg_name.as_deref().unwrap_or("wit_component"),
861862
replacement_pkg
862863
)
863864
.as_bytes(),

0 commit comments

Comments
 (0)