tinygo icon indicating copy to clipboard operation
tinygo copied to clipboard

cannot use `tinygo build -ldflags "-X 'main.WASM_NAME=ws_conn.wasm'"` to modify variable WASM_NAME

Open longkui-clown opened this issue 1 year ago • 2 comments
trafficstars

when i use cmd tinygo build -ldflags "-X 'main.WASM_NAME=ws_conn.wasm'" to change the variable WASM_NAME in main package like golang, i got the return val in default val, is it not work? image image

longkui-clown avatar Jul 08 '24 05:07 longkui-clown

The documentation mentions that if a default value is set for a variable, value passed with ldflags will be ignored.

One important thing to note is that you cannot use a default value in your code if you want to be able to set that value using -ldflags. If you set the variable to a default value, then the value you pass using ldflags will be ignored.

Source: How to set build-time variables

Tush-r avatar Aug 26 '24 06:08 Tush-r

thanks,i got it

longkui-clown avatar Aug 27 '24 04:08 longkui-clown

Closing since the question was answered. Thank you!

deadprogram avatar Sep 06 '24 09:09 deadprogram