@@ -13,7 +13,7 @@ pub fn generate_bindings(
1313 output : Option < & Path > ,
1414 pkg_name : Option < String > ,
1515) -> Result < ( ) > {
16- let ( resolve, world) = parse_wit ( wit_path, world, features, all_features) ?;
16+ let ( mut resolve, world) = parse_wit ( wit_path, world, features, all_features) ?;
1717 let mut files = Default :: default ( ) ;
1818
1919 let format = if should_format {
@@ -22,14 +22,24 @@ pub fn generate_bindings(
2222 wit_bindgen_go:: Format :: False
2323 } ;
2424
25+ // If the user wants to create a package rather than a standalone binary, provide them with the
26+ // go.bytecodealliance.org/pkg version that needs to be placed in their go.mod file
27+ let mut message: Option < String > = None ;
28+ if pkg_name. is_some ( ) {
29+ message = Some ( format ! (
30+ "Success! Please add the following line to your 'go.mod' file:\n \n require {}" ,
31+ wit_bindgen_go:: remote_pkg_version( )
32+ ) ) ;
33+ }
34+
2535 wit_bindgen_go:: Opts {
2636 generate_stubs,
2737 format,
2838 pkg_name,
2939 ..Default :: default ( )
3040 }
3141 . build ( )
32- . generate ( & resolve, world, & mut files) ?;
42+ . generate ( & mut resolve, world, & mut files) ?;
3343
3444 let output_path = match output {
3545 Some ( p) => make_path_absolute ( & p. to_path_buf ( ) ) ?,
@@ -45,5 +55,9 @@ pub fn generate_bindings(
4555 std:: fs:: write ( & file_path, contents) ?;
4656 }
4757
58+ if let Some ( msg) = message {
59+ println ! ( "{msg}" ) ;
60+ }
61+
4862 Ok ( ( ) )
4963}
0 commit comments