goscript 0.0.36 → 0.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (376) hide show
  1. package/compiler/analysis.go +129 -8
  2. package/compiler/compiler.go +4 -1
  3. package/compiler/composite-lit.go +2 -4
  4. package/compiler/expr-call.go +26 -0
  5. package/compiler/lit.go +83 -0
  6. package/compiler/protobuf.go +2 -2
  7. package/compiler/spec-value.go +3 -3
  8. package/compiler/spec.go +7 -4
  9. package/compiler/stmt-assign.go +1 -1
  10. package/compiler/stmt.go +26 -8
  11. package/dist/gs/builtin/slice.js +2 -1
  12. package/dist/gs/builtin/slice.js.map +1 -1
  13. package/dist/gs/github.com/pkg/errors/errors.d.ts +1 -1
  14. package/dist/gs/github.com/pkg/errors/errors.js +182 -23
  15. package/dist/gs/github.com/pkg/errors/errors.js.map +1 -1
  16. package/dist/gs/github.com/pkg/errors/go113.d.ts +1 -1
  17. package/dist/gs/github.com/pkg/errors/go113.js +1 -1
  18. package/dist/gs/github.com/pkg/errors/go113.js.map +1 -1
  19. package/dist/gs/github.com/pkg/errors/index.d.ts +3 -3
  20. package/dist/gs/github.com/pkg/errors/index.js +3 -3
  21. package/dist/gs/github.com/pkg/errors/index.js.map +1 -1
  22. package/dist/gs/github.com/pkg/errors/stack.d.ts +1 -1
  23. package/dist/gs/github.com/pkg/errors/stack.js +8 -5
  24. package/dist/gs/github.com/pkg/errors/stack.js.map +1 -1
  25. package/dist/gs/internal/abi/index.d.ts +20 -0
  26. package/dist/gs/internal/abi/index.js +20 -0
  27. package/dist/gs/internal/abi/index.js.map +1 -0
  28. package/dist/gs/internal/bytealg/index.d.ts +2 -0
  29. package/dist/gs/internal/bytealg/index.js +33 -0
  30. package/dist/gs/internal/bytealg/index.js.map +1 -0
  31. package/dist/gs/internal/byteorder/index.d.ts +8 -0
  32. package/dist/gs/internal/byteorder/index.js +34 -0
  33. package/dist/gs/internal/byteorder/index.js.map +1 -0
  34. package/dist/gs/internal/testlog/index.d.ts +1 -0
  35. package/dist/gs/internal/testlog/index.js +5 -0
  36. package/dist/gs/internal/testlog/index.js.map +1 -0
  37. package/dist/gs/math/index.d.ts +44 -44
  38. package/dist/gs/math/index.js +44 -44
  39. package/dist/gs/math/index.js.map +1 -1
  40. package/dist/gs/os/dir.gs.d.ts +6 -0
  41. package/dist/gs/os/dir.gs.js +35 -0
  42. package/dist/gs/os/dir.gs.js.map +1 -0
  43. package/dist/gs/os/dir_unix.gs.d.ts +7 -0
  44. package/dist/gs/os/dir_unix.gs.js +113 -0
  45. package/dist/gs/os/dir_unix.gs.js.map +1 -0
  46. package/dist/gs/os/dirent_js.gs.d.ts +5 -0
  47. package/dist/gs/os/dirent_js.gs.js +20 -0
  48. package/dist/gs/os/dirent_js.gs.js.map +1 -0
  49. package/dist/gs/os/env.gs.d.ts +12 -0
  50. package/dist/gs/os/env.gs.js +157 -0
  51. package/dist/gs/os/env.gs.js.map +1 -0
  52. package/dist/gs/os/error.gs.d.ts +40 -0
  53. package/dist/gs/os/error.gs.js +158 -0
  54. package/dist/gs/os/error.gs.js.map +1 -0
  55. package/dist/gs/os/error_errno.gs.d.ts +1 -0
  56. package/dist/gs/os/error_errno.gs.js +5 -0
  57. package/dist/gs/os/error_errno.gs.js.map +1 -0
  58. package/dist/gs/os/exec.gs.d.ts +60 -0
  59. package/dist/gs/os/exec.gs.js +136 -0
  60. package/dist/gs/os/exec.gs.js.map +1 -0
  61. package/dist/gs/os/exec_nohandle.gs.d.ts +1 -0
  62. package/dist/gs/os/exec_nohandle.gs.js +2 -0
  63. package/dist/gs/os/exec_nohandle.gs.js.map +1 -0
  64. package/dist/gs/os/exec_posix.gs.d.ts +25 -0
  65. package/dist/gs/os/exec_posix.gs.js +67 -0
  66. package/dist/gs/os/exec_posix.gs.js.map +1 -0
  67. package/dist/gs/os/exec_unix.gs.d.ts +4 -0
  68. package/dist/gs/os/exec_unix.gs.js +46 -0
  69. package/dist/gs/os/exec_unix.gs.js.map +1 -0
  70. package/dist/gs/os/executable.gs.d.ts +2 -0
  71. package/dist/gs/os/executable.gs.js +16 -0
  72. package/dist/gs/os/executable.gs.js.map +1 -0
  73. package/dist/gs/os/executable_js.gs.d.ts +2 -0
  74. package/dist/gs/os/executable_js.gs.js +5 -0
  75. package/dist/gs/os/executable_js.gs.js.map +1 -0
  76. package/dist/gs/os/executable_wasm.gs.d.ts +2 -0
  77. package/dist/gs/os/executable_wasm.gs.js +6 -0
  78. package/dist/gs/os/executable_wasm.gs.js.map +1 -0
  79. package/dist/gs/os/file_constants_js.gs.d.ts +41 -0
  80. package/dist/gs/os/file_constants_js.gs.js +78 -0
  81. package/dist/gs/os/file_constants_js.gs.js.map +1 -0
  82. package/dist/gs/os/file_js.gs.d.ts +22 -0
  83. package/dist/gs/os/file_js.gs.js +73 -0
  84. package/dist/gs/os/file_js.gs.js.map +1 -0
  85. package/dist/gs/os/file_open_unix.gs.d.ts +6 -0
  86. package/dist/gs/os/file_open_unix.gs.js +10 -0
  87. package/dist/gs/os/file_open_unix.gs.js.map +1 -0
  88. package/dist/gs/os/file_posix_js.gs.d.ts +8 -0
  89. package/dist/gs/os/file_posix_js.gs.js +32 -0
  90. package/dist/gs/os/file_posix_js.gs.js.map +1 -0
  91. package/dist/gs/os/file_unix_js.gs.d.ts +27 -0
  92. package/dist/gs/os/file_unix_js.gs.js +64 -0
  93. package/dist/gs/os/file_unix_js.gs.js.map +1 -0
  94. package/dist/gs/os/getwd_js.gs.d.ts +6 -0
  95. package/dist/gs/os/getwd_js.gs.js +21 -0
  96. package/dist/gs/os/getwd_js.gs.js.map +1 -0
  97. package/dist/gs/os/index.d.ts +19 -0
  98. package/dist/gs/os/index.js +20 -0
  99. package/dist/gs/os/index.js.map +1 -0
  100. package/dist/gs/os/path.gs.d.ts +4 -0
  101. package/dist/gs/os/path.gs.js +32 -0
  102. package/dist/gs/os/path.gs.js.map +1 -0
  103. package/dist/gs/os/path_unix.gs.d.ts +4 -0
  104. package/dist/gs/os/path_unix.gs.js +40 -0
  105. package/dist/gs/os/path_unix.gs.js.map +1 -0
  106. package/dist/gs/os/pidfd_js.gs.d.ts +6 -0
  107. package/dist/gs/os/pidfd_js.gs.js +14 -0
  108. package/dist/gs/os/pidfd_js.gs.js.map +1 -0
  109. package/dist/gs/os/pipe_wasm.gs.d.ts +2 -0
  110. package/dist/gs/os/pipe_wasm.gs.js +14 -0
  111. package/dist/gs/os/pipe_wasm.gs.js.map +1 -0
  112. package/dist/gs/os/proc.gs.d.ts +11 -0
  113. package/dist/gs/os/proc.gs.js +68 -0
  114. package/dist/gs/os/proc.gs.js.map +1 -0
  115. package/dist/gs/os/proc_js.gs.d.ts +3 -0
  116. package/dist/gs/os/proc_js.gs.js +12 -0
  117. package/dist/gs/os/proc_js.gs.js.map +1 -0
  118. package/dist/gs/os/rawconn_js.gs.d.ts +10 -0
  119. package/dist/gs/os/rawconn_js.gs.js +26 -0
  120. package/dist/gs/os/rawconn_js.gs.js.map +1 -0
  121. package/dist/gs/os/removeall_js.gs.d.ts +2 -0
  122. package/dist/gs/os/removeall_js.gs.js +7 -0
  123. package/dist/gs/os/removeall_js.gs.js.map +1 -0
  124. package/dist/gs/os/root_js.gs.d.ts +23 -0
  125. package/dist/gs/os/root_js.gs.js +80 -0
  126. package/dist/gs/os/root_js.gs.js.map +1 -0
  127. package/dist/gs/os/root_nonwindows.gs.d.ts +2 -0
  128. package/dist/gs/os/root_nonwindows.gs.js +4 -0
  129. package/dist/gs/os/root_nonwindows.gs.js.map +1 -0
  130. package/dist/gs/os/root_noopenat.gs.d.ts +11 -0
  131. package/dist/gs/os/root_noopenat.gs.js +31 -0
  132. package/dist/gs/os/root_noopenat.gs.js.map +1 -0
  133. package/dist/gs/os/stat.gs.d.ts +24 -0
  134. package/dist/gs/os/stat.gs.js +20 -0
  135. package/dist/gs/os/stat.gs.js.map +1 -0
  136. package/dist/gs/os/stat_js.gs.d.ts +6 -0
  137. package/dist/gs/os/stat_js.gs.js +23 -0
  138. package/dist/gs/os/stat_js.gs.js.map +1 -0
  139. package/dist/gs/os/stat_unix_js.gs.d.ts +8 -0
  140. package/dist/gs/os/stat_unix_js.gs.js +16 -0
  141. package/dist/gs/os/stat_unix_js.gs.js.map +1 -0
  142. package/dist/gs/os/sticky_bsd.gs.d.ts +1 -0
  143. package/dist/gs/os/sticky_bsd.gs.js +3 -0
  144. package/dist/gs/os/sticky_bsd.gs.js.map +1 -0
  145. package/dist/gs/os/sys.gs.d.ts +2 -0
  146. package/dist/gs/os/sys.gs.js +10 -0
  147. package/dist/gs/os/sys.gs.js.map +1 -0
  148. package/dist/gs/os/sys_bsd.gs.d.ts +2 -0
  149. package/dist/gs/os/sys_bsd.gs.js +15 -0
  150. package/dist/gs/os/sys_bsd.gs.js.map +1 -0
  151. package/dist/gs/os/sys_js.gs.d.ts +2 -0
  152. package/dist/gs/os/sys_js.gs.js +6 -0
  153. package/dist/gs/os/sys_js.gs.js.map +1 -0
  154. package/dist/gs/os/tempfile.gs.d.ts +5 -0
  155. package/dist/gs/os/tempfile.gs.js +30 -0
  156. package/dist/gs/os/tempfile.gs.js.map +1 -0
  157. package/dist/gs/os/types.gs.d.ts +59 -0
  158. package/dist/gs/os/types.gs.js +123 -0
  159. package/dist/gs/os/types.gs.js.map +1 -0
  160. package/dist/gs/os/types_js.gs.d.ts +74 -0
  161. package/dist/gs/os/types_js.gs.js +147 -0
  162. package/dist/gs/os/types_js.gs.js.map +1 -0
  163. package/dist/gs/os/types_unix.gs.d.ts +40 -0
  164. package/dist/gs/os/types_unix.gs.js +87 -0
  165. package/dist/gs/os/types_unix.gs.js.map +1 -0
  166. package/dist/gs/os/wait_unimp.gs.d.ts +1 -0
  167. package/dist/gs/os/wait_unimp.gs.js +2 -0
  168. package/dist/gs/os/wait_unimp.gs.js.map +1 -0
  169. package/dist/gs/os/zero_copy_posix.gs.d.ts +4 -0
  170. package/dist/gs/os/zero_copy_posix.gs.js +27 -0
  171. package/dist/gs/os/zero_copy_posix.gs.js.map +1 -0
  172. package/dist/gs/os/zero_copy_stub.gs.d.ts +1 -0
  173. package/dist/gs/os/zero_copy_stub.gs.js +2 -0
  174. package/dist/gs/os/zero_copy_stub.gs.js.map +1 -0
  175. package/dist/gs/reflect/abi.d.ts +59 -0
  176. package/dist/gs/reflect/abi.gs.d.ts +59 -0
  177. package/dist/gs/reflect/abi.gs.js +79 -0
  178. package/dist/gs/reflect/abi.gs.js.map +1 -0
  179. package/dist/gs/reflect/abi.js +79 -0
  180. package/dist/gs/reflect/abi.js.map +1 -0
  181. package/dist/gs/reflect/badlinkname.d.ts +52 -0
  182. package/dist/gs/reflect/badlinkname.gs.d.ts +52 -0
  183. package/dist/gs/reflect/badlinkname.gs.js +72 -0
  184. package/dist/gs/reflect/badlinkname.gs.js.map +1 -0
  185. package/dist/gs/reflect/badlinkname.js +72 -0
  186. package/dist/gs/reflect/badlinkname.js.map +1 -0
  187. package/dist/gs/reflect/deepequal.d.ts +1 -0
  188. package/dist/gs/reflect/deepequal.gs.d.ts +25 -0
  189. package/dist/gs/reflect/deepequal.gs.js +308 -0
  190. package/dist/gs/reflect/deepequal.gs.js.map +1 -0
  191. package/dist/gs/reflect/deepequal.js +139 -0
  192. package/dist/gs/reflect/deepequal.js.map +1 -0
  193. package/dist/gs/reflect/float32reg_generic.gs.d.ts +2 -0
  194. package/dist/gs/reflect/float32reg_generic.gs.js +10 -0
  195. package/dist/gs/reflect/float32reg_generic.gs.js.map +1 -0
  196. package/dist/gs/reflect/index.d.ts +8 -0
  197. package/dist/gs/reflect/index.gs.d.ts +1 -0
  198. package/dist/gs/reflect/index.gs.js +3 -0
  199. package/dist/gs/reflect/index.gs.js.map +1 -0
  200. package/dist/gs/reflect/index.js +10 -0
  201. package/dist/gs/reflect/index.js.map +1 -0
  202. package/dist/gs/reflect/iter.d.ts +4 -0
  203. package/dist/gs/reflect/iter.gs.d.ts +3 -0
  204. package/dist/gs/reflect/iter.gs.js +24 -0
  205. package/dist/gs/reflect/iter.gs.js.map +1 -0
  206. package/dist/gs/reflect/iter.js +24 -0
  207. package/dist/gs/reflect/iter.js.map +1 -0
  208. package/dist/gs/reflect/makefunc.gs.d.ts +34 -0
  209. package/dist/gs/reflect/makefunc.gs.js +288 -0
  210. package/dist/gs/reflect/makefunc.gs.js.map +1 -0
  211. package/dist/gs/reflect/map.d.ts +14 -0
  212. package/dist/gs/reflect/map.js +70 -0
  213. package/dist/gs/reflect/map.js.map +1 -0
  214. package/dist/gs/reflect/map_swiss.gs.d.ts +14 -0
  215. package/dist/gs/reflect/map_swiss.gs.js +70 -0
  216. package/dist/gs/reflect/map_swiss.gs.js.map +1 -0
  217. package/dist/gs/reflect/reflect.gs.d.ts +132 -0
  218. package/dist/gs/reflect/reflect.gs.js +437 -0
  219. package/dist/gs/reflect/reflect.gs.js.map +1 -0
  220. package/dist/gs/reflect/swapper.d.ts +2 -0
  221. package/dist/gs/reflect/swapper.gs.d.ts +1 -0
  222. package/dist/gs/reflect/swapper.gs.js +32 -0
  223. package/dist/gs/reflect/swapper.gs.js.map +1 -0
  224. package/dist/gs/reflect/swapper.js +46 -0
  225. package/dist/gs/reflect/swapper.js.map +1 -0
  226. package/dist/gs/reflect/type.d.ts +126 -0
  227. package/dist/gs/reflect/type.gs.d.ts +4 -0
  228. package/dist/gs/reflect/type.gs.js +21 -0
  229. package/dist/gs/reflect/type.gs.js.map +1 -0
  230. package/dist/gs/reflect/type.js +825 -0
  231. package/dist/gs/reflect/type.js.map +1 -0
  232. package/dist/gs/reflect/types.d.ts +90 -0
  233. package/dist/gs/reflect/types.js +119 -0
  234. package/dist/gs/reflect/types.js.map +1 -0
  235. package/dist/gs/reflect/value.d.ts +13 -0
  236. package/dist/gs/reflect/value.gs.d.ts +4 -0
  237. package/dist/gs/reflect/value.gs.js +12 -0
  238. package/dist/gs/reflect/value.gs.js.map +1 -0
  239. package/dist/gs/reflect/value.js +201 -0
  240. package/dist/gs/reflect/value.js.map +1 -0
  241. package/dist/gs/reflect/visiblefields.d.ts +4 -0
  242. package/dist/gs/reflect/visiblefields.gs.d.ts +3 -0
  243. package/dist/gs/reflect/visiblefields.gs.js +123 -0
  244. package/dist/gs/reflect/visiblefields.gs.js.map +1 -0
  245. package/dist/gs/reflect/visiblefields.js +143 -0
  246. package/dist/gs/reflect/visiblefields.js.map +1 -0
  247. package/dist/gs/strconv/index.d.ts +6 -6
  248. package/dist/gs/strconv/index.js +6 -6
  249. package/dist/gs/strconv/index.js.map +1 -1
  250. package/dist/gs/strings/index.d.ts +1 -1
  251. package/dist/gs/strings/index.js +1 -1
  252. package/dist/gs/strings/index.js.map +1 -1
  253. package/dist/gs/strings/replace.js.map +1 -1
  254. package/dist/gs/sync/atomic/index.d.ts +4 -4
  255. package/dist/gs/sync/atomic/index.js +4 -4
  256. package/dist/gs/sync/atomic/index.js.map +1 -1
  257. package/dist/gs/syscall/index.d.ts +80 -0
  258. package/dist/gs/syscall/index.js +169 -0
  259. package/dist/gs/syscall/index.js.map +1 -0
  260. package/dist/gs/unsafe/unsafe.js.map +1 -1
  261. package/gs/builtin/slice.ts +2 -1
  262. package/gs/github.com/pkg/errors/errors.ts +408 -238
  263. package/gs/github.com/pkg/errors/go113.ts +5 -6
  264. package/gs/github.com/pkg/errors/index.ts +12 -3
  265. package/gs/github.com/pkg/errors/stack.ts +107 -105
  266. package/gs/internal/abi/index.ts +37 -0
  267. package/gs/internal/bytealg/index.ts +34 -0
  268. package/gs/internal/byteorder/index.ts +40 -0
  269. package/gs/math/abs.gs.test.ts +1 -1
  270. package/gs/math/acosh.gs.test.ts +4 -2
  271. package/gs/math/asin.gs.test.ts +1 -1
  272. package/gs/math/asinh.gs.test.ts +7 -3
  273. package/gs/math/atan.gs.test.ts +1 -1
  274. package/gs/math/atan2.gs.test.ts +17 -9
  275. package/gs/math/atanh.gs.test.ts +1 -1
  276. package/gs/math/bits.gs.test.ts +1 -1
  277. package/gs/math/cbrt.gs.test.ts +1 -1
  278. package/gs/math/const.gs.test.ts +34 -8
  279. package/gs/math/copysign.gs.test.ts +7 -3
  280. package/gs/math/dim.gs.test.ts +19 -7
  281. package/gs/math/erf.gs.test.ts +1 -1
  282. package/gs/math/erfinv.gs.test.ts +4 -2
  283. package/gs/math/exp.gs.test.ts +1 -1
  284. package/gs/math/expm1.gs.test.ts +6 -4
  285. package/gs/math/floor.gs.test.ts +17 -4
  286. package/gs/math/fma.gs.test.ts +53 -53
  287. package/gs/math/frexp.gs.test.ts +112 -117
  288. package/gs/math/gamma.gs.test.ts +1 -1
  289. package/gs/math/hypot.gs.test.ts +53 -53
  290. package/gs/math/index.ts +80 -44
  291. package/gs/math/j0.gs.test.ts +6 -2
  292. package/gs/math/j1.gs.test.ts +6 -2
  293. package/gs/math/jn.gs.test.ts +9 -5
  294. package/gs/math/ldexp.gs.test.ts +103 -86
  295. package/gs/math/lgamma.gs.test.ts +10 -10
  296. package/gs/math/log.gs.test.ts +1 -1
  297. package/gs/math/log10.gs.test.ts +1 -1
  298. package/gs/math/log1p.gs.test.ts +2 -2
  299. package/gs/math/logb.gs.test.ts +1 -1
  300. package/gs/math/mod.gs.test.ts +2 -2
  301. package/gs/math/modf.gs.test.ts +7 -7
  302. package/gs/math/nextafter.gs.test.ts +9 -7
  303. package/gs/math/pow.gs.test.ts +6 -4
  304. package/gs/math/pow10.gs.test.ts +1 -1
  305. package/gs/math/remainder.gs.test.ts +1 -1
  306. package/gs/math/signbit.gs.test.ts +1 -1
  307. package/gs/math/sin.gs.test.ts +1 -1
  308. package/gs/math/sincos.gs.test.ts +33 -14
  309. package/gs/math/sinh.gs.test.ts +1 -1
  310. package/gs/math/sqrt.gs.test.ts +1 -1
  311. package/gs/math/tan.gs.test.ts +3 -3
  312. package/gs/math/tanh.gs.test.ts +1 -1
  313. package/gs/os/dir.gs.ts +42 -0
  314. package/gs/os/dir_unix.gs.ts +155 -0
  315. package/gs/os/dirent_js.gs.ts +27 -0
  316. package/gs/os/env.gs.ts +179 -0
  317. package/gs/os/error.gs.ts +205 -0
  318. package/gs/os/error_errno.gs.ts +12 -0
  319. package/gs/os/exec.gs.ts +198 -0
  320. package/gs/os/exec_nohandle.gs.ts +2 -0
  321. package/gs/os/exec_posix.gs.ts +95 -0
  322. package/gs/os/exec_unix.gs.ts +64 -0
  323. package/gs/os/executable.gs.ts +18 -0
  324. package/gs/os/executable_js.gs.ts +6 -0
  325. package/gs/os/executable_wasm.gs.ts +10 -0
  326. package/gs/os/file_constants_js.gs.ts +98 -0
  327. package/gs/os/file_js.gs.ts +99 -0
  328. package/gs/os/file_open_unix.gs.ts +15 -0
  329. package/gs/os/file_posix_js.gs.ts +40 -0
  330. package/gs/os/file_unix_js.gs.ts +94 -0
  331. package/gs/os/getwd_js.gs.ts +28 -0
  332. package/gs/os/index.ts +128 -0
  333. package/gs/os/path.gs.ts +35 -0
  334. package/gs/os/path_unix.gs.ts +49 -0
  335. package/gs/os/pidfd_js.gs.ts +25 -0
  336. package/gs/os/pipe_wasm.gs.ts +17 -0
  337. package/gs/os/proc.gs.ts +84 -0
  338. package/gs/os/proc_js.gs.ts +15 -0
  339. package/gs/os/rawconn_js.gs.ts +30 -0
  340. package/gs/os/removeall_js.gs.ts +9 -0
  341. package/gs/os/root_js.gs.ts +111 -0
  342. package/gs/os/root_nonwindows.gs.ts +6 -0
  343. package/gs/os/root_noopenat.gs.ts +45 -0
  344. package/gs/os/stat.gs.ts +38 -0
  345. package/gs/os/stat_js.gs.ts +30 -0
  346. package/gs/os/stat_unix_js.gs.ts +27 -0
  347. package/gs/os/sticky_bsd.gs.ts +4 -0
  348. package/gs/os/sys.gs.ts +12 -0
  349. package/gs/os/sys_bsd.gs.ts +17 -0
  350. package/gs/os/sys_js.gs.ts +9 -0
  351. package/gs/os/tempfile.gs.ts +34 -0
  352. package/gs/os/types.gs.ts +170 -0
  353. package/gs/os/types_js.gs.ts +205 -0
  354. package/gs/os/types_unix.gs.ts +118 -0
  355. package/gs/os/wait_unimp.gs.ts +2 -0
  356. package/gs/os/zero_copy_posix.gs.ts +35 -0
  357. package/gs/os/zero_copy_stub.gs.ts +4 -0
  358. package/gs/reflect/ANALYSIS.md +278 -0
  359. package/gs/reflect/deepequal.ts +154 -0
  360. package/gs/reflect/function-types.test.ts +146 -0
  361. package/gs/reflect/godoc.txt +67 -0
  362. package/gs/reflect/index.ts +83 -0
  363. package/gs/reflect/iter.ts +44 -0
  364. package/gs/reflect/map.ts +81 -0
  365. package/gs/reflect/swapper.ts +52 -0
  366. package/gs/reflect/type.ts +1012 -0
  367. package/gs/reflect/types.ts +214 -0
  368. package/gs/reflect/value.ts +264 -0
  369. package/gs/reflect/visiblefields.ts +173 -0
  370. package/gs/strconv/index.ts +39 -6
  371. package/gs/strings/index.ts +7 -1
  372. package/gs/strings/replace.ts +1 -9
  373. package/gs/sync/atomic/index.ts +53 -4
  374. package/gs/syscall/index.ts +212 -0
  375. package/gs/unsafe/unsafe.ts +1 -1
  376. package/package.json +2 -1
@@ -0,0 +1,205 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+
3
+ // import * as poll from "@goscript/internal/poll/index.js" // Not available in JavaScript
4
+
5
+ import * as fs from "@goscript/io/fs/index.js"
6
+
7
+ // ErrInvalid indicates an invalid argument.
8
+ // Methods on File will return this error when the receiver is nil.
9
+ // "invalid argument"
10
+ export let ErrInvalid: $.GoError = fs.ErrInvalid
11
+
12
+ // "permission denied"
13
+ export let ErrPermission: $.GoError = fs.ErrPermission
14
+
15
+ // "file already exists"
16
+ export let ErrExist: $.GoError = fs.ErrExist
17
+
18
+ // "file does not exist"
19
+ export let ErrNotExist: $.GoError = fs.ErrNotExist
20
+
21
+ // "file already closed"
22
+ export let ErrClosed: $.GoError = fs.ErrClosed
23
+
24
+ // "file type does not support deadline"
25
+ export let ErrNoDeadline: $.GoError = errNoDeadline()
26
+
27
+ // "i/o timeout"
28
+ export let ErrDeadlineExceeded: $.GoError = errDeadlineExceeded()
29
+
30
+ // "operation not implemented in JavaScript environment"
31
+ export let ErrUnimplemented: $.GoError = {
32
+ Error: () => "operation not implemented in JavaScript environment"
33
+ }
34
+
35
+ export function errNoDeadline(): $.GoError {
36
+ return {Error: () => "file type does not support deadline"}
37
+ }
38
+
39
+ // errDeadlineExceeded returns the value for os.ErrDeadlineExceeded.
40
+ // This error comes from the internal/poll package, which is also
41
+ // used by package net. Doing it this way ensures that the net
42
+ // package will return os.ErrDeadlineExceeded for an exceeded deadline,
43
+ // as documented by net.Conn.SetDeadline, without requiring any extra
44
+ // work in the net package and without requiring the internal/poll
45
+ // package to import os (which it can't, because that would be circular).
46
+ export function errDeadlineExceeded(): $.GoError {
47
+ return {Error: () => "i/o timeout"}
48
+ }
49
+
50
+ type timeout = null | {
51
+ Timeout(): boolean
52
+ }
53
+
54
+ $.registerInterfaceType(
55
+ 'timeout',
56
+ null, // Zero value for interface is null
57
+ [{ name: "Timeout", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "boolean" } }] }]
58
+ );
59
+
60
+ export type PathError = fs.PathError;
61
+ export const PathError = null as any;
62
+
63
+ export class SyscallError {
64
+ public get Syscall(): string {
65
+ return this._fields.Syscall.value
66
+ }
67
+ public set Syscall(value: string) {
68
+ this._fields.Syscall.value = value
69
+ }
70
+
71
+ public get Err(): $.GoError {
72
+ return this._fields.Err.value
73
+ }
74
+ public set Err(value: $.GoError) {
75
+ this._fields.Err.value = value
76
+ }
77
+
78
+ public _fields: {
79
+ Syscall: $.VarRef<string>;
80
+ Err: $.VarRef<$.GoError>;
81
+ }
82
+
83
+ constructor(init?: Partial<{Err?: $.GoError, Syscall?: string}>) {
84
+ this._fields = {
85
+ Syscall: $.varRef(init?.Syscall ?? ""),
86
+ Err: $.varRef(init?.Err ?? null)
87
+ }
88
+ }
89
+
90
+ public clone(): SyscallError {
91
+ const cloned = new SyscallError()
92
+ cloned._fields = {
93
+ Syscall: $.varRef(this._fields.Syscall.value),
94
+ Err: $.varRef(this._fields.Err.value)
95
+ }
96
+ return cloned
97
+ }
98
+
99
+ public Error(): string {
100
+ const e = this
101
+ return e.Syscall + ": " + e.Err!.Error()
102
+ }
103
+
104
+ public Unwrap(): $.GoError {
105
+ const e = this
106
+ return e.Err
107
+ }
108
+
109
+ // Timeout reports whether this error represents a timeout.
110
+ public Timeout(): boolean {
111
+ const e = this
112
+ let { value: t, ok: ok } = $.typeAssert<timeout>(e.Err, 'timeout')
113
+ return ok && t!.Timeout()
114
+ }
115
+
116
+ // Register this type with the runtime type system
117
+ static __typeInfo = $.registerStructType(
118
+ 'SyscallError',
119
+ new SyscallError(),
120
+ [{ name: "Error", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "string" } }] }, { name: "Unwrap", args: [], returns: [{ type: { kind: $.TypeKind.Interface, name: 'GoError', methods: [{ name: 'Error', args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: 'string' } }] }] } }] }, { name: "Timeout", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "boolean" } }] }],
121
+ SyscallError,
122
+ {"Syscall": { kind: $.TypeKind.Basic, name: "string" }, "Err": { kind: $.TypeKind.Interface, name: 'GoError', methods: [{ name: 'Error', args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: 'string' } }] }] }}
123
+ );
124
+ }
125
+
126
+ // NewSyscallError returns, as an error, a new [SyscallError]
127
+ // with the given system call name and error details.
128
+ // As a convenience, if err is nil, NewSyscallError returns nil.
129
+ export function NewSyscallError(syscall: string, err: $.GoError): $.GoError {
130
+ if (err == null) {
131
+ return null
132
+ }
133
+ return new SyscallError({})
134
+ }
135
+
136
+ // IsExist returns a boolean indicating whether its argument is known to report
137
+ // that a file or directory already exists. It is satisfied by [ErrExist] as
138
+ // well as some syscall errors.
139
+ //
140
+ // This function predates [errors.Is]. It only supports errors returned by
141
+ // the os package. New code should use errors.Is(err, fs.ErrExist).
142
+ export function IsExist(err: $.GoError): boolean {
143
+ return underlyingErrorIs(err, ErrExist)
144
+ }
145
+
146
+ // IsNotExist returns a boolean indicating whether its argument is known to
147
+ // report that a file or directory does not exist. It is satisfied by
148
+ // [ErrNotExist] as well as some syscall errors.
149
+ //
150
+ // This function predates [errors.Is]. It only supports errors returned by
151
+ // the os package. New code should use errors.Is(err, fs.ErrNotExist).
152
+ export function IsNotExist(err: $.GoError): boolean {
153
+ return underlyingErrorIs(err, ErrNotExist)
154
+ }
155
+
156
+ // IsPermission returns a boolean indicating whether its argument is known to
157
+ // report that permission is denied. It is satisfied by [ErrPermission] as well
158
+ // as some syscall errors.
159
+ //
160
+ // This function predates [errors.Is]. It only supports errors returned by
161
+ // the os package. New code should use errors.Is(err, fs.ErrPermission).
162
+ export function IsPermission(err: $.GoError): boolean {
163
+ return underlyingErrorIs(err, ErrPermission)
164
+ }
165
+
166
+ // IsTimeout returns a boolean indicating whether its argument is known
167
+ // to report that a timeout occurred.
168
+ //
169
+ // This function predates [errors.Is], and the notion of whether an
170
+ // error indicates a timeout can be ambiguous. For example, the Unix
171
+ // error EWOULDBLOCK sometimes indicates a timeout and sometimes does not.
172
+ // New code should use errors.Is with a value appropriate to the call
173
+ // returning the error, such as [os.ErrDeadlineExceeded].
174
+ export function IsTimeout(err: $.GoError): boolean {
175
+ let { value: terr, ok: ok } = $.typeAssert<timeout>(underlyingError(err), 'timeout')
176
+ return ok && terr!.Timeout()
177
+ }
178
+
179
+ export function underlyingErrorIs(err: $.GoError, target: $.GoError): boolean {
180
+ // Note that this function is not errors.Is:
181
+ // underlyingError only unwraps the specific error-wrapping types
182
+ // that it historically did, not all errors implementing Unwrap().
183
+ err = underlyingError(err)
184
+ if (err == target) {
185
+ return true
186
+ }
187
+ // To preserve prior behavior, only examine syscall errors.
188
+ let { value: e, ok: ok } = $.typeAssert<any>(err, 'syscallErrorType')
189
+ return ok && e.Is(target)
190
+ }
191
+
192
+ // underlyingError returns the underlying error for known os error types.
193
+ export function underlyingError(err: $.GoError): $.GoError {
194
+ $.typeSwitch(err, [{ types: [{kind: $.TypeKind.Pointer, elemType: 'PathError'}], body: (err) => {
195
+ return err!.Err
196
+ }},
197
+ { types: [{kind: $.TypeKind.Pointer, elemType: 'LinkError'}], body: (err) => {
198
+ return err!.Err
199
+ }},
200
+ { types: [{kind: $.TypeKind.Pointer, elemType: 'SyscallError'}], body: (err) => {
201
+ return err!.Err
202
+ }}])
203
+ return err
204
+ }
205
+
@@ -0,0 +1,12 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+
3
+ import * as syscall from "@goscript/syscall/index.js"
4
+
5
+ type syscallErrorType = syscall.Errno;
6
+
7
+ let errENOSYS: syscall.Errno = syscall.ENOSYS
8
+
9
+ let errERANGE: syscall.Errno = syscall.ERANGE
10
+
11
+ let errENOMEM: syscall.Errno = syscall.ENOMEM
12
+
@@ -0,0 +1,198 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+ import { ErrUnimplemented } from "./error.gs.js";
3
+
4
+ import * as errors from "@goscript/errors/index.js"
5
+ import * as syscall from "@goscript/syscall/index.js"
6
+
7
+ export let ErrProcessDone: $.GoError = errors.New("os: process already finished")
8
+
9
+ // Simplified Process class for JavaScript environment
10
+ export class Process {
11
+ public get Pid(): number {
12
+ return this._fields.Pid.value
13
+ }
14
+ public set Pid(value: number) {
15
+ this._fields.Pid.value = value
16
+ }
17
+
18
+ public _fields: {
19
+ Pid: $.VarRef<number>;
20
+ }
21
+
22
+ constructor(init?: Partial<{Pid?: number}>) {
23
+ this._fields = {
24
+ Pid: $.varRef(init?.Pid ?? -1)
25
+ }
26
+ }
27
+
28
+ public clone(): Process {
29
+ const cloned = new Process()
30
+ cloned._fields = {
31
+ Pid: $.varRef(this._fields.Pid.value)
32
+ }
33
+ return cloned
34
+ }
35
+
36
+ // All process operations return ErrUnimplemented in JavaScript
37
+ public Release(): $.GoError {
38
+ return ErrUnimplemented
39
+ }
40
+
41
+ public Kill(): $.GoError {
42
+ return ErrUnimplemented
43
+ }
44
+
45
+ public Wait(): [ProcessState | null, $.GoError] {
46
+ return [null, ErrUnimplemented]
47
+ }
48
+
49
+ public Signal(sig: Signal): $.GoError {
50
+ return ErrUnimplemented
51
+ }
52
+
53
+ // Register this type with the runtime type system
54
+ static __typeInfo = $.registerStructType(
55
+ 'Process',
56
+ new Process(),
57
+ [
58
+ { name: "Release", args: [], returns: [{ type: { kind: $.TypeKind.Interface, name: 'GoError', methods: [{ name: 'Error', args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: 'string' } }] }] } }] },
59
+ { name: "Kill", args: [], returns: [{ type: { kind: $.TypeKind.Interface, name: 'GoError', methods: [{ name: 'Error', args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: 'string' } }] }] } }] },
60
+ { name: "Wait", args: [], returns: [{ type: { kind: $.TypeKind.Pointer, elemType: "ProcessState" } }, { type: { kind: $.TypeKind.Interface, name: 'GoError', methods: [{ name: 'Error', args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: 'string' } }] }] } }] },
61
+ { name: "Signal", args: [{ name: "sig", type: "Signal" }], returns: [{ type: { kind: $.TypeKind.Interface, name: 'GoError', methods: [{ name: 'Error', args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: 'string' } }] }] } }] }
62
+ ],
63
+ Process,
64
+ { "Pid": { kind: $.TypeKind.Basic, name: "number" } }
65
+ );
66
+ }
67
+
68
+ // Simplified ProcAttr class for JavaScript environment
69
+ export class ProcAttr {
70
+ public get Dir(): string {
71
+ return this._fields.Dir.value
72
+ }
73
+ public set Dir(value: string) {
74
+ this._fields.Dir.value = value
75
+ }
76
+
77
+ public get Env(): $.Slice<string> {
78
+ return this._fields.Env.value
79
+ }
80
+ public set Env(value: $.Slice<string>) {
81
+ this._fields.Env.value = value
82
+ }
83
+
84
+ public get Files(): $.Slice<any> {
85
+ return this._fields.Files.value
86
+ }
87
+ public set Files(value: $.Slice<any>) {
88
+ this._fields.Files.value = value
89
+ }
90
+
91
+ public get Sys(): any {
92
+ return this._fields.Sys.value
93
+ }
94
+ public set Sys(value: any) {
95
+ this._fields.Sys.value = value
96
+ }
97
+
98
+ public _fields: {
99
+ Dir: $.VarRef<string>;
100
+ Env: $.VarRef<$.Slice<string>>;
101
+ Files: $.VarRef<$.Slice<any>>;
102
+ Sys: $.VarRef<any>;
103
+ }
104
+
105
+ constructor(init?: Partial<{Dir?: string, Env?: $.Slice<string>, Files?: $.Slice<any>, Sys?: any}>) {
106
+ this._fields = {
107
+ Dir: $.varRef(init?.Dir ?? ""),
108
+ Env: $.varRef(init?.Env ?? null),
109
+ Files: $.varRef(init?.Files ?? null),
110
+ Sys: $.varRef(init?.Sys ?? null)
111
+ }
112
+ }
113
+
114
+ public clone(): ProcAttr {
115
+ const cloned = new ProcAttr()
116
+ cloned._fields = {
117
+ Dir: $.varRef(this._fields.Dir.value),
118
+ Env: $.varRef(this._fields.Env.value),
119
+ Files: $.varRef(this._fields.Files.value),
120
+ Sys: $.varRef(this._fields.Sys.value)
121
+ }
122
+ return cloned
123
+ }
124
+
125
+ // Register this type with the runtime type system
126
+ static __typeInfo = $.registerStructType(
127
+ 'ProcAttr',
128
+ new ProcAttr(),
129
+ [],
130
+ ProcAttr,
131
+ {
132
+ "Dir": { kind: $.TypeKind.Basic, name: "string" },
133
+ "Env": { kind: $.TypeKind.Slice, elemType: { kind: $.TypeKind.Basic, name: "string" } },
134
+ "Files": { kind: $.TypeKind.Slice, elemType: { kind: $.TypeKind.Basic, name: "any" } },
135
+ "Sys": { kind: $.TypeKind.Basic, name: "any" }
136
+ }
137
+ );
138
+ }
139
+
140
+ // Stub ProcessState for JavaScript environment
141
+ export class ProcessState {
142
+ public _fields: {}
143
+
144
+ constructor() {
145
+ this._fields = {}
146
+ }
147
+
148
+ public clone(): ProcessState {
149
+ return new ProcessState()
150
+ }
151
+
152
+ // Register this type with the runtime type system
153
+ static __typeInfo = $.registerStructType(
154
+ 'ProcessState',
155
+ new ProcessState(),
156
+ [],
157
+ ProcessState,
158
+ {}
159
+ );
160
+ }
161
+
162
+ // Signal interface stub
163
+ export type Signal = null | {
164
+ Signal(): void
165
+ String(): string
166
+ }
167
+ export const Signal = null as any;
168
+
169
+ // Stub functions that return ErrUnimplemented
170
+ export function Getpid(): number {
171
+ return -1 // Not available in JavaScript
172
+ }
173
+
174
+ export function Getppid(): number {
175
+ return -1 // Not available in JavaScript
176
+ }
177
+
178
+ export function FindProcess(pid: number): [Process | null, $.GoError] {
179
+ return [null, ErrUnimplemented]
180
+ }
181
+
182
+ export function StartProcess(name: string, argv: $.Slice<string>, attr: ProcAttr | null): [Process | null, $.GoError] {
183
+ return [null, ErrUnimplemented]
184
+ }
185
+
186
+ // Internal functions used by exec_unix.gs.ts
187
+ export function newDoneProcess(pid: number): Process {
188
+ return new Process({Pid: pid})
189
+ }
190
+
191
+ export function newHandleProcess(pid: number, handle: number): Process {
192
+ return new Process({Pid: pid})
193
+ }
194
+
195
+ export function newPIDProcess(pid: number): Process {
196
+ return new Process({Pid: pid})
197
+ }
198
+
@@ -0,0 +1,2 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+
@@ -0,0 +1,95 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+ import { Signal } from "./exec.gs.js";
3
+ import { ErrUnimplemented } from "./error.gs.js";
4
+
5
+ import * as syscall from "@goscript/syscall/index.js"
6
+
7
+ // Signal constants for JavaScript environment
8
+ export let Interrupt: Signal = null // syscall.SIGINT not available in JavaScript
9
+
10
+ export let Kill: Signal = null // syscall.SIGKILL not available in JavaScript
11
+
12
+ // Simplified ProcessState for JavaScript environment
13
+ export class ProcessState {
14
+ public get pid(): number {
15
+ return this._fields.pid.value
16
+ }
17
+ public set pid(value: number) {
18
+ this._fields.pid.value = value
19
+ }
20
+
21
+ public _fields: {
22
+ pid: $.VarRef<number>;
23
+ }
24
+
25
+ constructor(init?: Partial<{pid?: number}>) {
26
+ this._fields = {
27
+ pid: $.varRef(init?.pid ?? -1)
28
+ }
29
+ }
30
+
31
+ public clone(): ProcessState {
32
+ const cloned = new ProcessState()
33
+ cloned._fields = {
34
+ pid: $.varRef(this._fields.pid.value)
35
+ }
36
+ return cloned
37
+ }
38
+
39
+ // All methods return stub values for JavaScript environment
40
+ public UserTime(): any {
41
+ return 0 // Duration not available
42
+ }
43
+
44
+ public SystemTime(): any {
45
+ return 0 // Duration not available
46
+ }
47
+
48
+ public Exited(): boolean {
49
+ return false
50
+ }
51
+
52
+ public Success(): boolean {
53
+ return false
54
+ }
55
+
56
+ public Sys(): null | any {
57
+ return null
58
+ }
59
+
60
+ public SysUsage(): null | any {
61
+ return null
62
+ }
63
+
64
+ public Pid(): number {
65
+ return this.pid
66
+ }
67
+
68
+ public String(): string {
69
+ return `exit status ${this.pid}`
70
+ }
71
+
72
+ public ExitCode(): number {
73
+ return -1
74
+ }
75
+
76
+ // Register this type with the runtime type system
77
+ static __typeInfo = $.registerStructType(
78
+ 'ProcessState',
79
+ new ProcessState(),
80
+ [
81
+ { name: "UserTime", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "any" } }] },
82
+ { name: "SystemTime", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "any" } }] },
83
+ { name: "Exited", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "boolean" } }] },
84
+ { name: "Success", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "boolean" } }] },
85
+ { name: "Sys", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "any" } }] },
86
+ { name: "SysUsage", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "any" } }] },
87
+ { name: "Pid", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "number" } }] },
88
+ { name: "String", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "string" } }] },
89
+ { name: "ExitCode", args: [], returns: [{ type: { kind: $.TypeKind.Basic, name: "number" } }] }
90
+ ],
91
+ ProcessState,
92
+ { "pid": { kind: $.TypeKind.Basic, name: "number" } }
93
+ );
94
+ }
95
+
@@ -0,0 +1,64 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+ import { NewSyscallError, ErrUnimplemented } from "./error.gs.js";
3
+ import { newDoneProcess, newHandleProcess, newPIDProcess, Process, ErrProcessDone } from "./exec.gs.js";
4
+
5
+ import * as errors from "@goscript/errors/index.js"
6
+
7
+ import * as runtime from "@goscript/runtime/index.js"
8
+
9
+ import * as syscall from "@goscript/syscall/index.js"
10
+
11
+ import * as time from "@goscript/time/index.js"
12
+
13
+ // Import uintptr type
14
+ type uintptr = syscall.uintptr
15
+
16
+ // Stub functions for JavaScript environment
17
+ function ignoringEINTR2(fn: any, arg1: any, arg2: any): [any, $.GoError] {
18
+ return [null, ErrUnimplemented]
19
+ }
20
+
21
+ function pidfdFind(pid: number): [uintptr, $.GoError] {
22
+ return [0, ErrUnimplemented]
23
+ }
24
+
25
+ // Special values for Process.Pid.
26
+ let pidUnset: number = 0
27
+
28
+ let pidReleased: number = -1
29
+
30
+ export function convertESRCH(err: $.GoError): $.GoError {
31
+ if (err == syscall.ESRCH) {
32
+ return ErrProcessDone
33
+ }
34
+ return err
35
+ }
36
+
37
+ export function findProcess(pid: number): [Process | null, $.GoError] {
38
+ let p: Process | null = null
39
+ let err: $.GoError = null
40
+ {
41
+ let h: uintptr
42
+ [h, err] = pidfdFind(pid)
43
+
44
+ // We can't return an error here since users are not expecting
45
+ // it. Instead, return a process with a "done" state already
46
+ // and let a subsequent Signal or Wait call catch that.
47
+
48
+ // Ignore other errors from pidfdFind, as the callers
49
+ // do not expect them. Fall back to using the PID.
50
+ if (err == ErrProcessDone) {
51
+ // We can't return an error here since users are not expecting
52
+ // it. Instead, return a process with a "done" state already
53
+ // and let a subsequent Signal or Wait call catch that.
54
+ return [newDoneProcess(pid), null]
55
+ } else if (err != null) {
56
+ // Ignore other errors from pidfdFind, as the callers
57
+ // do not expect them. Fall back to using the PID.
58
+ return [newPIDProcess(pid), null]
59
+ }
60
+ // Use the handle.
61
+ return [newHandleProcess(pid, h), null]
62
+ }
63
+ }
64
+
@@ -0,0 +1,18 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+ import { executable } from "./executable_js.gs.js";
3
+
4
+ // Executable returns the path name for the executable that started
5
+ // the current process. There is no guarantee that the path is still
6
+ // pointing to the correct executable. If a symlink was used to start
7
+ // the process, depending on the operating system, the result might
8
+ // be the symlink or the path it pointed to. If a stable result is
9
+ // needed, [path/filepath.EvalSymlinks] might help.
10
+ //
11
+ // Executable returns an absolute path unless an error occurred.
12
+ //
13
+ // The main use case is finding resources located relative to an
14
+ // executable.
15
+ export function Executable(): [string, $.GoError] {
16
+ return executable()
17
+ }
18
+
@@ -0,0 +1,6 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+ import { ErrUnimplemented } from "./error.gs.js";
3
+
4
+ export function executable(): [string, $.GoError] {
5
+ return ["", ErrUnimplemented]
6
+ }
@@ -0,0 +1,10 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+
3
+ import * as errors from "@goscript/errors/index.js"
4
+
5
+ import * as runtime from "@goscript/runtime/index.js"
6
+
7
+ export function executable(): [string, $.GoError] {
8
+ return ["", errors.New("Executable not implemented for " + runtime.GOOS)]
9
+ }
10
+