/top/
/new/
/best/
/ask/
/show/
/job/
^
slacker news
login
about
←back to thread
Show HN: Write Go code in JavaScript files
(www.npmjs.com)
153 points
yar-kravtsov
| 1 comments |
27 Oct 25 05:36 UTC
|
HN request time: 0.325s
|
source
I built a Vite plugin that lets you write Go code directly in .js files using a "use golang" directive. It compiles to WebAssembly automatically.
Show context
tkzed49
◴[
27 Oct 25 09:55 UTC
]
No.
45719084
[source]
▶
>>45717724 (OP)
#
Beautiful. Minor feedback: rather than having a "use golang" directive, just allow imports of .go files. This is more idiomatic for JS bundlers.
replies(4):
>>45720617
#
>>45720828
#
>>45721171
#
>>45727246
#
1.
CamouflagedKiwi
◴[
27 Oct 25 14:06 UTC
]
No.
45721171
[source]
▶
>>45719084
#
That would also avoid the problem with this syntax, that it's not a valid Go file (it doesn't start with `package ...` and I don't think a bare top-level string is valid), which lots of editors will be pretty unhappy about.
ID:
GO
↑