goscript 0.0.35 → 0.0.37

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 (228) hide show
  1. package/compiler/expr-call.go +26 -0
  2. package/compiler/spec-struct.go +41 -8
  3. package/compiler/spec-value.go +4 -0
  4. package/compiler/spec.go +1 -1
  5. package/compiler/stmt.go +26 -8
  6. package/dist/gs/internal/byteorder/index.d.ts +8 -0
  7. package/dist/gs/internal/byteorder/index.js +34 -0
  8. package/dist/gs/internal/byteorder/index.js.map +1 -0
  9. package/dist/gs/internal/testlog/index.d.ts +1 -0
  10. package/dist/gs/internal/testlog/index.js +5 -0
  11. package/dist/gs/internal/testlog/index.js.map +1 -0
  12. package/dist/gs/maps/iter.d.ts +1 -1
  13. package/dist/gs/os/dir.gs.d.ts +6 -0
  14. package/dist/gs/os/dir.gs.js +35 -0
  15. package/dist/gs/os/dir.gs.js.map +1 -0
  16. package/dist/gs/os/dir_unix.gs.d.ts +7 -0
  17. package/dist/gs/os/dir_unix.gs.js +113 -0
  18. package/dist/gs/os/dir_unix.gs.js.map +1 -0
  19. package/dist/gs/os/dirent_js.gs.d.ts +5 -0
  20. package/dist/gs/os/dirent_js.gs.js +20 -0
  21. package/dist/gs/os/dirent_js.gs.js.map +1 -0
  22. package/dist/gs/os/env.gs.d.ts +12 -0
  23. package/dist/gs/os/env.gs.js +157 -0
  24. package/dist/gs/os/env.gs.js.map +1 -0
  25. package/dist/gs/os/error.gs.d.ts +40 -0
  26. package/dist/gs/os/error.gs.js +158 -0
  27. package/dist/gs/os/error.gs.js.map +1 -0
  28. package/dist/gs/os/error_errno.gs.d.ts +1 -0
  29. package/dist/gs/os/error_errno.gs.js +5 -0
  30. package/dist/gs/os/error_errno.gs.js.map +1 -0
  31. package/dist/gs/os/exec.gs.d.ts +60 -0
  32. package/dist/gs/os/exec.gs.js +136 -0
  33. package/dist/gs/os/exec.gs.js.map +1 -0
  34. package/dist/gs/os/exec_nohandle.gs.d.ts +1 -0
  35. package/dist/gs/os/exec_nohandle.gs.js +2 -0
  36. package/dist/gs/os/exec_nohandle.gs.js.map +1 -0
  37. package/dist/gs/os/exec_posix.gs.d.ts +25 -0
  38. package/dist/gs/os/exec_posix.gs.js +67 -0
  39. package/dist/gs/os/exec_posix.gs.js.map +1 -0
  40. package/dist/gs/os/exec_unix.gs.d.ts +4 -0
  41. package/dist/gs/os/exec_unix.gs.js +46 -0
  42. package/dist/gs/os/exec_unix.gs.js.map +1 -0
  43. package/dist/gs/os/executable.gs.d.ts +2 -0
  44. package/dist/gs/os/executable.gs.js +16 -0
  45. package/dist/gs/os/executable.gs.js.map +1 -0
  46. package/dist/gs/os/executable_js.gs.d.ts +2 -0
  47. package/dist/gs/os/executable_js.gs.js +5 -0
  48. package/dist/gs/os/executable_js.gs.js.map +1 -0
  49. package/dist/gs/os/executable_wasm.gs.d.ts +2 -0
  50. package/dist/gs/os/executable_wasm.gs.js +6 -0
  51. package/dist/gs/os/executable_wasm.gs.js.map +1 -0
  52. package/dist/gs/os/file_constants_js.gs.d.ts +41 -0
  53. package/dist/gs/os/file_constants_js.gs.js +78 -0
  54. package/dist/gs/os/file_constants_js.gs.js.map +1 -0
  55. package/dist/gs/os/file_js.gs.d.ts +22 -0
  56. package/dist/gs/os/file_js.gs.js +73 -0
  57. package/dist/gs/os/file_js.gs.js.map +1 -0
  58. package/dist/gs/os/file_open_unix.gs.d.ts +6 -0
  59. package/dist/gs/os/file_open_unix.gs.js +10 -0
  60. package/dist/gs/os/file_open_unix.gs.js.map +1 -0
  61. package/dist/gs/os/file_posix_js.gs.d.ts +8 -0
  62. package/dist/gs/os/file_posix_js.gs.js +32 -0
  63. package/dist/gs/os/file_posix_js.gs.js.map +1 -0
  64. package/dist/gs/os/file_unix_js.gs.d.ts +27 -0
  65. package/dist/gs/os/file_unix_js.gs.js +64 -0
  66. package/dist/gs/os/file_unix_js.gs.js.map +1 -0
  67. package/dist/gs/os/getwd_js.gs.d.ts +6 -0
  68. package/dist/gs/os/getwd_js.gs.js +21 -0
  69. package/dist/gs/os/getwd_js.gs.js.map +1 -0
  70. package/dist/gs/os/index.d.ts +19 -0
  71. package/dist/gs/os/index.js +20 -0
  72. package/dist/gs/os/index.js.map +1 -0
  73. package/dist/gs/os/path.gs.d.ts +4 -0
  74. package/dist/gs/os/path.gs.js +32 -0
  75. package/dist/gs/os/path.gs.js.map +1 -0
  76. package/dist/gs/os/path_unix.gs.d.ts +4 -0
  77. package/dist/gs/os/path_unix.gs.js +40 -0
  78. package/dist/gs/os/path_unix.gs.js.map +1 -0
  79. package/dist/gs/os/pidfd_js.gs.d.ts +6 -0
  80. package/dist/gs/os/pidfd_js.gs.js +14 -0
  81. package/dist/gs/os/pidfd_js.gs.js.map +1 -0
  82. package/dist/gs/os/pipe_wasm.gs.d.ts +2 -0
  83. package/dist/gs/os/pipe_wasm.gs.js +14 -0
  84. package/dist/gs/os/pipe_wasm.gs.js.map +1 -0
  85. package/dist/gs/os/proc.gs.d.ts +11 -0
  86. package/dist/gs/os/proc.gs.js +68 -0
  87. package/dist/gs/os/proc.gs.js.map +1 -0
  88. package/dist/gs/os/proc_js.gs.d.ts +3 -0
  89. package/dist/gs/os/proc_js.gs.js +12 -0
  90. package/dist/gs/os/proc_js.gs.js.map +1 -0
  91. package/dist/gs/os/rawconn_js.gs.d.ts +10 -0
  92. package/dist/gs/os/rawconn_js.gs.js +26 -0
  93. package/dist/gs/os/rawconn_js.gs.js.map +1 -0
  94. package/dist/gs/os/removeall_js.gs.d.ts +2 -0
  95. package/dist/gs/os/removeall_js.gs.js +7 -0
  96. package/dist/gs/os/removeall_js.gs.js.map +1 -0
  97. package/dist/gs/os/root_js.gs.d.ts +23 -0
  98. package/dist/gs/os/root_js.gs.js +80 -0
  99. package/dist/gs/os/root_js.gs.js.map +1 -0
  100. package/dist/gs/os/root_nonwindows.gs.d.ts +2 -0
  101. package/dist/gs/os/root_nonwindows.gs.js +4 -0
  102. package/dist/gs/os/root_nonwindows.gs.js.map +1 -0
  103. package/dist/gs/os/root_noopenat.gs.d.ts +11 -0
  104. package/dist/gs/os/root_noopenat.gs.js +31 -0
  105. package/dist/gs/os/root_noopenat.gs.js.map +1 -0
  106. package/dist/gs/os/stat.gs.d.ts +24 -0
  107. package/dist/gs/os/stat.gs.js +20 -0
  108. package/dist/gs/os/stat.gs.js.map +1 -0
  109. package/dist/gs/os/stat_js.gs.d.ts +6 -0
  110. package/dist/gs/os/stat_js.gs.js +23 -0
  111. package/dist/gs/os/stat_js.gs.js.map +1 -0
  112. package/dist/gs/os/stat_unix_js.gs.d.ts +8 -0
  113. package/dist/gs/os/stat_unix_js.gs.js +16 -0
  114. package/dist/gs/os/stat_unix_js.gs.js.map +1 -0
  115. package/dist/gs/os/sticky_bsd.gs.d.ts +1 -0
  116. package/dist/gs/os/sticky_bsd.gs.js +3 -0
  117. package/dist/gs/os/sticky_bsd.gs.js.map +1 -0
  118. package/dist/gs/os/sys.gs.d.ts +2 -0
  119. package/dist/gs/os/sys.gs.js +10 -0
  120. package/dist/gs/os/sys.gs.js.map +1 -0
  121. package/dist/gs/os/sys_bsd.gs.d.ts +2 -0
  122. package/dist/gs/os/sys_bsd.gs.js +15 -0
  123. package/dist/gs/os/sys_bsd.gs.js.map +1 -0
  124. package/dist/gs/os/sys_js.gs.d.ts +2 -0
  125. package/dist/gs/os/sys_js.gs.js +6 -0
  126. package/dist/gs/os/sys_js.gs.js.map +1 -0
  127. package/dist/gs/os/tempfile.gs.d.ts +5 -0
  128. package/dist/gs/os/tempfile.gs.js +30 -0
  129. package/dist/gs/os/tempfile.gs.js.map +1 -0
  130. package/dist/gs/os/types.gs.d.ts +59 -0
  131. package/dist/gs/os/types.gs.js +123 -0
  132. package/dist/gs/os/types.gs.js.map +1 -0
  133. package/dist/gs/os/types_js.gs.d.ts +74 -0
  134. package/dist/gs/os/types_js.gs.js +147 -0
  135. package/dist/gs/os/types_js.gs.js.map +1 -0
  136. package/dist/gs/os/types_unix.gs.d.ts +40 -0
  137. package/dist/gs/os/types_unix.gs.js +87 -0
  138. package/dist/gs/os/types_unix.gs.js.map +1 -0
  139. package/dist/gs/os/wait_unimp.gs.d.ts +1 -0
  140. package/dist/gs/os/wait_unimp.gs.js +2 -0
  141. package/dist/gs/os/wait_unimp.gs.js.map +1 -0
  142. package/dist/gs/os/zero_copy_posix.gs.d.ts +4 -0
  143. package/dist/gs/os/zero_copy_posix.gs.js +27 -0
  144. package/dist/gs/os/zero_copy_posix.gs.js.map +1 -0
  145. package/dist/gs/os/zero_copy_stub.gs.d.ts +1 -0
  146. package/dist/gs/os/zero_copy_stub.gs.js +2 -0
  147. package/dist/gs/os/zero_copy_stub.gs.js.map +1 -0
  148. package/dist/gs/sync/atomic/doc.gs.d.ts +28 -0
  149. package/dist/gs/sync/atomic/doc.gs.js +265 -0
  150. package/dist/gs/sync/atomic/doc.gs.js.map +1 -0
  151. package/dist/gs/sync/atomic/doc_64.gs.d.ts +15 -0
  152. package/dist/gs/sync/atomic/doc_64.gs.js +165 -0
  153. package/dist/gs/sync/atomic/doc_64.gs.js.map +1 -0
  154. package/dist/gs/sync/atomic/index.d.ts +4 -0
  155. package/dist/gs/sync/atomic/index.js +5 -0
  156. package/dist/gs/sync/atomic/index.js.map +1 -0
  157. package/dist/gs/sync/atomic/type.gs.d.ts +130 -0
  158. package/dist/gs/sync/atomic/type.gs.js +433 -0
  159. package/dist/gs/sync/atomic/type.gs.js.map +1 -0
  160. package/dist/gs/sync/atomic/value.gs.d.ts +19 -0
  161. package/dist/gs/sync/atomic/value.gs.js +116 -0
  162. package/dist/gs/sync/atomic/value.gs.js.map +1 -0
  163. package/dist/gs/syscall/index.d.ts +80 -0
  164. package/dist/gs/syscall/index.js +163 -0
  165. package/dist/gs/syscall/index.js.map +1 -0
  166. package/dist/gs/unsafe/unsafe.d.ts +1 -0
  167. package/dist/gs/unsafe/unsafe.js +5 -0
  168. package/dist/gs/unsafe/unsafe.js.map +1 -1
  169. package/gs/internal/byteorder/index.ts +40 -0
  170. package/gs/internal/testlog/index.ts +7 -0
  171. package/gs/maps/iter.ts +1 -1
  172. package/gs/math/erfinv.gs.test.ts +2 -2
  173. package/gs/math/fma.gs.test.ts +5 -5
  174. package/gs/math/ldexp.gs.test.ts +5 -5
  175. package/gs/math/lgamma.gs.test.ts +2 -2
  176. package/gs/os/dir.gs.ts +42 -0
  177. package/gs/os/dir_unix.gs.ts +155 -0
  178. package/gs/os/dirent_js.gs.ts +27 -0
  179. package/gs/os/env.gs.ts +179 -0
  180. package/gs/os/error.gs.ts +205 -0
  181. package/gs/os/error_errno.gs.ts +12 -0
  182. package/gs/os/exec.gs.ts +198 -0
  183. package/gs/os/exec_nohandle.gs.ts +2 -0
  184. package/gs/os/exec_posix.gs.ts +95 -0
  185. package/gs/os/exec_unix.gs.ts +64 -0
  186. package/gs/os/executable.gs.ts +18 -0
  187. package/gs/os/executable_js.gs.ts +6 -0
  188. package/gs/os/executable_wasm.gs.ts +10 -0
  189. package/gs/os/file_constants_js.gs.ts +98 -0
  190. package/gs/os/file_js.gs.ts +99 -0
  191. package/gs/os/file_open_unix.gs.ts +15 -0
  192. package/gs/os/file_posix_js.gs.ts +40 -0
  193. package/gs/os/file_unix_js.gs.ts +94 -0
  194. package/gs/os/getwd_js.gs.ts +28 -0
  195. package/gs/os/index.ts +19 -0
  196. package/gs/os/path.gs.ts +35 -0
  197. package/gs/os/path_unix.gs.ts +49 -0
  198. package/gs/os/pidfd_js.gs.ts +25 -0
  199. package/gs/os/pipe_wasm.gs.ts +17 -0
  200. package/gs/os/proc.gs.ts +84 -0
  201. package/gs/os/proc_js.gs.ts +15 -0
  202. package/gs/os/rawconn_js.gs.ts +30 -0
  203. package/gs/os/removeall_js.gs.ts +9 -0
  204. package/gs/os/root_js.gs.ts +111 -0
  205. package/gs/os/root_nonwindows.gs.ts +6 -0
  206. package/gs/os/root_noopenat.gs.ts +45 -0
  207. package/gs/os/stat.gs.ts +38 -0
  208. package/gs/os/stat_js.gs.ts +30 -0
  209. package/gs/os/stat_unix_js.gs.ts +27 -0
  210. package/gs/os/sticky_bsd.gs.ts +4 -0
  211. package/gs/os/sys.gs.ts +12 -0
  212. package/gs/os/sys_bsd.gs.ts +17 -0
  213. package/gs/os/sys_js.gs.ts +9 -0
  214. package/gs/os/tempfile.gs.ts +34 -0
  215. package/gs/os/types.gs.ts +170 -0
  216. package/gs/os/types_js.gs.ts +205 -0
  217. package/gs/os/types_unix.gs.ts +118 -0
  218. package/gs/os/wait_unimp.gs.ts +2 -0
  219. package/gs/os/zero_copy_posix.gs.ts +35 -0
  220. package/gs/os/zero_copy_stub.gs.ts +4 -0
  221. package/gs/sync/atomic/doc.gs.ts +276 -0
  222. package/gs/sync/atomic/doc_64.gs.ts +168 -0
  223. package/gs/sync/atomic/index.ts +4 -0
  224. package/gs/sync/atomic/type.gs.ts +596 -0
  225. package/gs/sync/atomic/value.gs.ts +158 -0
  226. package/gs/syscall/index.ts +204 -0
  227. package/gs/unsafe/unsafe.ts +6 -0
  228. package/package.json +1 -1
@@ -1120,9 +1120,22 @@ func (c *GoToTSCompiler) WriteCallExpr(exp *ast.CallExpr) error {
1120
1120
  if i != 0 {
1121
1121
  c.tsw.WriteLiterally(", ")
1122
1122
  }
1123
+ // Check if this is the last argument and we have ellipsis (variadic call)
1124
+ if exp.Ellipsis != token.NoPos && i == len(exp.Args)-1 {
1125
+ c.tsw.WriteLiterally("...")
1126
+ }
1123
1127
  if err := c.WriteValueExpr(arg); err != nil {
1124
1128
  return fmt.Errorf("failed to write argument %d in call: %w", i, err)
1125
1129
  }
1130
+ // Add non-null assertion for spread arguments that might be null
1131
+ if exp.Ellipsis != token.NoPos && i == len(exp.Args)-1 {
1132
+ // Check if the argument type is potentially nullable (slice)
1133
+ if argType := c.pkg.TypesInfo.TypeOf(arg); argType != nil {
1134
+ if _, isSlice := argType.Underlying().(*types.Slice); isSlice {
1135
+ c.tsw.WriteLiterally("!")
1136
+ }
1137
+ }
1138
+ }
1126
1139
  }
1127
1140
  c.tsw.WriteLiterally(")")
1128
1141
  return nil // Handled regular function call
@@ -1206,9 +1219,22 @@ func (c *GoToTSCompiler) WriteCallExpr(exp *ast.CallExpr) error {
1206
1219
  if i != 0 {
1207
1220
  c.tsw.WriteLiterally(", ")
1208
1221
  }
1222
+ // Check if this is the last argument and we have ellipsis (variadic call)
1223
+ if exp.Ellipsis != token.NoPos && i == len(exp.Args)-1 {
1224
+ c.tsw.WriteLiterally("...")
1225
+ }
1209
1226
  if err := c.WriteValueExpr(arg); err != nil {
1210
1227
  return fmt.Errorf("failed to write argument %d in call: %w", i, err)
1211
1228
  }
1229
+ // Add non-null assertion for spread arguments that might be null
1230
+ if exp.Ellipsis != token.NoPos && i == len(exp.Args)-1 {
1231
+ // Check if the argument type is potentially nullable (slice)
1232
+ if argType := c.pkg.TypesInfo.TypeOf(arg); argType != nil {
1233
+ if _, isSlice := argType.Underlying().(*types.Slice); isSlice {
1234
+ c.tsw.WriteLiterally("!")
1235
+ }
1236
+ }
1237
+ }
1212
1238
  }
1213
1239
  c.tsw.WriteLiterally(")")
1214
1240
  return nil
@@ -56,6 +56,10 @@ func (c *GoToTSCompiler) WriteStructTypeSpec(a *ast.TypeSpec, t *ast.StructType)
56
56
  }
57
57
  for _, name := range field.Names {
58
58
  fieldName := name.Name
59
+ // Skip underscore fields
60
+ if fieldName == "_" {
61
+ continue
62
+ }
59
63
  fieldType := c.pkg.TypesInfo.TypeOf(field.Type)
60
64
  if fieldType == nil {
61
65
  fieldType = types.Typ[types.Invalid]
@@ -86,6 +90,10 @@ func (c *GoToTSCompiler) WriteStructTypeSpec(a *ast.TypeSpec, t *ast.StructType)
86
90
  } else {
87
91
  fieldKeyName = field.Name()
88
92
  }
93
+ // Skip underscore fields
94
+ if fieldKeyName == "_" {
95
+ continue
96
+ }
89
97
  fieldTsType := c.getTypeString(field.Type())
90
98
  c.tsw.WriteLinef("%s: $.VarRef<%s>;", fieldKeyName, fieldTsType)
91
99
  }
@@ -105,6 +113,7 @@ func (c *GoToTSCompiler) WriteStructTypeSpec(a *ast.TypeSpec, t *ast.StructType)
105
113
  c.tsw.WriteLine("")
106
114
  c.tsw.Indent(1)
107
115
 
116
+ firstFieldWritten := false
108
117
  for i := range numFields {
109
118
  field := underlyingStruct.Field(i)
110
119
  fieldType := field.Type()
@@ -115,13 +124,20 @@ func (c *GoToTSCompiler) WriteStructTypeSpec(a *ast.TypeSpec, t *ast.StructType)
115
124
  fieldKeyName = field.Name()
116
125
  }
117
126
 
118
- c.writeVarRefedFieldInitializer(fieldKeyName, fieldType, field.Anonymous())
127
+ // Skip underscore fields
128
+ if fieldKeyName == "_" {
129
+ continue
130
+ }
119
131
 
120
- if i < numFields-1 {
132
+ if firstFieldWritten {
121
133
  c.tsw.WriteLine(",")
122
- } else {
123
- c.tsw.WriteLine("")
124
134
  }
135
+
136
+ c.writeVarRefedFieldInitializer(fieldKeyName, fieldType, field.Anonymous())
137
+ firstFieldWritten = true
138
+ }
139
+ if firstFieldWritten {
140
+ c.tsw.WriteLine("")
125
141
  }
126
142
  c.tsw.Indent(-1)
127
143
  }
@@ -154,6 +170,7 @@ func (c *GoToTSCompiler) WriteStructTypeSpec(a *ast.TypeSpec, t *ast.StructType)
154
170
  c.tsw.WriteLine("cloned._fields = {")
155
171
  c.tsw.Indent(1)
156
172
 
173
+ firstFieldWritten := false
157
174
  for i := range numFields {
158
175
  field := underlyingStruct.Field(i)
159
176
  fieldType := field.Type()
@@ -164,13 +181,20 @@ func (c *GoToTSCompiler) WriteStructTypeSpec(a *ast.TypeSpec, t *ast.StructType)
164
181
  fieldKeyName = field.Name()
165
182
  }
166
183
 
167
- c.writeClonedFieldInitializer(fieldKeyName, fieldType, field.Anonymous())
184
+ // Skip underscore fields
185
+ if fieldKeyName == "_" {
186
+ continue
187
+ }
168
188
 
169
- if i < numFields-1 {
189
+ if firstFieldWritten {
170
190
  c.tsw.WriteLine(",")
171
- } else {
172
- c.tsw.WriteLine("")
173
191
  }
192
+
193
+ c.writeClonedFieldInitializer(fieldKeyName, fieldType, field.Anonymous())
194
+ firstFieldWritten = true
195
+ }
196
+ if firstFieldWritten {
197
+ c.tsw.WriteLine("")
174
198
  }
175
199
 
176
200
  c.tsw.Indent(-1)
@@ -402,6 +426,10 @@ func (c *GoToTSCompiler) WriteStructTypeSpec(a *ast.TypeSpec, t *ast.StructType)
402
426
  } else {
403
427
  fieldKeyName = field.Name()
404
428
  }
429
+ // Skip underscore fields
430
+ if fieldKeyName == "_" {
431
+ continue
432
+ }
405
433
  // fieldTsType := c.getTypeString(field.Type())
406
434
  if !firstField {
407
435
  c.tsw.WriteLiterally(", ")
@@ -451,6 +479,11 @@ func (c *GoToTSCompiler) generateFlattenedInitTypeString(structType *types.Named
451
479
  field := underlying.Field(i)
452
480
  fieldName := field.Name()
453
481
 
482
+ // Skip underscore fields
483
+ if fieldName == "_" {
484
+ continue
485
+ }
486
+
454
487
  if !field.Exported() && field.Pkg() != c.pkg.Types {
455
488
  continue
456
489
  }
@@ -41,6 +41,10 @@ func (c *GoToTSCompiler) WriteValueSpec(a *ast.ValueSpec) error {
41
41
  // Handle single variable declaration
42
42
  if len(a.Names) == 1 {
43
43
  name := a.Names[0]
44
+ // Skip underscore variables
45
+ if name.Name == "_" {
46
+ return nil
47
+ }
44
48
  obj := c.pkg.TypesInfo.Defs[name]
45
49
  if obj == nil {
46
50
  return fmt.Errorf("could not resolve type: %v", name)
package/compiler/spec.go CHANGED
@@ -95,7 +95,7 @@ func (c *GoToTSCompiler) writeVarRefedFieldInitializer(fieldName string, fieldTy
95
95
  if named, ok := fieldType.(*types.Named); ok {
96
96
  if _, isStruct := named.Underlying().(*types.Struct); isStruct {
97
97
  isStructValueType = true
98
- structTypeNameForClone = named.Obj().Name()
98
+ structTypeNameForClone = c.getTypeString(fieldType)
99
99
  }
100
100
  }
101
101
 
package/compiler/stmt.go CHANGED
@@ -170,10 +170,16 @@ func (c *GoToTSCompiler) WriteStmtBranch(stmt *ast.BranchStmt) error {
170
170
  c.tsw.WriteLine("break") // No semicolon needed
171
171
  case token.CONTINUE:
172
172
  c.tsw.WriteLine("continue") // No semicolon needed
173
+ case token.GOTO:
174
+ // TypeScript doesn't support goto, but we can handle it by skipping it
175
+ // since the labeled statement restructuring should handle the control flow
176
+ c.tsw.WriteCommentLinef("goto %s // goto statement skipped", stmt.Label.Name)
177
+ case token.FALLTHROUGH:
178
+ // Fallthrough is handled in switch statements, should not appear elsewhere
179
+ c.tsw.WriteCommentLinef("fallthrough // fallthrough statement skipped")
173
180
  default:
174
181
  // This case should ideally not be reached if the Go parser is correct,
175
182
  // as ast.BranchStmt only covers break, continue, goto, fallthrough.
176
- // 'goto' and 'fallthrough' are handled elsewhere or not supported.
177
183
  c.tsw.WriteCommentLinef("unhandled branch statement token: %s", stmt.Tok.String())
178
184
  }
179
185
  return nil
@@ -855,17 +861,29 @@ func (c *GoToTSCompiler) WriteStmtDefer(exp *ast.DeferStmt) error {
855
861
  // WriteStmtLabeled handles labeled statements (ast.LabeledStmt), such as "label: statement".
856
862
  // In TypeScript, labels cannot be used with variable declarations, so we need to handle this case specially.
857
863
  func (c *GoToTSCompiler) WriteStmtLabeled(stmt *ast.LabeledStmt) error {
858
- // Check if the labeled statement is a declaration statement
859
- if declStmt, ok := stmt.Stmt.(*ast.DeclStmt); ok {
860
- // For declaration statements, we need to put the label on a separate line
864
+ // Check if the labeled statement is a declaration statement or assignment with :=
865
+ needsBlock := false
866
+ if _, ok := stmt.Stmt.(*ast.DeclStmt); ok {
867
+ needsBlock = true
868
+ } else if assignStmt, ok := stmt.Stmt.(*ast.AssignStmt); ok && assignStmt.Tok == token.DEFINE {
869
+ // Assignment with := is also a declaration and needs special handling
870
+ needsBlock = true
871
+ }
872
+
873
+ if needsBlock {
874
+ // For declaration statements and := assignments, we need to put the label on a separate line
861
875
  // because TypeScript doesn't allow labels with declarations
862
876
  c.tsw.WriteLiterally(stmt.Label.Name)
863
- c.tsw.WriteLine(": {}")
877
+ c.tsw.WriteLine(": {")
878
+ c.tsw.Indent(1)
864
879
 
865
- // Write the declaration statement without the label
866
- if err := c.WriteStmt(declStmt); err != nil {
867
- return fmt.Errorf("failed to write labeled declaration statement: %w", err)
880
+ // Write the statement without the label
881
+ if err := c.WriteStmt(stmt.Stmt); err != nil {
882
+ return fmt.Errorf("failed to write labeled declaration/assignment statement: %w", err)
868
883
  }
884
+
885
+ c.tsw.Indent(-1)
886
+ c.tsw.WriteLine("}")
869
887
  } else {
870
888
  // For non-declaration statements, write the label normally
871
889
  c.tsw.WriteLiterally(stmt.Label.Name)
@@ -0,0 +1,8 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+ export declare function LittleEndian(): boolean;
3
+ export declare function BEUint16(b: $.Bytes): number;
4
+ export declare function BEUint32(b: $.Bytes): number;
5
+ export declare function BEUint64(b: $.Bytes): number;
6
+ export declare function LEUint16(b: $.Bytes): number;
7
+ export declare function LEUint32(b: $.Bytes): number;
8
+ export declare function LEUint64(b: $.Bytes): number;
@@ -0,0 +1,34 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+ // Stub implementations for internal/byteorder package
3
+ export function LittleEndian() {
4
+ return true; // Assume little endian for JS
5
+ }
6
+ // Big Endian byte order functions
7
+ export function BEUint16(b) {
8
+ return (b[0] << 8) | b[1];
9
+ }
10
+ export function BEUint32(b) {
11
+ return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3];
12
+ }
13
+ export function BEUint64(b) {
14
+ // JavaScript numbers are 64-bit floats, so we'll lose precision for very large integers
15
+ // For our stub purposes, this should be sufficient
16
+ let high = BEUint32(b);
17
+ let low = BEUint32($.goSlice(b, 4, undefined));
18
+ return (high * 0x100000000) + low;
19
+ }
20
+ // Little Endian byte order functions
21
+ export function LEUint16(b) {
22
+ return b[0] | (b[1] << 8);
23
+ }
24
+ export function LEUint32(b) {
25
+ return b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24);
26
+ }
27
+ export function LEUint64(b) {
28
+ // JavaScript numbers are 64-bit floats, so we'll lose precision for very large integers
29
+ // For our stub purposes, this should be sufficient
30
+ let low = LEUint32(b);
31
+ let high = LEUint32($.goSlice(b, 4, undefined));
32
+ return low + (high * 0x100000000);
33
+ }
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../gs/internal/byteorder/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,8BAA8B,CAAC;AAElD,sDAAsD;AACtD,MAAM,UAAU,YAAY;IAC1B,OAAO,IAAI,CAAA,CAAC,8BAA8B;AAC5C,CAAC;AAED,kCAAkC;AAClC,MAAM,UAAU,QAAQ,CAAC,CAAU;IACjC,OAAO,CAAC,CAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAE,CAAC,CAAC,CAAC,CAAA;AAC7B,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,CAAU;IACjC,OAAO,CAAC,CAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAE,CAAC,CAAC,CAAC,CAAA;AAC7D,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,CAAU;IACjC,wFAAwF;IACxF,mDAAmD;IACnD,IAAI,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IACtB,IAAI,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC,CAAA;IAC9C,OAAO,CAAC,IAAI,GAAG,WAAW,CAAC,GAAG,GAAG,CAAA;AACnC,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,QAAQ,CAAC,CAAU;IACjC,OAAO,CAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA;AAC7B,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,CAAU;IACjC,OAAO,CAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAA;AAC7D,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,CAAU;IACjC,wFAAwF;IACxF,mDAAmD;IACnD,IAAI,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IACrB,IAAI,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC,CAAA;IAC/C,OAAO,GAAG,GAAG,CAAC,IAAI,GAAG,WAAW,CAAC,CAAA;AACnC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function Getenv(key: string): void;
@@ -0,0 +1,5 @@
1
+ // Stub implementations for internal/testlog package
2
+ export function Getenv(key) {
3
+ // Stub for test logging - no-op in runtime
4
+ }
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../gs/internal/testlog/index.ts"],"names":[],"mappings":"AAEA,oDAAoD;AAEpD,MAAM,UAAU,MAAM,CAAC,GAAW;IAChC,2CAA2C;AAC7C,CAAC"}
@@ -4,4 +4,4 @@ export declare function All<K extends $.Comparable, V>(m: Map<K, V>): iter.Seq2<
4
4
  export declare function Keys<K extends $.Comparable, V>(m: Map<K, V>): iter.Seq<K>;
5
5
  export declare function Values<K extends $.Comparable, V>(m: Map<K, V>): iter.Seq<V>;
6
6
  export declare function Insert<K extends $.Comparable, V>(m: Map<K, V>, seq: iter.Seq2<K, V>): void;
7
- export declare function Collect<K extends $.Comparable, V extends any>(seq: iter.Seq2<K, V>): Map<K, V>;
7
+ export declare function Collect<K extends $.Comparable, V>(seq: iter.Seq2<K, V>): Map<K, V>;
@@ -0,0 +1,6 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+ import * as fs from "@goscript/io/fs/index.js";
3
+ type DirEntry = fs.DirEntry;
4
+ export declare function ReadDir(name: string): [$.Slice<DirEntry>, $.GoError];
5
+ export declare function CopyFS(dir: string, fsys: fs.FS): $.GoError;
6
+ export {};
@@ -0,0 +1,35 @@
1
+ import { ErrUnimplemented } from "./error.gs.js";
2
+ // ReadDir reads the named directory,
3
+ // returning all its directory entries sorted by filename.
4
+ // If an error occurs reading the directory,
5
+ // ReadDir returns the entries it was able to read before the error,
6
+ // along with the error.
7
+ export function ReadDir(name) {
8
+ // Directory reading not supported in JavaScript environment
9
+ return [null, ErrUnimplemented];
10
+ }
11
+ // CopyFS copies the file system fsys into the directory dir,
12
+ // creating dir if necessary.
13
+ //
14
+ // Files are created with mode 0o666 plus any execute permissions
15
+ // from the source, and directories are created with mode 0o777
16
+ // (before umask).
17
+ //
18
+ // CopyFS will not overwrite existing files. If a file name in fsys
19
+ // already exists in the destination, CopyFS will return an error
20
+ // such that errors.Is(err, fs.ErrExist) will be true.
21
+ //
22
+ // Symbolic links in fsys are not supported. A *PathError with Err set
23
+ // to ErrInvalid is returned when copying from a symbolic link.
24
+ //
25
+ // Symbolic links in dir are followed.
26
+ //
27
+ // New files added to fsys (including if dir is a subdirectory of fsys)
28
+ // while CopyFS is running are not guaranteed to be copied.
29
+ //
30
+ // Copying stops at and returns the first error encountered.
31
+ export function CopyFS(dir, fsys) {
32
+ // File system copying not supported in JavaScript environment
33
+ return ErrUnimplemented;
34
+ }
35
+ //# sourceMappingURL=dir.gs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dir.gs.js","sourceRoot":"","sources":["../../../gs/os/dir.gs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAMjD,qCAAqC;AACrC,0DAA0D;AAC1D,4CAA4C;AAC5C,oEAAoE;AACpE,wBAAwB;AACxB,MAAM,UAAU,OAAO,CAAC,IAAY;IACnC,4DAA4D;IAC5D,OAAO,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAA;AAChC,CAAC;AAED,6DAA6D;AAC7D,6BAA6B;AAC7B,EAAE;AACF,iEAAiE;AACjE,+DAA+D;AAC/D,kBAAkB;AAClB,EAAE;AACF,mEAAmE;AACnE,iEAAiE;AACjE,sDAAsD;AACtD,EAAE;AACF,sEAAsE;AACtE,+DAA+D;AAC/D,EAAE;AACF,sCAAsC;AACtC,EAAE;AACF,uEAAuE;AACvE,2DAA2D;AAC3D,EAAE;AACF,4DAA4D;AAC5D,MAAM,UAAU,MAAM,CAAC,GAAW,EAAE,IAAW;IAC9C,8DAA8D;IAC9D,OAAO,gBAAgB,CAAA;AACxB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+ import * as syscall from "@goscript/syscall/index.js";
3
+ type uintptr = syscall.uintptr;
4
+ export declare function readInt(b: $.Bytes, off: uintptr, size: uintptr): [number, boolean];
5
+ export declare function readIntBE(b: $.Bytes, size: uintptr): number;
6
+ export declare function readIntLE(b: $.Bytes, size: uintptr): number;
7
+ export {};
@@ -0,0 +1,113 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+ import * as byteorder from "@goscript/internal/byteorder/index.js";
3
+ import * as goarch from "@goscript/internal/goarch/index.js";
4
+ import * as sync from "@goscript/sync/index.js";
5
+ class dirInfo {
6
+ get mu() {
7
+ return this._fields.mu.value;
8
+ }
9
+ set mu(value) {
10
+ this._fields.mu.value = value;
11
+ }
12
+ // buffer for directory I/O
13
+ get buf() {
14
+ return this._fields.buf.value;
15
+ }
16
+ set buf(value) {
17
+ this._fields.buf.value = value;
18
+ }
19
+ // length of buf; return value from Getdirentries
20
+ get nbuf() {
21
+ return this._fields.nbuf.value;
22
+ }
23
+ set nbuf(value) {
24
+ this._fields.nbuf.value = value;
25
+ }
26
+ // location of next record in buf.
27
+ get bufp() {
28
+ return this._fields.bufp.value;
29
+ }
30
+ set bufp(value) {
31
+ this._fields.bufp.value = value;
32
+ }
33
+ _fields;
34
+ constructor(init) {
35
+ this._fields = {
36
+ mu: $.varRef(init?.mu?.clone() ?? new sync.Mutex()),
37
+ buf: $.varRef(init?.buf ?? null),
38
+ nbuf: $.varRef(init?.nbuf ?? 0),
39
+ bufp: $.varRef(init?.bufp ?? 0)
40
+ };
41
+ }
42
+ clone() {
43
+ const cloned = new dirInfo();
44
+ cloned._fields = {
45
+ mu: $.varRef(this._fields.mu.value?.clone() ?? null),
46
+ buf: $.varRef(this._fields.buf.value),
47
+ nbuf: $.varRef(this._fields.nbuf.value),
48
+ bufp: $.varRef(this._fields.bufp.value)
49
+ };
50
+ return cloned;
51
+ }
52
+ close() {
53
+ const d = this;
54
+ if (d.buf != null) {
55
+ dirBufPool.Put(d.buf);
56
+ d.buf = null;
57
+ }
58
+ }
59
+ // Register this type with the runtime type system
60
+ static __typeInfo = $.registerStructType('dirInfo', new dirInfo(), [{ name: "close", args: [], returns: [] }], dirInfo, { "mu": "Mutex", "buf": { kind: $.TypeKind.Pointer, elemType: { kind: $.TypeKind.Slice, elemType: { kind: $.TypeKind.Basic, name: "number" } } }, "nbuf": { kind: $.TypeKind.Basic, name: "number" }, "bufp": { kind: $.TypeKind.Basic, name: "number" } });
61
+ }
62
+ // More than 5760 to work around https://golang.org/issue/24015.
63
+ let blockSize = 8192;
64
+ let dirBufPool = new sync.Pool({ New: () => {
65
+ // The buffer must be at least a block long.
66
+ let buf = new Uint8Array(8192);
67
+ return buf;
68
+ } });
69
+ // readInt returns the size-bytes unsigned integer in native byte order at offset off.
70
+ export function readInt(b, off, size) {
71
+ let u = 0;
72
+ let ok = false;
73
+ {
74
+ if ($.len(b) < $.int(off + size)) {
75
+ return [0, false];
76
+ }
77
+ if (goarch.BigEndian) {
78
+ return [readIntBE($.goSlice(b, off, undefined), size), true];
79
+ }
80
+ return [readIntLE($.goSlice(b, off, undefined), size), true];
81
+ }
82
+ }
83
+ export function readIntBE(b, size) {
84
+ switch (size) {
85
+ case 1:
86
+ return b[0];
87
+ case 2:
88
+ return byteorder.BEUint16(b);
89
+ case 4:
90
+ return byteorder.BEUint32(b);
91
+ case 8:
92
+ return byteorder.BEUint64(b);
93
+ default:
94
+ $.panic("syscall: readInt with unsupported size");
95
+ return 0; // This line will never be reached due to panic, but satisfies TypeScript
96
+ }
97
+ }
98
+ export function readIntLE(b, size) {
99
+ switch (size) {
100
+ case 1:
101
+ return b[0];
102
+ case 2:
103
+ return byteorder.LEUint16(b);
104
+ case 4:
105
+ return byteorder.LEUint32(b);
106
+ case 8:
107
+ return byteorder.LEUint64(b);
108
+ default:
109
+ $.panic("syscall: readInt with unsupported size");
110
+ return 0; // This line will never be reached due to panic, but satisfies TypeScript
111
+ }
112
+ }
113
+ //# sourceMappingURL=dir_unix.gs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dir_unix.gs.js","sourceRoot":"","sources":["../../../gs/os/dir_unix.gs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,8BAA8B,CAAC;AAKlD,OAAO,KAAK,SAAS,MAAM,uCAAuC,CAAA;AAElE,OAAO,KAAK,MAAM,MAAM,oCAAoC,CAAA;AAM5D,OAAO,KAAK,IAAI,MAAM,yBAAyB,CAAA;AAS/C,MAAM,OAAO;IACZ,IAAW,EAAE;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAA;IAC7B,CAAC;IACD,IAAW,EAAE,CAAC,KAAiB;QAC9B,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,GAAG,KAAK,CAAA;IAC9B,CAAC;IAED,2BAA2B;IAC3B,IAAW,GAAG;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAA;IAC9B,CAAC;IACD,IAAW,GAAG,CAAC,KAA+B;QAC7C,IAA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ACC,CAAC,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAA;YACjD,OAAO,CAAC,CAAA,CAAC,yEAAyE;IACpF,CAAC;AACF,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,CAAU,EAAE,IAAa;IAClD,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,CAAC;YACL,OAAQ,CAAE,CAAC,CAAC,CAAY,CAAA;QACzB,KAAK,CAAC;YACL,OAAQ,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAY,CAAA;QACzC,KAAK,CAAC;YACL,OAAQ,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAY,CAAA;QACzC,KAAK,CAAC;YACL,OAAQ,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAY,CAAA;QACzC;YACC,CAAC,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAA;YACjD,OAAO,CAAC,CAAA,CAAC,yEAAyE;IACpF,CAAC;AACF,CAAC"}
@@ -0,0 +1,5 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+ export declare function direntIno(buf: $.Bytes): [number, boolean];
3
+ export declare function direntReclen(buf: $.Bytes): [number, boolean];
4
+ export declare function direntNamlen(buf: $.Bytes): [number, boolean];
5
+ export declare function direntType(buf: $.Bytes): number;
@@ -0,0 +1,20 @@
1
+ import { readInt } from "./dir_unix.gs.js";
2
+ import * as syscall from "@goscript/syscall/index.js";
3
+ import * as unsafe from "@goscript/unsafe/index.js";
4
+ export function direntIno(buf) {
5
+ return [1, true];
6
+ }
7
+ export function direntReclen(buf) {
8
+ return readInt(buf, unsafe.Offsetof(new syscall.Dirent({}).Reclen), unsafe.Sizeof(new syscall.Dirent({}).Reclen));
9
+ }
10
+ export function direntNamlen(buf) {
11
+ let [reclen, ok] = direntReclen(buf);
12
+ if (!ok) {
13
+ return [0, false];
14
+ }
15
+ return [reclen - unsafe.Offsetof(new syscall.Dirent({}).Name), true];
16
+ }
17
+ export function direntType(buf) {
18
+ return ~0;
19
+ }
20
+ //# sourceMappingURL=dirent_js.gs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dirent_js.gs.js","sourceRoot":"","sources":["../../../gs/os/dirent_js.gs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,KAAK,OAAO,MAAM,4BAA4B,CAAA;AAErD,OAAO,KAAK,MAAM,MAAM,2BAA2B,CAAA;AAEnD,MAAM,UAAU,SAAS,CAAC,GAAY;IACrC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAAA;AACjB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAY;IACxC,OAAO,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;AAClH,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAY;IACxC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,CAAA;IACpC,IAAI,CAAC,EAAE,EAAE,CAAC;QACT,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;IAClB,CAAC;IACD,OAAO,CAAC,MAAM,GAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,IAAI,CAAY,EAAE,IAAI,CAAC,CAAA;AACjF,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,GAAY;IACtC,OAAO,CAAE,CAAY,CAAA;AACtB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import * as $ from "@goscript/builtin/builtin.js";
2
+ export declare function Expand(s: string, mapping: ((p0: string) => string) | null): string;
3
+ export declare function ExpandEnv(s: string): string;
4
+ export declare function isShellSpecialVar(c: number): boolean;
5
+ export declare function isAlphaNum(c: number): boolean;
6
+ export declare function getShellName(s: string): [string, number];
7
+ export declare function Getenv(key: string): string;
8
+ export declare function LookupEnv(key: string): [string, boolean];
9
+ export declare function Setenv(key: string, value: string): $.GoError;
10
+ export declare function Unsetenv(key: string): $.GoError;
11
+ export declare function Clearenv(): void;
12
+ export declare function Environ(): $.Slice<string>;