├── .cursor ├── .github ├── renovate.json └── workflows │ ├── codeql-analysis.yml │ ├── dependency-review.yml │ └── tests.yml ├── .gitignore ├── .ignore ├── .npmignore ├── .prettierignore ├── .prettierrc.yaml ├── .roo ├── mcp.json └── rules │ ├── compliance.txt │ ├── design-patterns.txt │ ├── project-index.txt │ └── project-info.txt ├── .rooignore ├── .roomodes ├── .vscode ├── extensions.json ├── launch.json └── settings.json ├── .windsurf ├── rules │ ├── project-index.md │ └── project-info.md └── workflows │ └── iterate-compliance.md ├── LICENSE ├── README.md ├── REFACTOR_CALL_EXPR.md ├── cmd └── goscript │ ├── .gitignore │ ├── cmd_compile.go │ ├── deps.go │ ├── main.go │ └── main.js ├── compiler ├── analysis.go ├── analysis_test.go ├── assignment.go ├── builtin_test.go ├── code-writer.go ├── compiler.go ├── compiler_test.go ├── composite-lit.go ├── config.go ├── config_test.go ├── decl.go ├── expr-call-async.go ├── expr-call-builtins.go ├── expr-call-helpers.go ├── expr-call-make.go ├── expr-call-type-conversion.go ├── expr-call.go ├── expr-selector.go ├── expr-star.go ├── expr-type.go ├── expr-value.go ├── expr.go ├── field.go ├── gs_dependencies_test.go ├── index.test.ts ├── index.ts ├── lit.go ├── output.go ├── primitive.go ├── protobuf.go ├── sanitize.go ├── spec-struct.go ├── spec-value.go ├── spec.go ├── stmt-assign.go ├── stmt-for.go ├── stmt-range.go ├── stmt-select.go ├── stmt-type-switch.go ├── stmt.go ├── type-assert.go ├── type-info.go └── type.go ├── compliance ├── .gitignore ├── .ignore ├── COMPLIANCE.md ├── WIP.md ├── compliance.go ├── deps │ └── github.com │ │ └── aperturerobotics │ │ └── util │ │ ├── broadcast │ │ ├── broadcast.gs.ts │ │ └── index.ts │ │ └── csync │ │ ├── index.ts │ │ ├── mutex.gs.ts │ │ └── rwmutex.gs.ts └── tests │ ├── array_literal │ ├── array_literal.go │ ├── array_literal.gs.ts │ ├── expected.log │ └── index.ts │ ├── assign_op │ ├── assign_op.go │ ├── assign_op.gs.ts │ ├── expected.log │ └── index.ts │ ├── async_basic │ ├── async_basic.go │ ├── async_basic.gs.ts │ ├── expected.log │ └── index.ts │ ├── async_defer_statement │ ├── async_defer_statement.go │ ├── async_defer_statement.gs.ts │ ├── expected.log │ └── index.ts │ ├── atomic_struct_field_init │ ├── atomic_struct_field_init.go │ ├── atomic_struct_field_init.gs.ts │ ├── expected.log │ └── index.ts │ ├── basic_arithmetic │ ├── basic_arithmetic.go │ ├── basic_arithmetic.gs.ts │ ├── expected.log │ └── index.ts │ ├── bitwise_and_not_assignment │ ├── bitwise_and_not_assignment.go │ ├── bitwise_and_not_assignment.gs.ts │ ├── expected.log │ └── index.ts │ ├── block_comments │ ├── block_comments.go │ ├── block_comments.gs.ts │ ├── expected.log │ └── index.ts │ ├── boolean_logic │ ├── boolean_logic.go │ ├── boolean_logic.gs.ts │ ├── expected.log │ └── index.ts │ ├── buffer_value_field_error │ ├── buffer_value_field_error.go │ ├── buffer_value_field_error.gs.ts │ ├── expected.log │ └── index.ts │ ├── build_tags │ ├── build_tags.go │ ├── build_tags.gs.ts │ ├── build_tags_darwin.go │ ├── build_tags_generic.go │ ├── build_tags_generic.gs.ts │ ├── build_tags_js.go │ ├── build_tags_js.gs.ts │ ├── build_tags_other.go │ ├── build_tags_windows.go │ ├── expected.log │ └── index.ts │ ├── bytes │ ├── bytes.go │ ├── bytes.gs.ts │ ├── expected.log │ └── index.ts │ ├── chan_type_assertion │ ├── chan_type_assertion.go │ ├── chan_type_assertion.gs.ts │ ├── expected.log │ └── index.ts │ ├── channel_basic │ ├── channel_basic.go │ ├── channel_basic.gs.ts │ ├── expected.log │ └── index.ts │ ├── channel_receive_both_blank │ ├── channel_receive_both_blank.go │ ├── channel_receive_both_blank.gs.ts │ ├── expected.log │ └── index.ts │ ├── comments_struct │ ├── comments_struct.go │ ├── comments_struct.gs.ts │ ├── expected.log │ └── index.ts │ ├── composite_literal_assignment │ ├── composite_literal_assignment.go │ ├── composite_literal_assignment.gs.ts │ ├── expected.log │ └── index.ts │ ├── constants │ ├── constants.go │ ├── constants.gs.ts │ ├── expected.log │ └── index.ts │ ├── constants_iota │ ├── constants_iota.go │ ├── constants_iota.gs.ts │ ├── expected.log │ └── index.ts │ ├── copy_independence │ ├── copy_independence.go │ ├── copy_independence.gs.ts │ ├── expected.log │ └── index.ts │ ├── defer_statement │ ├── defer_statement.go │ ├── defer_statement.gs.ts │ ├── expected.log │ └── index.ts │ ├── destructure_trailing_comma │ ├── destructure_trailing_comma.go │ ├── destructure_trailing_comma.gs.ts │ ├── expected.log │ └── index.ts │ ├── discarded_channel_receive │ ├── discarded_channel_receive.go │ ├── discarded_channel_receive.gs.ts │ ├── expected.log │ └── index.ts │ ├── embedded_interface_assertion │ ├── embedded_interface_assertion.go │ ├── embedded_interface_assertion.gs.ts │ ├── expected.log │ └── index.ts │ ├── embedded_interface_null_assertion │ ├── embedded_interface_null_assertion.go │ ├── embedded_interface_null_assertion.gs.ts │ ├── expected.log │ └── index.ts │ ├── filepath_walkfunc_call │ ├── expected.log │ ├── filepath_walkfunc_call.go │ ├── filepath_walkfunc_call.gs.ts │ └── index.ts │ ├── flag_bitwise_op │ ├── expected.log │ ├── flag_bitwise_op.go │ ├── flag_bitwise_op.gs.ts │ └── index.ts │ ├── float64 │ ├── expected.log │ ├── float64.go │ ├── float64.gs.ts │ └── index.ts │ ├── for_init_exprstmt │ ├── expected.log │ ├── for_init_exprstmt.go │ ├── for_init_exprstmt.gs.ts │ └── index.ts │ ├── for_init_multi_assign │ ├── expected.log │ ├── for_init_multi_assign.go │ ├── for_init_multi_assign.gs.ts │ └── index.ts │ ├── for_init_value_ok │ ├── expected.log │ ├── for_init_value_ok.go │ ├── for_init_value_ok.gs.ts │ └── index.ts │ ├── for_loop_basic │ ├── expected.log │ ├── for_loop_basic.go │ ├── for_loop_basic.gs.ts │ └── index.ts │ ├── for_loop_condition_only │ ├── expected.log │ ├── for_loop_condition_only.go │ ├── for_loop_condition_only.gs.ts │ └── index.ts │ ├── for_loop_infinite │ ├── expected.log │ ├── for_loop_infinite.go │ ├── for_loop_infinite.gs.ts │ └── index.ts │ ├── for_loop_multi_assign_mismatch │ ├── expected.log │ ├── for_loop_multi_assign_mismatch.go │ ├── for_loop_multi_assign_mismatch.gs.ts │ └── index.ts │ ├── for_post_assign_stmt │ ├── expected.log │ ├── for_post_assign_stmt.go │ ├── for_post_assign_stmt.gs.ts │ └── index.ts │ ├── for_post_exprstmt │ ├── expected.log │ ├── for_post_exprstmt.go │ ├── for_post_exprstmt.gs.ts │ └── index.ts │ ├── for_post_incdec │ ├── expected.log │ ├── for_post_incdec.go │ ├── for_post_incdec.gs.ts │ └── index.ts │ ├── for_post_multi_assign │ ├── expected.log │ ├── for_post_multi_assign.go │ ├── for_post_multi_assign.gs.ts │ └── index.ts │ ├── for_range │ ├── expected.log │ ├── for_range.go │ ├── for_range.gs.ts │ └── index.ts │ ├── for_range_index_use │ ├── expected.log │ ├── for_range_index_use.go │ ├── for_range_index_use.gs.ts │ └── index.ts │ ├── for_range_key_only │ ├── expected.log │ ├── for_range_key_only.go │ ├── for_range_key_only.gs.ts │ └── index.ts │ ├── for_range_no_vars │ ├── expected.log │ ├── for_range_no_vars.go │ ├── for_range_no_vars.gs.ts │ └── index.ts │ ├── for_range_value_only │ ├── expected.log │ ├── for_range_value_only.go │ ├── for_range_value_only.gs.ts │ └── index.ts │ ├── func_literal │ ├── expected.log │ ├── func_literal.go │ ├── func_literal.gs.ts │ └── index.ts │ ├── function_call_result_assignment │ ├── expected.log │ ├── function_call_result_assignment.go │ ├── function_call_result_assignment.gs.ts │ └── index.ts │ ├── function_call_variable_shadowing │ ├── expected.log │ ├── function_call_variable_shadowing.go │ ├── function_call_variable_shadowing.gs.ts │ └── index.ts │ ├── function_signature_type │ ├── expected.log │ ├── function_signature_type.go │ ├── function_signature_type.gs.ts │ └── index.ts │ ├── function_type_assertion │ ├── expected.log │ ├── function_type_assertion.go │ ├── function_type_assertion.gs.ts │ └── index.ts │ ├── generic_index_assignment │ ├── expected.log │ ├── generic_index_assignment.go │ ├── generic_index_assignment.gs.ts │ └── index.ts │ ├── generics │ ├── expected.log │ ├── generics.go │ ├── generics.gs.ts │ └── index.ts │ ├── generics_basic │ ├── expected.log │ ├── generics_basic.go │ ├── generics_basic.gs.ts │ └── index.ts │ ├── generics_interface │ ├── expected.log │ ├── generics_interface.go │ ├── generics_interface.gs.ts │ └── index.ts │ ├── generics_leading_int │ ├── expected.log │ ├── generics_leading_int.go │ ├── generics_leading_int.gs.ts │ └── index.ts │ ├── go_type_assertion │ ├── expected.log │ ├── go_type_assertion.go │ ├── go_type_assertion.gs.ts │ └── index.ts │ ├── goroutines │ ├── expected.log │ ├── goroutines.go │ ├── goroutines.gs.ts │ └── index.ts │ ├── goroutines_anonymous │ ├── expected.log │ ├── goroutines_anonymous.go │ ├── goroutines_anonymous.gs.ts │ └── index.ts │ ├── goroutines_selector │ ├── expected.log │ ├── goroutines_selector.go │ ├── goroutines_selector.gs.ts │ └── index.ts │ ├── hex_escape_sequence │ ├── expected.log │ ├── hex_escape_sequence.go │ ├── hex_escape_sequence.gs.ts │ └── index.ts │ ├── if_statement │ ├── expected.log │ ├── if_statement.go │ ├── if_statement.gs.ts │ └── index.ts │ ├── import_interface │ ├── expected.log │ ├── import_interface.go │ ├── import_interface.gs.ts │ └── index.ts │ ├── import_named_multiple │ ├── expected.log │ ├── import_interface.go │ ├── import_interface.gs.ts │ └── index.ts │ ├── index_expr_destructuring │ ├── expected.log │ ├── index.ts │ ├── index_expr_destructuring.go │ └── index_expr_destructuring.gs.ts │ ├── index_expr_type_assertion │ ├── expected.log │ ├── index.ts │ ├── index_expr_type_assertion.go │ └── index_expr_type_assertion.gs.ts │ ├── inline_function_type_cast │ ├── expected.log │ ├── index.ts │ ├── inline_function_type_cast.go │ └── inline_function_type_cast.gs.ts │ ├── inline_interface_type_assertion │ ├── expected.log │ ├── index.ts │ ├── inline_interface_type_assertion.go │ └── inline_interface_type_assertion.gs.ts │ ├── interface_embedding │ ├── expected.log │ ├── index.ts │ ├── interface_embedding.go │ ├── interface_embedding.gs.ts │ └── subpkg │ │ ├── index.ts │ │ ├── subpkg.go │ │ └── subpkg.gs.ts │ ├── interface_method_comments │ ├── expected.log │ ├── index.ts │ ├── interface_method_comments.go │ └── interface_method_comments.gs.ts │ ├── interface_multi_param_return │ ├── expected.log │ ├── index.ts │ ├── interface_multi_param_return.go │ └── interface_multi_param_return.gs.ts │ ├── interface_to_interface_type_assertion │ ├── expected.log │ ├── index.ts │ ├── interface_to_interface_type_assertion.go │ └── interface_to_interface_type_assertion.gs.ts │ ├── interface_type_assertion │ ├── expected.log │ ├── index.ts │ ├── interface_type_assertion.go │ └── interface_type_assertion.gs.ts │ ├── interface_type_reference │ ├── expected.log │ ├── index.ts │ ├── interface_type_reference.go │ └── interface_type_reference.gs.ts │ ├── iterator_simple │ ├── expected.log │ ├── index.ts │ ├── iterator_simple.go │ └── iterator_simple.gs.ts │ ├── keyed_array_literal │ ├── expected.log │ ├── index.ts │ ├── keyed_array_literal.go │ └── keyed_array_literal.gs.ts │ ├── labeled_statement │ ├── actual.log │ ├── expected.log │ ├── index.ts │ ├── labeled_statement.go │ ├── labeled_statement.gs.ts │ └── skip-test │ ├── linkname │ ├── index.ts │ ├── linkname.go │ ├── linkname.gs.ts │ └── skip-test │ ├── make_generic_type │ ├── expected.log │ ├── index.ts │ ├── make_generic_type.go │ └── make_generic_type.gs.ts │ ├── make_named_types │ ├── expected.log │ ├── index.ts │ ├── make_named_types.go │ └── make_named_types.gs.ts │ ├── make_selector_type │ ├── expected.log │ ├── index.ts │ ├── make_selector_type.go │ └── make_selector_type.gs.ts │ ├── make_slice │ ├── expected.log │ ├── index.ts │ ├── make_slice.go │ └── make_slice.gs.ts │ ├── map_assign_blank_both │ ├── expected.log │ ├── index.ts │ ├── map_assign_blank_both.go │ └── map_assign_blank_both.gs.ts │ ├── map_support │ ├── expected.log │ ├── index.ts │ ├── map_support.go │ └── map_support.gs.ts │ ├── map_type_assertion │ ├── expected.log │ ├── index.ts │ ├── map_type_assertion.go │ └── map_type_assertion.gs.ts │ ├── method_binding │ ├── expected.log │ ├── index.ts │ ├── method_binding.go │ └── method_binding.gs.ts │ ├── method_call_on_pointer_receiver │ ├── expected.log │ ├── index.ts │ ├── method_call_on_pointer_receiver.go │ └── method_call_on_pointer_receiver.gs.ts │ ├── method_call_on_pointer_via_value │ ├── expected.log │ ├── index.ts │ ├── method_call_on_pointer_via_value.go │ └── method_call_on_pointer_via_value.gs.ts │ ├── method_call_on_value_receiver │ ├── expected.log │ ├── index.ts │ ├── method_call_on_value_receiver.go │ └── method_call_on_value_receiver.gs.ts │ ├── method_call_on_value_via_pointer │ ├── expected.log │ ├── index.ts │ ├── method_call_on_value_via_pointer.go │ └── method_call_on_value_via_pointer.gs.ts │ ├── missing_valueof_error │ ├── expected.log │ ├── index.ts │ ├── missing_valueof_error.go │ └── missing_valueof_error.gs.ts │ ├── multiple_return_values │ ├── expected.log │ ├── index.ts │ ├── multiple_return_values.go │ └── multiple_return_values.gs.ts │ ├── named_function_type_call │ ├── expected.log │ ├── index.ts │ ├── named_function_type_call.go │ └── named_function_type_call.gs.ts │ ├── named_return_method │ ├── expected.log │ ├── index.ts │ ├── named_return_method.go │ └── named_return_method.gs.ts │ ├── named_return_multiple │ ├── expected.log │ ├── index.ts │ ├── named_return_multiple.go │ └── named_return_multiple.gs.ts │ ├── named_slice_wrapper │ ├── expected.log │ ├── index.ts │ ├── named_slice_wrapper.go │ └── named_slice_wrapper.gs.ts │ ├── named_type_wrapper │ ├── expected.log │ ├── index.ts │ ├── named_type_wrapper.go │ └── named_type_wrapper.gs.ts │ ├── named_types_valueof │ ├── expected.log │ ├── index.ts │ ├── named_types_valueof.go │ ├── named_types_valueof.gs.ts │ └── subpkg │ │ ├── index.ts │ │ ├── types.go │ │ └── types.gs.ts │ ├── nil_channel │ ├── expected.log │ ├── index.ts │ ├── nil_channel.go │ └── nil_channel.gs.ts │ ├── nil_pkg_pointer_dereference │ ├── expected.log │ ├── index.ts │ ├── nil_pkg_pointer_dereference.go │ ├── nil_pkg_pointer_dereference.gs.ts │ ├── no-all-deps │ └── output.txt │ ├── nullable_function_param_call │ ├── expected.log │ ├── index.ts │ ├── nullable_function_param_call.go │ └── nullable_function_param_call.gs.ts │ ├── octal_literals │ ├── expected.log │ ├── index.ts │ ├── octal_literals.go │ └── octal_literals.gs.ts │ ├── os_filemode_struct │ ├── expected.log │ ├── index.ts │ ├── os_filemode_struct.go │ └── os_filemode_struct.gs.ts │ ├── package_import │ ├── .gitignore │ ├── expected.log │ ├── index.ts │ ├── package_import.go │ ├── package_import.gs.ts │ └── subpkg │ │ ├── index.ts │ │ ├── subpkg.go │ │ └── subpkg.gs.ts │ ├── package_import_bytes │ ├── expected.log │ ├── index.ts │ ├── package_import_bytes.go │ └── package_import_bytes.gs.ts │ ├── package_import_context │ ├── expected.log │ ├── index.ts │ ├── package_import_context.go │ ├── package_import_context.gs.ts │ └── packages │ ├── package_import_csync │ ├── expect-typecheck-fail │ ├── expected.log │ ├── index.ts │ ├── package_import_csync.go │ └── package_import_csync.gs.ts │ ├── package_import_errors │ ├── expected.log │ ├── index.ts │ ├── package_import_errors.go │ └── package_import_errors.gs.ts │ ├── package_import_fmt │ ├── actual.log │ ├── expected.log │ ├── index.ts │ ├── package_import_fmt.go │ ├── package_import_fmt.gs.ts │ └── skip-test │ ├── package_import_io │ ├── expected.log │ ├── index.ts │ ├── package_import_io.go │ └── package_import_io.gs.ts │ ├── package_import_io_fs │ ├── expected.log │ ├── index.ts │ ├── package_import_io_fs.go │ └── package_import_io_fs.gs.ts │ ├── package_import_maps │ ├── expected.log │ ├── index.ts │ ├── package_import_maps.go │ └── package_import_maps.gs.ts │ ├── package_import_os │ ├── expected.log │ ├── index.ts │ ├── package_import_os.go │ └── package_import_os.gs.ts │ ├── package_import_path │ ├── expected.log │ ├── index.ts │ ├── package_import_path.go │ └── package_import_path.gs.ts │ ├── package_import_path_filepath │ ├── expected.log │ ├── index.ts │ ├── package_import_path_filepath.go │ └── package_import_path_filepath.gs.ts │ ├── package_import_pkg_errors │ ├── expected.log │ ├── index.ts │ ├── package_import_pkg_errors.go │ └── package_import_pkg_errors.gs.ts │ ├── package_import_reflect │ ├── expected.log │ ├── index.ts │ ├── package_import_reflect.go │ ├── package_import_reflect.gs.js │ └── package_import_reflect.gs.ts │ ├── package_import_runtime │ ├── expected.log │ ├── index.ts │ ├── package_import_runtime.go │ ├── package_import_runtime.gs.ts │ └── packages │ ├── package_import_slices │ ├── expected.log │ ├── index.ts │ ├── package_import_slices.go │ └── package_import_slices.gs.ts │ ├── package_import_sort │ ├── expected.log │ ├── index.ts │ ├── package_import_sort.go │ └── package_import_sort.gs.ts │ ├── package_import_strconv │ ├── expected.log │ ├── index.ts │ ├── package_import_strconv.go │ └── package_import_strconv.gs.ts │ ├── package_import_strings │ ├── expected.log │ ├── index.ts │ ├── package_import_strings.go │ └── package_import_strings.gs.ts │ ├── package_import_sync │ ├── expected.log │ ├── index.ts │ ├── package_import_sync.go │ └── package_import_sync.gs.ts │ ├── package_import_sync_atomic │ ├── expected.log │ ├── index.ts │ ├── package_import_sync_atomic.go │ └── package_import_sync_atomic.gs.ts │ ├── package_import_testing_fstest │ ├── actual.log │ ├── expected.log │ ├── index.ts │ ├── package_import_testing_fstest.go │ ├── package_import_testing_fstest.gs.ts │ └── skip-test │ ├── package_import_time │ ├── expected.log │ ├── index.ts │ ├── package_import_time.go │ └── package_import_time.gs.ts │ ├── package_import_unicode │ ├── expected.log │ ├── index.ts │ ├── package_import_unicode.go │ └── package_import_unicode.gs.ts │ ├── package_import_unicode_utf8 │ ├── expected.log │ ├── index.ts │ ├── package_import_unicode_utf8.go │ └── package_import_unicode_utf8.gs.ts │ ├── path_error_constructor │ ├── expected.log │ ├── index.ts │ ├── path_error_constructor.go │ └── path_error_constructor.gs.ts │ ├── pointer_assignment_no_copy │ ├── expected.log │ ├── index.ts │ ├── pointer_assignment_no_copy.go │ └── pointer_assignment_no_copy.gs.ts │ ├── pointer_composite_literal_assignment │ ├── expected.log │ ├── index.ts │ ├── pointer_composite_literal_assignment.go │ └── pointer_composite_literal_assignment.gs.ts │ ├── pointer_composite_literal_untyped │ ├── expected.log │ ├── index.ts │ ├── pointer_composite_literal_untyped.go │ └── pointer_composite_literal_untyped.gs.ts │ ├── pointer_deref_multiassign │ ├── expected.log │ ├── index.ts │ ├── pointer_deref_multiassign.go │ └── pointer_deref_multiassign.gs.ts │ ├── pointer_initialization │ ├── expected.log │ ├── index.ts │ ├── pointer_initialization.go │ └── pointer_initialization.gs.ts │ ├── pointer_range_loop │ ├── expected.log │ ├── index.ts │ ├── pointer_range_loop.go │ └── pointer_range_loop.gs.ts │ ├── pointer_struct_assign_clone │ ├── actual.log │ ├── expect-fail │ ├── expected.log │ ├── index.ts │ ├── pointer_struct_assign_clone.go │ └── pointer_struct_assign_clone.gs.ts │ ├── pointers │ ├── expect-typecheck-fail │ ├── expected.log │ ├── index.ts │ ├── pointers.go │ └── pointers.gs.ts │ ├── private_field_access │ ├── expected.log │ ├── index.ts │ ├── private_field_access.go │ └── private_field_access.gs.ts │ ├── protobuf_lite_ts │ ├── README.md │ ├── expected.log │ ├── index.ts │ ├── protobuf_lite_ts.go │ ├── protobuf_lite_ts.gs.ts │ ├── protobuf_lite_ts.pb.go │ ├── protobuf_lite_ts.pb.ts │ └── protobuf_lite_ts.proto │ ├── receiver_binding │ ├── expected.log │ ├── index.ts │ ├── methods.go │ ├── methods.gs.ts │ ├── storage.go │ └── storage.gs.ts │ ├── receiver_method │ ├── expected.log │ ├── index.ts │ ├── main.go │ └── main.gs.ts │ ├── receiver_variable │ ├── expected.log │ ├── index.ts │ ├── receiver_variable.go │ └── receiver_variable.gs.ts │ ├── recursive_type_definition │ ├── expected.log │ ├── index.ts │ ├── recursive_type_definition.go │ └── recursive_type_definition.gs.ts │ ├── redeclaration_assign │ ├── expected.log │ ├── index.ts │ ├── redeclaration_assign.go │ └── redeclaration_assign.gs.ts │ ├── reserved_words │ ├── expected.log │ ├── index.ts │ ├── reserved_words.go │ └── reserved_words.gs.ts │ ├── rune_const_import │ ├── expected.log │ ├── index.ts │ ├── rune_const_import.go │ ├── rune_const_import.gs.ts │ └── subpkg │ │ ├── index.ts │ │ ├── subpkg.go │ │ └── subpkg.gs.ts │ ├── rune_const_reference │ ├── expected.log │ ├── index.ts │ ├── rune_const_reference.go │ ├── rune_const_reference.gs.ts │ └── subpkg │ │ ├── index.ts │ │ ├── subpkg.go │ │ └── subpkg.gs.ts │ ├── select_receive_on_closed_channel_no_default │ ├── expected.log │ ├── index.ts │ ├── select_receive_on_closed_channel_no_default.go │ └── select_receive_on_closed_channel_no_default.gs.ts │ ├── select_send_on_full_buffered_channel_with_default │ ├── expected.log │ ├── index.ts │ ├── select_send_on_full_buffered_channel_with_default.go │ └── select_send_on_full_buffered_channel_with_default.gs.ts │ ├── select_statement │ ├── expected.log │ ├── index.ts │ ├── select_statement.go │ └── select_statement.gs.ts │ ├── selective_exports │ ├── expected.log │ ├── index.ts │ ├── selective_exports.go │ ├── selective_exports.gs.ts │ ├── utils.go │ └── utils.gs.ts │ ├── selector_expr_lhs_multi_assign │ ├── expected.log │ ├── index.ts │ ├── selector_expr_lhs_multi_assign.go │ └── selector_expr_lhs_multi_assign.gs.ts │ ├── selector_expr_ok_variable │ ├── expected.log │ ├── index.ts │ ├── selector_expr_ok_variable.go │ └── selector_expr_ok_variable.gs.ts │ ├── simple │ ├── expected.log │ ├── index.ts │ ├── simple.go │ └── simple.gs.ts │ ├── simple_deref_assignment │ ├── expected.log │ ├── index.ts │ ├── simple_deref_assignment.go │ └── simple_deref_assignment.gs.ts │ ├── slice │ ├── expected.log │ ├── index.ts │ ├── slice.go │ └── slice.gs.ts │ ├── star_expr_destructuring │ ├── expected.log │ ├── index.ts │ ├── star_expr_destructuring.go │ └── star_expr_destructuring.gs.ts │ ├── string_conversion │ ├── expected.log │ ├── index.ts │ ├── string_conversion.go │ └── string_conversion.gs.ts │ ├── string_index_access │ ├── expected.log │ ├── index.ts │ ├── string_index_access.go │ └── string_index_access.gs.ts │ ├── string_slice │ ├── expected.log │ ├── index.ts │ ├── string_slice.go │ └── string_slice.gs.ts │ ├── string_type_assertion │ ├── expected.log │ ├── index.ts │ ├── string_type_assertion.go │ └── string_type_assertion.gs.ts │ ├── struct_embedding │ ├── expected.log │ ├── index.ts │ ├── struct_embedding.go │ └── struct_embedding.gs.ts │ ├── struct_field_access │ ├── expected.log │ ├── index.ts │ ├── struct_field_access.go │ └── struct_field_access.gs.ts │ ├── struct_new │ ├── expected.log │ ├── index.ts │ ├── struct_new.go │ └── struct_new.gs.ts │ ├── struct_pointer_interface_fields │ ├── expected.log │ ├── index.ts │ ├── struct_pointer_interface_fields.go │ └── struct_pointer_interface_fields.gs.ts │ ├── struct_private_field │ ├── expected.log │ ├── index.ts │ ├── struct_private_field.go │ └── struct_private_field.gs.ts │ ├── struct_private_field_ptr │ ├── expected.log │ ├── index.ts │ ├── struct_private_field_ptr.go │ └── struct_private_field_ptr.gs.ts │ ├── struct_type_assertion │ ├── expected.log │ ├── index.ts │ ├── struct_type_assertion.go │ └── struct_type_assertion.gs.ts │ ├── struct_value_init_clone │ ├── expected.log │ ├── index.ts │ ├── struct_value_init_clone.go │ └── struct_value_init_clone.gs.ts │ ├── switch_multi_case │ ├── expected.log │ ├── index.ts │ ├── switch_multi_case.go │ └── switch_multi_case.gs.ts │ ├── switch_statement │ ├── expected.log │ ├── index.ts │ ├── switch_statement.go │ └── switch_statement.gs.ts │ ├── time_format_ext │ ├── expected.log │ ├── index.ts │ ├── time_format_ext.go │ └── time_format_ext.gs.ts │ ├── type_assertion_duplicate_vars │ ├── expected.log │ ├── index.ts │ ├── type_assertion_duplicate_vars.go │ └── type_assertion_duplicate_vars.gs.ts │ ├── type_declaration_receiver │ ├── expected.log │ ├── index.ts │ ├── type_declaration_receiver.go │ └── type_declaration_receiver.gs.ts │ ├── type_missing_imports │ ├── expected.log │ ├── index.ts │ ├── type_missing_imports.go │ └── type_missing_imports.gs.ts │ ├── type_separate_files │ ├── expected.log │ ├── index.ts │ ├── memory.go │ ├── memory.gs.ts │ ├── storage.go │ ├── storage.gs.ts │ ├── type_separate_files.go │ └── type_separate_files.gs.ts │ ├── type_switch_statement │ ├── expected.log │ ├── index.ts │ ├── type_switch_statement.go │ └── type_switch_statement.gs.ts │ ├── undefined_type_error │ ├── expected.log │ ├── index.ts │ ├── undefined_type_error.go │ └── undefined_type_error.gs.ts │ ├── value_type_copy_behavior │ ├── expected.log │ ├── index.ts │ ├── value_type_copy_behavior.go │ └── value_type_copy_behavior.gs.ts │ ├── variable_shadowing_scope │ ├── expected.log │ ├── index.ts │ ├── variable_shadowing_scope.go │ └── variable_shadowing_scope.gs.ts │ ├── variadic_function_call │ ├── expected.log │ ├── index.ts │ ├── variadic_function_call.go │ └── variadic_function_call.gs.ts │ ├── variadic_interface_method │ ├── expected.log │ ├── index.ts │ ├── variadic_interface_method.go │ └── variadic_interface_method.gs.ts │ ├── variadic_interface_param │ ├── expected.log │ ├── index.ts │ ├── variadic_interface_param.go │ └── variadic_interface_param.gs.ts │ ├── varref │ ├── expected.log │ ├── index.ts │ ├── varref.go │ └── varref.gs.ts │ ├── varref_assign │ ├── expected.log │ ├── index.ts │ ├── varref_assign.go │ └── varref_assign.gs.ts │ ├── varref_composite_lit │ ├── expected.log │ ├── index.ts │ ├── varref_composite_lit.go │ └── varref_composite_lit.gs.ts │ ├── varref_deref_set │ ├── expected.log │ ├── index.ts │ ├── varref_deref_set.go │ └── varref_deref_set.gs.ts │ ├── varref_deref_struct │ ├── expected.log │ ├── index.ts │ ├── varref_deref_struct.go │ └── varref_deref_struct.gs.ts │ ├── varref_pointers │ ├── expected.log │ ├── index.ts │ ├── varref_pointers.go │ └── varref_pointers.gs.ts │ ├── varref_pointers_deref │ ├── expected.log │ ├── index.ts │ ├── varref_pointers_deref.go │ └── varref_pointers_deref.gs.ts │ ├── varref_pointers_number │ ├── expect-fail │ ├── expected.log │ ├── index.ts │ ├── varref_pointers_number.go │ └── varref_pointers_number.gs.ts │ ├── varref_struct │ ├── expected.log │ ├── index.ts │ ├── varref_struct.go │ └── varref_struct.gs.ts │ ├── varref_struct_init │ ├── expected.log │ ├── index.ts │ ├── varref_struct_init.go │ └── varref_struct_init.gs.ts │ └── wrapper_type_args │ ├── expected.log │ ├── index.ts │ ├── wrapper_type_args.go │ └── wrapper_type_args.gs.ts ├── design ├── ASYNC.md ├── BUILTIN.md ├── BYTES.md ├── CHANNELS.md ├── DESIGN.md ├── GENERICS.md ├── GO_SPECIFICATION.html ├── ITERATE_COMPLIANCE.md ├── NAMED_BASIC_TYPES.md ├── OVERRIDES.md ├── PROPOSED_SLICES_DESIGN.md ├── SLICES_REDUCED.md ├── SPEC_DIFFERENCES.md ├── TODO.md └── VAR_REFS.md ├── docs └── gs-dependencies.md ├── eslint.config.mjs ├── example └── simple │ ├── .gitignore │ ├── .rooignore │ ├── build.bash │ ├── go.mod │ ├── go.sum │ ├── main.go │ ├── main.gs.ts │ ├── main.ts │ ├── main_test.go │ ├── main_tools.go │ ├── package.json │ ├── run.bash │ ├── tsconfig.json │ └── yarn.lock ├── expected.log ├── go.mod ├── go.sum ├── gs.go ├── gs ├── README.md ├── builtin │ ├── builtin.ts │ ├── channel.ts │ ├── defer.ts │ ├── errors.ts │ ├── index.ts │ ├── map.ts │ ├── slice.ts │ ├── type.ts │ └── varRef.ts ├── bytes │ ├── buffer.gs.ts │ ├── bytes.gs.ts │ ├── godoc.txt │ ├── index.ts │ ├── iter.gs.ts │ ├── meta.json │ └── reader.gs.ts ├── cmp │ ├── godoc.txt │ └── index.ts ├── context │ ├── context.ts │ ├── godoc.txt │ └── index.ts ├── errors │ ├── errors.ts │ ├── godoc.txt │ └── index.ts ├── fmt │ ├── fmt.ts │ ├── godoc.txt │ ├── index.ts │ └── meta.json ├── github.com │ └── pkg │ │ └── errors │ │ ├── errors.ts │ │ ├── go113.ts │ │ ├── index.ts │ │ └── stack.ts ├── internal │ ├── abi │ │ └── index.ts │ ├── bytealg │ │ └── index.ts │ ├── byteorder │ │ └── index.ts │ ├── goarch │ │ ├── godoc.txt │ │ └── index.ts │ ├── meta.json │ └── oserror │ │ ├── errors.ts │ │ └── index.ts ├── io │ ├── fs │ │ ├── format.ts │ │ ├── fs.ts │ │ ├── glob.ts │ │ ├── godoc.txt │ │ ├── index.ts │ │ ├── readdir.ts │ │ ├── readfile.ts │ │ ├── stat.ts │ │ ├── sub.ts │ │ └── walk.ts │ ├── godoc.txt │ ├── index.ts │ ├── io.ts │ └── meta.json ├── iter │ ├── godoc.txt │ ├── index.ts │ └── iter.ts ├── maps │ ├── index.ts │ ├── iter.ts │ ├── maps.ts │ └── meta.json ├── math │ ├── TODO.md │ ├── abs.gs.test.ts │ ├── abs.gs.ts │ ├── acosh.gs.test.ts │ ├── acosh.gs.ts │ ├── asin.gs.test.ts │ ├── asin.gs.ts │ ├── asinh.gs.test.ts │ ├── asinh.gs.ts │ ├── atan.gs.test.ts │ ├── atan.gs.ts │ ├── atan2.gs.test.ts │ ├── atan2.gs.ts │ ├── atanh.gs.test.ts │ ├── atanh.gs.ts │ ├── bits.gs.test.ts │ ├── bits.gs.ts │ ├── bits │ │ └── index.ts │ ├── cbrt.gs.test.ts │ ├── cbrt.gs.ts │ ├── const.gs.test.ts │ ├── const.gs.ts │ ├── copysign.gs.test.ts │ ├── copysign.gs.ts │ ├── dim.gs.test.ts │ ├── dim.gs.ts │ ├── erf.gs.test.ts │ ├── erf.gs.ts │ ├── erfinv.gs.test.ts │ ├── erfinv.gs.ts │ ├── exp.gs.test.ts │ ├── exp.gs.ts │ ├── expm1.gs.test.ts │ ├── expm1.gs.ts │ ├── floor.gs.test.ts │ ├── floor.gs.ts │ ├── fma.gs.test.ts │ ├── fma.gs.ts │ ├── frexp.gs.test.ts │ ├── frexp.gs.ts │ ├── gamma.gs.test.ts │ ├── gamma.gs.ts │ ├── godoc.txt │ ├── hypot.gs.test.ts │ ├── hypot.gs.ts │ ├── index.ts │ ├── j0.gs.test.ts │ ├── j0.gs.ts │ ├── j1.gs.test.ts │ ├── j1.gs.ts │ ├── jn.gs.test.ts │ ├── jn.gs.ts │ ├── ldexp.gs.test.ts │ ├── ldexp.gs.ts │ ├── lgamma.gs.test.ts │ ├── lgamma.gs.ts │ ├── log.gs.test.ts │ ├── log.gs.ts │ ├── log10.gs.test.ts │ ├── log10.gs.ts │ ├── log1p.gs.test.ts │ ├── log1p.gs.ts │ ├── logb.gs.test.ts │ ├── logb.gs.ts │ ├── meta.json │ ├── mod.gs.test.ts │ ├── mod.gs.ts │ ├── modf.gs.test.ts │ ├── modf.gs.ts │ ├── nextafter.gs.test.ts │ ├── nextafter.gs.ts │ ├── pow.gs.test.ts │ ├── pow.gs.ts │ ├── pow10.gs.test.ts │ ├── pow10.gs.ts │ ├── remainder.gs.test.ts │ ├── remainder.gs.ts │ ├── signbit.gs.test.ts │ ├── signbit.gs.ts │ ├── sin.gs.test.ts │ ├── sin.gs.ts │ ├── sincos.gs.test.ts │ ├── sincos.gs.ts │ ├── sinh.gs.test.ts │ ├── sinh.gs.ts │ ├── sqrt.gs.test.ts │ ├── sqrt.gs.ts │ ├── tan.gs.test.ts │ ├── tan.gs.ts │ ├── tanh.gs.test.ts │ ├── tanh.gs.ts │ ├── trig_reduce.gs.ts │ └── unsafe.gs.ts ├── os │ ├── dir.gs.ts │ ├── dir_unix.gs.ts │ ├── dirent_js.gs.ts │ ├── env.gs.ts │ ├── error.gs.ts │ ├── error_errno.gs.ts │ ├── exec.gs.ts │ ├── exec_nohandle.gs.ts │ ├── exec_posix.gs.ts │ ├── exec_unix.gs.ts │ ├── executable.gs.ts │ ├── executable_js.gs.ts │ ├── executable_wasm.gs.ts │ ├── file_constants_js.gs.ts │ ├── file_js.gs.ts │ ├── file_open_unix.gs.ts │ ├── file_posix_js.gs.ts │ ├── file_unix_js.gs.ts │ ├── getwd_js.gs.ts │ ├── index.ts │ ├── meta.json │ ├── path.gs.ts │ ├── path_unix.gs.ts │ ├── pidfd_js.gs.ts │ ├── pipe_wasm.gs.ts │ ├── proc.gs.ts │ ├── proc_js.gs.ts │ ├── rawconn_js.gs.ts │ ├── removeall_js.gs.ts │ ├── root_js.gs.ts │ ├── root_nonwindows.gs.ts │ ├── root_noopenat.gs.ts │ ├── stat.gs.ts │ ├── stat_js.gs.ts │ ├── stat_unix_js.gs.ts │ ├── sticky_bsd.gs.ts │ ├── sys.gs.ts │ ├── sys_bsd.gs.ts │ ├── sys_js.gs.ts │ ├── tempfile.gs.ts │ ├── types.gs.ts │ ├── types_js.gs.ts │ ├── types_unix.gs.ts │ ├── wait_unimp.gs.ts │ ├── zero_copy_posix.gs.ts │ └── zero_copy_stub.gs.ts ├── path │ ├── filepath │ │ ├── godoc.txt │ │ ├── index.ts │ │ ├── match.test.ts │ │ ├── match.ts │ │ ├── path.test.ts │ │ └── path.ts │ ├── index.ts │ ├── match.ts │ ├── meta.json │ └── path.ts ├── reflect │ ├── ANALYSIS.md │ ├── deepequal.test.ts │ ├── deepequal.ts │ ├── function-types.test.ts │ ├── godoc.txt │ ├── index.ts │ ├── iter.ts │ ├── map.test.ts │ ├── map.ts │ ├── meta.json │ ├── swapper.ts │ ├── type.ts │ ├── types.ts │ ├── value.ts │ └── visiblefields.ts ├── runtime │ ├── godoc.txt │ ├── index.ts │ └── runtime.ts ├── slices │ ├── godoc.txt │ ├── index.ts │ └── slices.ts ├── sort │ ├── godoc.txt │ ├── index.ts │ ├── search.gs.ts │ ├── slice.gs.ts │ └── sort.gs.ts ├── strconv │ ├── atob.gs.ts │ ├── atof.gs.ts │ ├── atoi.gs.ts │ ├── doc.gs.ts │ ├── ftoa.gs.ts │ ├── index.ts │ ├── itoa.gs.ts │ ├── meta.json │ └── quote.gs.ts ├── strings │ ├── builder.test.ts │ ├── builder.ts │ ├── clone.test.ts │ ├── clone.ts │ ├── compare.test.ts │ ├── compare.ts │ ├── godoc.txt │ ├── index.ts │ ├── iter.test.ts │ ├── iter.ts │ ├── meta.json │ ├── reader.test.ts │ ├── reader.ts │ ├── replace.test.ts │ ├── replace.ts │ ├── search.test.ts │ ├── search.ts │ ├── strings.test.ts │ └── strings.ts ├── sync │ ├── atomic │ │ ├── doc.gs.ts │ │ ├── doc_64.gs.ts │ │ ├── index.ts │ │ ├── type.gs.ts │ │ └── value.gs.ts │ ├── godoc.txt │ ├── index.ts │ ├── meta.json │ └── sync.ts ├── syscall │ └── index.ts ├── time │ ├── godoc.txt │ ├── index.ts │ └── time.ts ├── unicode │ ├── godoc.txt │ ├── index.ts │ ├── unicode.go │ ├── unicode.ts │ └── utf8 │ │ ├── godoc.txt │ │ ├── index.ts │ │ └── utf8.ts └── unsafe │ ├── godoc.txt │ ├── index.ts │ ├── unsafe.test.ts │ └── unsafe.ts ├── gs_test.go ├── package.json ├── tsconfig.build.json ├── tsconfig.json ├── vitest.config.ts └── yarn.lock /.cursor: -------------------------------------------------------------------------------- 1 | .roo -------------------------------------------------------------------------------- /.github/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | ":semanticPrefixFixDepsChoreOthers", 5 | ":ignoreModulesAndTests", 6 | "group:all", 7 | "workarounds:all" 8 | ], 9 | "branchConcurrentLimit": 0, 10 | "packageRules": [ 11 | { 12 | "matchManagers": ["gomod"], 13 | "matchDepTypes": ["replace"], 14 | "enabled": false 15 | }, 16 | { 17 | "matchPackageNames": ["github.com/aperturerobotics/goscript"], 18 | "enabled": false 19 | } 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .#* 2 | node_modules 3 | *.swp 4 | .DS_Store 5 | vendor 6 | dist 7 | buildtarget 8 | .idea 9 | output 10 | out 11 | -------------------------------------------------------------------------------- /.ignore: -------------------------------------------------------------------------------- 1 | .aider* 2 | yarn.lock 3 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # General ignores (from .gitignore and common patterns) 2 | .DS_Store 3 | *.swp 4 | .#* 5 | node_modules 6 | vendor/ 7 | 8 | # Project specific ignores 9 | .gitignore 10 | .npmignore 11 | .roo* 12 | .aider.* 13 | .vscode/ 14 | .github/ -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | *.gs.ts -------------------------------------------------------------------------------- /.prettierrc.yaml: -------------------------------------------------------------------------------- 1 | semi: false 2 | singleQuote: true 3 | experimentalTernaries: true 4 | -------------------------------------------------------------------------------- /.roo/mcp.json: -------------------------------------------------------------------------------- 1 | { 2 | "mcpServers": { 3 | "go-ast-mcp": { 4 | "url": "http://localhost:8080/sse", 5 | "description": "Read and write functions from the Go codebase.", 6 | "alwaysAllow": [ 7 | "read_godoc" 8 | ] 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /.rooignore: -------------------------------------------------------------------------------- 1 | vendor 2 | .aider.* 3 | .roo* 4 | go.sum 5 | go.mod 6 | LICENSE 7 | .vscode 8 | .github 9 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "github.copilot-chat", 4 | "golang.go", 5 | "esbenp.prettier-vscode" 6 | ] 7 | } -------------------------------------------------------------------------------- /cmd/goscript/.gitignore: -------------------------------------------------------------------------------- 1 | output/ 2 | goscript -------------------------------------------------------------------------------- /cmd/goscript/deps.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // This file has _ imports to ensure we include these in the go module. 4 | 5 | import ( 6 | // _ ensure we include the root package 7 | _ "github.com/aperturerobotics/goscript" 8 | ) 9 | -------------------------------------------------------------------------------- /cmd/goscript/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/aperturerobotics/cli" 7 | ) 8 | 9 | func main() { 10 | app := cli.NewApp() 11 | 12 | app.Authors = []*cli.Author{ 13 | {Name: "Christian Stewart", Email: "christian@aperture.us"}, 14 | } 15 | 16 | app.Usage = "GoScript compiles Go to Typescript." 17 | app.Commands = append(app.Commands, CompileCommands...) 18 | 19 | if err := app.Run(os.Args); err != nil { 20 | _, _ = os.Stderr.WriteString(err.Error() + "\n") 21 | os.Exit(1) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /compliance/.gitignore: -------------------------------------------------------------------------------- 1 | tsconfig.json 2 | run 3 | go.mod 4 | go.sum 5 | -------------------------------------------------------------------------------- /compliance/.ignore: -------------------------------------------------------------------------------- 1 | *.gs.ts 2 | expected.log 3 | -------------------------------------------------------------------------------- /compliance/deps/github.com/aperturerobotics/util/broadcast/index.ts: -------------------------------------------------------------------------------- 1 | export { Broadcast } from "./broadcast.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/deps/github.com/aperturerobotics/util/csync/index.ts: -------------------------------------------------------------------------------- 1 | export { Mutex, MutexLocker } from "./mutex.gs.js" 2 | export { RWMutex, RWMutexLocker } from "./rwmutex.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/array_literal/array_literal.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | // Test basic array literal 5 | var a [3]int = [3]int{1, 2, 3} //nolint:staticcheck 6 | println(a[0], a[1], a[2]) 7 | 8 | // Test array literal with inferred length 9 | b := [...]string{"hello", "world"} 10 | println(b[0], b[1]) 11 | 12 | // Test array literal with specific element initialization 13 | c := [5]int{1: 10, 3: 30} 14 | println(c[0], c[1], c[2], c[3], c[4]) 15 | } 16 | -------------------------------------------------------------------------------- /compliance/tests/array_literal/expected.log: -------------------------------------------------------------------------------- 1 | 1 2 3 2 | hello world 3 | 0 10 0 30 0 -------------------------------------------------------------------------------- /compliance/tests/array_literal/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/array_literal/index.ts -------------------------------------------------------------------------------- /compliance/tests/assign_op/expected.log: -------------------------------------------------------------------------------- 1 | 8 2 | 8 3 | 4 4 | 15 5 | 1 6 | 1 7 | 7 8 | 6 9 | 10 10 | 2 -------------------------------------------------------------------------------- /compliance/tests/assign_op/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/assign_op/index.ts -------------------------------------------------------------------------------- /compliance/tests/async_basic/expected.log: -------------------------------------------------------------------------------- 1 | 11 -------------------------------------------------------------------------------- /compliance/tests/async_basic/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/async_basic/index.ts -------------------------------------------------------------------------------- /compliance/tests/async_defer_statement/async_defer_statement.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | ch := make(chan bool, 1) 5 | 6 | defer func() { 7 | println("deferred start") 8 | <-ch // Wait for signal from main 9 | println("deferred end") 10 | }() 11 | 12 | println("main start") 13 | println("main signaling defer") 14 | ch <- true // Signal the deferred function 15 | println("main end") 16 | } 17 | -------------------------------------------------------------------------------- /compliance/tests/async_defer_statement/expected.log: -------------------------------------------------------------------------------- 1 | main start 2 | main signaling defer 3 | main end 4 | deferred start 5 | deferred end -------------------------------------------------------------------------------- /compliance/tests/async_defer_statement/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/async_defer_statement/index.ts -------------------------------------------------------------------------------- /compliance/tests/atomic_struct_field_init/expected.log: -------------------------------------------------------------------------------- 1 | closed: true 2 | count: 42 3 | flag: 100 4 | s2 closed: false 5 | s2 count: 24 6 | s2 flag: 50 7 | atomic struct field test finished 8 | -------------------------------------------------------------------------------- /compliance/tests/atomic_struct_field_init/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./atomic_struct_field_init.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/basic_arithmetic/basic_arithmetic.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | // === Basic Arithmetic === 5 | add := 2 + 3 6 | sub := 10 - 4 7 | mul := 6 * 7 8 | div := 20 / 5 9 | mod := 17 % 3 10 | println("Addition: Expected: 5, Actual:", add) 11 | println("Subtraction: Expected: 6, Actual:", sub) 12 | println("Multiplication: Expected: 42, Actual:", mul) 13 | println("Division: Expected: 4, Actual:", div) 14 | println("Modulus: Expected: 2, Actual:", mod) 15 | } 16 | -------------------------------------------------------------------------------- /compliance/tests/basic_arithmetic/expected.log: -------------------------------------------------------------------------------- 1 | Addition: Expected: 5, Actual: 5 2 | Subtraction: Expected: 6, Actual: 6 3 | Multiplication: Expected: 42, Actual: 42 4 | Division: Expected: 4, Actual: 4 5 | Modulus: Expected: 2, Actual: 2 -------------------------------------------------------------------------------- /compliance/tests/basic_arithmetic/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/basic_arithmetic/index.ts -------------------------------------------------------------------------------- /compliance/tests/bitwise_and_not_assignment/bitwise_and_not_assignment.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | // Test the &^= operator (bit clear assignment) 5 | x := uint64(0x7FF0000000000000) // Some bits set 6 | mask := uint64(2047 << 52) // Mask to clear 7 | 8 | println("Before:", x) 9 | x &^= mask // This should generate valid TypeScript 10 | println("After:", x) 11 | 12 | // Also test regular &^ operator 13 | y := uint64(0x7FF0000000000000) 14 | result := y &^ mask 15 | println("Result:", result) 16 | } 17 | -------------------------------------------------------------------------------- /compliance/tests/bitwise_and_not_assignment/expected.log: -------------------------------------------------------------------------------- 1 | Before: 9218868437227405000 2 | After: 0 3 | Result: 0 4 | -------------------------------------------------------------------------------- /compliance/tests/bitwise_and_not_assignment/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/bitwise_and_not_assignment/index.ts -------------------------------------------------------------------------------- /compliance/tests/block_comments/block_comments.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | /* This is a single-line block comment */ 4 | 5 | /* 6 | This is a multi-line 7 | block comment that spans 8 | several lines 9 | */ 10 | 11 | func main() { 12 | /* Another single-line block comment */ 13 | println("testing block comments") 14 | 15 | /* 16 | Multi-line comment 17 | in the middle of code 18 | */ 19 | 20 | x := 42 /* inline block comment */ 21 | println("x =", x) 22 | } 23 | -------------------------------------------------------------------------------- /compliance/tests/block_comments/block_comments.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on block_comments.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export async function main(): Promise { 7 | /* Another single-line block comment */ 8 | console.log("testing block comments") 9 | 10 | /* 11 | * 12 | * Multi-line comment 13 | * in the middle of code 14 | * 15 | */ 16 | 17 | let x = 42 // inline block comment 18 | console.log("x =", x) 19 | } 20 | 21 | -------------------------------------------------------------------------------- /compliance/tests/block_comments/expected.log: -------------------------------------------------------------------------------- 1 | testing block comments 2 | x = 42 3 | -------------------------------------------------------------------------------- /compliance/tests/block_comments/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/block_comments/index.ts -------------------------------------------------------------------------------- /compliance/tests/boolean_logic/boolean_logic.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | // === Boolean Logic === 5 | a := true 6 | b := false 7 | and := a && b 8 | or := a || b 9 | notA := !a 10 | println("AND: Expected: false, Actual:", and) 11 | println("OR: Expected: true, Actual:", or) 12 | println("NOT: Expected: false, Actual:", notA) 13 | } 14 | -------------------------------------------------------------------------------- /compliance/tests/boolean_logic/boolean_logic.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on boolean_logic.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export async function main(): Promise { 7 | // === Boolean Logic === 8 | let a = true 9 | let b = false 10 | let and = a && b 11 | let or = a || b 12 | let notA = !a 13 | console.log("AND: Expected: false, Actual:", and) 14 | console.log("OR: Expected: true, Actual:", or) 15 | console.log("NOT: Expected: false, Actual:", notA) 16 | } 17 | 18 | -------------------------------------------------------------------------------- /compliance/tests/boolean_logic/expected.log: -------------------------------------------------------------------------------- 1 | AND: Expected: false, Actual: false 2 | OR: Expected: true, Actual: true 3 | NOT: Expected: false, Actual: false -------------------------------------------------------------------------------- /compliance/tests/boolean_logic/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/boolean_logic/index.ts -------------------------------------------------------------------------------- /compliance/tests/buffer_value_field_error/expected.log: -------------------------------------------------------------------------------- 1 | After write: hello 2 | After writeString: hello world 3 | After writeByte: hello world! 4 | -------------------------------------------------------------------------------- /compliance/tests/buffer_value_field_error/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/buffer_value_field_error/index.ts -------------------------------------------------------------------------------- /compliance/tests/build_tags/build_tags.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | println("=== Build Tags Test ===") 5 | 6 | // Test that platform-specific files are handled correctly 7 | // This should only compile files with js/wasm build tags 8 | // and exclude files with other platform tags 9 | 10 | testJSWasm() 11 | testGeneric() 12 | 13 | println("=== End Build Tags Test ===") 14 | } 15 | -------------------------------------------------------------------------------- /compliance/tests/build_tags/build_tags_darwin.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func testJSWasm() { 4 | println("Darwin specific code compiled - WRONG! This should not be compiled when GOOS=js") 5 | } 6 | -------------------------------------------------------------------------------- /compliance/tests/build_tags/build_tags_generic.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func testGeneric() { 4 | println("Generic code compiled - CORRECT") 5 | } 6 | -------------------------------------------------------------------------------- /compliance/tests/build_tags/build_tags_generic.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on build_tags_generic.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export function testGeneric(): void { 7 | console.log("Generic code compiled - CORRECT") 8 | } 9 | 10 | -------------------------------------------------------------------------------- /compliance/tests/build_tags/build_tags_js.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func testJSWasm() { 4 | println("JS/WASM specific code compiled - CORRECT") 5 | } 6 | -------------------------------------------------------------------------------- /compliance/tests/build_tags/build_tags_js.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on build_tags_js.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export function testJSWasm(): void { 7 | console.log("JS/WASM specific code compiled - CORRECT") 8 | } 9 | 10 | -------------------------------------------------------------------------------- /compliance/tests/build_tags/build_tags_other.go: -------------------------------------------------------------------------------- 1 | //go:build !js && !darwin && !windows 2 | 3 | package main 4 | 5 | func testJSWasm() { 6 | println("Non-Windows Non-Darwin Non-Js specific code compiled - WRONG! This should not be compiled when GOOS=js") 7 | } 8 | -------------------------------------------------------------------------------- /compliance/tests/build_tags/build_tags_windows.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func testJSWasm() { 4 | println("Windows specific code compiled - WRONG! This should not be compiled when GOOS=js") 5 | } 6 | -------------------------------------------------------------------------------- /compliance/tests/build_tags/expected.log: -------------------------------------------------------------------------------- 1 | === Build Tags Test === 2 | JS/WASM specific code compiled - CORRECT 3 | Generic code compiled - CORRECT 4 | === End Build Tags Test === -------------------------------------------------------------------------------- /compliance/tests/build_tags/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/build_tags/index.ts -------------------------------------------------------------------------------- /compliance/tests/bytes/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/bytes/index.ts -------------------------------------------------------------------------------- /compliance/tests/chan_type_assertion/expected.log: -------------------------------------------------------------------------------- 1 | i is chan int: ok 2 | s is chan<- string: ok 3 | r is <-chan float64: ok 4 | e is chan struct{}: ok 5 | i is chan string: correctly failed 6 | i is chan<- int: correctly failed 7 | i is <-chan int: correctly failed 8 | bidirectional can be used as send-only: failed 9 | bidirectional can be used as receive-only: failed -------------------------------------------------------------------------------- /compliance/tests/chan_type_assertion/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/chan_type_assertion/index.ts -------------------------------------------------------------------------------- /compliance/tests/channel_basic/channel_basic.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | messages := make(chan string) 5 | 6 | go func() { 7 | messages <- "ping" 8 | }() 9 | 10 | msg := <-messages 11 | println(msg) 12 | } 13 | -------------------------------------------------------------------------------- /compliance/tests/channel_basic/channel_basic.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on channel_basic.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export async function main(): Promise { 7 | let messages = $.makeChannel(0, "", 'both') 8 | 9 | queueMicrotask(async () => { 10 | await $.chanSend(messages, "ping") 11 | }) 12 | 13 | let msg = await $.chanRecv(messages) 14 | console.log(msg) 15 | } 16 | 17 | -------------------------------------------------------------------------------- /compliance/tests/channel_basic/expected.log: -------------------------------------------------------------------------------- 1 | ping -------------------------------------------------------------------------------- /compliance/tests/channel_basic/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/channel_basic/index.ts -------------------------------------------------------------------------------- /compliance/tests/channel_receive_both_blank/channel_receive_both_blank.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | ch := make(chan int, 1) 5 | 6 | // Send a value to the channel 7 | ch <- 42 8 | 9 | // Receive with both value and ok discarded 10 | _, _ = <-ch 11 | 12 | println("received and discarded value and ok") 13 | 14 | // Close the channel 15 | close(ch) 16 | 17 | // Receive from closed channel with both discarded 18 | _, _ = <-ch 19 | 20 | println("received from closed channel, both discarded") 21 | } 22 | -------------------------------------------------------------------------------- /compliance/tests/channel_receive_both_blank/expected.log: -------------------------------------------------------------------------------- 1 | received and discarded value and ok 2 | received from closed channel, both discarded 3 | -------------------------------------------------------------------------------- /compliance/tests/channel_receive_both_blank/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/channel_receive_both_blank/index.ts -------------------------------------------------------------------------------- /compliance/tests/comments_struct/comments_struct.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // TestStruct is a struct with commented fields. 4 | type TestStruct struct { 5 | // IntField is a commented integer field. 6 | IntField int 7 | // StringField is a commented string field. 8 | StringField string 9 | } 10 | 11 | func main() { 12 | s := TestStruct{ 13 | IntField: 42, 14 | StringField: "hello", 15 | } 16 | println("IntField:", s.IntField) 17 | println("StringField:", s.StringField) 18 | } 19 | -------------------------------------------------------------------------------- /compliance/tests/comments_struct/expected.log: -------------------------------------------------------------------------------- 1 | IntField: 42 2 | StringField: hello -------------------------------------------------------------------------------- /compliance/tests/comments_struct/index.ts: -------------------------------------------------------------------------------- 1 | export { TestStruct } from "./comments_struct.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/composite_literal_assignment/expected.log: -------------------------------------------------------------------------------- 1 | Original struct literal: Expected: composite literal, Actual: composite literal 2 | Modified struct literal copy: Expected: modified composite literal copy, Actual: modified composite literal copy -------------------------------------------------------------------------------- /compliance/tests/composite_literal_assignment/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./composite_literal_assignment.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/constants/constants.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const ( 4 | Pi = 3.14 5 | Truth = false 6 | // TODO: Handle large integer constants and bit shifts exceeding JS number limits. 7 | // Big = 1 << 60 8 | // Small = Big >> 59 // Commented out as it depends on Big 9 | Greeting = "Hello, Constants!" 10 | ) 11 | 12 | // Nothing has untyped null 13 | var Nothing = interface{}(nil) 14 | 15 | func main() { 16 | println(Pi) 17 | println(Truth) 18 | // println(Big) // Commented out until large integer handling is implemented 19 | // println(Small) // Commented out as it depends on Big 20 | println(Greeting) 21 | println(byte(4)) 22 | } 23 | -------------------------------------------------------------------------------- /compliance/tests/constants/expected.log: -------------------------------------------------------------------------------- 1 | 3.14 2 | false 3 | Hello, Constants! 4 | 4 -------------------------------------------------------------------------------- /compliance/tests/constants/index.ts: -------------------------------------------------------------------------------- 1 | export { Greeting, Nothing, Pi, Truth } from "./constants.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/constants_iota/expected.log: -------------------------------------------------------------------------------- 1 | ByteSize constants: 2 | KB: 1024 3 | MB: 1048576 4 | GB: 1073741824 5 | TB: 1099511627776 6 | Direction constants: 7 | North: 0 8 | East: 1 9 | South: 2 10 | West: 3 11 | Color constants: 12 | Red: 0 13 | Green: 1 14 | Blue: 2 15 | Day constants: 16 | Sunday: 0 17 | Monday: 1 18 | Tuesday: 2 19 | Wednesday: 3 20 | Thursday: 4 21 | Friday: 5 22 | Saturday: 6 23 | Arithmetic constants: 24 | First: 1 25 | Second: 2 26 | Third: 3 27 | Multiplication constants: 28 | A: 0 29 | B: 2 30 | C: 4 31 | -------------------------------------------------------------------------------- /compliance/tests/constants_iota/index.ts: -------------------------------------------------------------------------------- 1 | export { A, B, Blue, C, East, First, Friday, GB, Green, KB, MB, Monday, North, Red, Saturday, Second, South, Sunday, TB, Third, Thursday, Tuesday, Wednesday, West } from "./constants_iota.gs.js" 2 | export type { ByteSize, Direction } from "./constants_iota.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/copy_independence/expected.log: -------------------------------------------------------------------------------- 1 | pointerCopy (points to original structPointer): Expected: hello world, Actual: hello world 2 | dereferencedStructCopy (modified after copies were made): Expected: original dereferenced copy modified, Actual: original dereferenced copy modified 3 | valueCopy1: Expected: value copy 1, Actual: value copy 1 4 | valueCopy2: Expected: value copy 2, Actual: value copy 2 -------------------------------------------------------------------------------- /compliance/tests/copy_independence/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./copy_independence.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/defer_statement/defer_statement.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | defer println("deferred") 5 | println("main") 6 | } 7 | -------------------------------------------------------------------------------- /compliance/tests/defer_statement/defer_statement.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on defer_statement.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export async function main(): Promise { 7 | using __defer = new $.DisposableStack(); 8 | __defer.defer(() => { 9 | console.log("deferred") 10 | }); 11 | console.log("main") 12 | } 13 | 14 | -------------------------------------------------------------------------------- /compliance/tests/defer_statement/expected.log: -------------------------------------------------------------------------------- 1 | main 2 | deferred -------------------------------------------------------------------------------- /compliance/tests/defer_statement/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/defer_statement/index.ts -------------------------------------------------------------------------------- /compliance/tests/destructure_trailing_comma/destructure_trailing_comma.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func returnTwoValues() (int, error) { 4 | return 42, nil 5 | } 6 | 7 | func main() { 8 | // Test destructuring assignment with trailing comma issue 9 | // This should generate: [nref] = returnTwoValues() 10 | // Not: [nref, ] = returnTwoValues() 11 | var nref int 12 | nref, _ = returnTwoValues() 13 | 14 | println("nref:", nref) 15 | } 16 | -------------------------------------------------------------------------------- /compliance/tests/destructure_trailing_comma/expected.log: -------------------------------------------------------------------------------- 1 | nref: 42 -------------------------------------------------------------------------------- /compliance/tests/destructure_trailing_comma/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/destructure_trailing_comma/index.ts -------------------------------------------------------------------------------- /compliance/tests/discarded_channel_receive/discarded_channel_receive.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | ch := make(chan int) 5 | go func() { 6 | ch <- 1 7 | close(ch) // Close the channel to allow the main goroutine to exit 8 | }() 9 | <-ch // Discard the value received from the channel 10 | println("done") // Add a print statement to verify execution 11 | } 12 | -------------------------------------------------------------------------------- /compliance/tests/discarded_channel_receive/expected.log: -------------------------------------------------------------------------------- 1 | done -------------------------------------------------------------------------------- /compliance/tests/discarded_channel_receive/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/discarded_channel_receive/index.ts -------------------------------------------------------------------------------- /compliance/tests/embedded_interface_assertion/expected.log: -------------------------------------------------------------------------------- 1 | Embedded interface assertion successful -------------------------------------------------------------------------------- /compliance/tests/embedded_interface_assertion/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./embedded_interface_assertion.gs.js" 2 | export type { Closer, ReadCloser, Reader } from "./embedded_interface_assertion.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/embedded_interface_null_assertion/expected.log: -------------------------------------------------------------------------------- 1 | true 2 | true 3 | true 4 | 10 5 | 15 6 | true 7 | -------------------------------------------------------------------------------- /compliance/tests/embedded_interface_null_assertion/index.ts: -------------------------------------------------------------------------------- 1 | export { MyReader, StringReader } from "./embedded_interface_null_assertion.gs.js" 2 | export type { Reader } from "./embedded_interface_null_assertion.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/filepath_walkfunc_call/expected.log: -------------------------------------------------------------------------------- 1 | Walking: /test/test.txt size: 50 2 | Walking: /test/test.txt size: 50 3 | -------------------------------------------------------------------------------- /compliance/tests/filepath_walkfunc_call/index.ts: -------------------------------------------------------------------------------- 1 | export { MockFileInfo, MockFilesystem } from "./filepath_walkfunc_call.gs.js" 2 | export type { Filesystem } from "./filepath_walkfunc_call.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/flag_bitwise_op/expected.log: -------------------------------------------------------------------------------- 1 | O_APPEND is set: Expected: O_APPEND is set, Actual: O_APPEND is set 2 | O_TRUNC is not set: Expected: O_TRUNC is not set, Actual: O_TRUNC is not set 3 | O_APPEND is not set: Expected: O_APPEND is not set, Actual: O_APPEND is not set -------------------------------------------------------------------------------- /compliance/tests/flag_bitwise_op/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/flag_bitwise_op/index.ts -------------------------------------------------------------------------------- /compliance/tests/float64/expected.log: -------------------------------------------------------------------------------- 1 | a + b = 5.789999999999999 2 | a - b = -3.3299999999999996 3 | a * b = 5.6088 4 | a / b = 0.26973684210526316 5 | c = 7.89 6 | (a + b) * (c - d) / a = 0 -------------------------------------------------------------------------------- /compliance/tests/float64/float64.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a float64 = 1.23 //nolint:staticcheck 5 | b := 4.56 6 | var c float64 7 | 8 | c = a + b 9 | println("a + b =", c) 10 | 11 | c = a - b 12 | println("a - b =", c) 13 | 14 | c = a * b 15 | println("a * b =", c) 16 | 17 | c = a / b 18 | println("a / b =", c) 19 | 20 | // Assignment 21 | d := 7.89 22 | c = d 23 | println("c =", c) 24 | 25 | // More complex expression 26 | e := (a + b) * (c - d) / a 27 | println("(a + b) * (c - d) / a =", e) 28 | } 29 | -------------------------------------------------------------------------------- /compliance/tests/float64/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/float64/index.ts -------------------------------------------------------------------------------- /compliance/tests/for_init_exprstmt/expected.log: -------------------------------------------------------------------------------- 1 | init_func called 2 | done -------------------------------------------------------------------------------- /compliance/tests/for_init_exprstmt/for_init_exprstmt.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func init_func() { 4 | println("init_func called") 5 | } 6 | 7 | func main() { 8 | // Using a function call in the for loop's init statement 9 | // The condition is false to prevent the loop body from executing during the test, 10 | // focusing only on the init part's translation and execution. 11 | for init_func(); false; { 12 | println("loop body (should not be printed)") 13 | } 14 | println("done") 15 | } 16 | -------------------------------------------------------------------------------- /compliance/tests/for_init_exprstmt/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/for_init_exprstmt/index.ts -------------------------------------------------------------------------------- /compliance/tests/for_init_multi_assign/expected.log: -------------------------------------------------------------------------------- 1 | 0 1 2 | 1 11 -------------------------------------------------------------------------------- /compliance/tests/for_init_multi_assign/for_init_multi_assign.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | for i, j := 0, 1; i < 2; i++ { 5 | println(i, j) 6 | j += 10 // Modify j to see a clearer change in output 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /compliance/tests/for_init_multi_assign/for_init_multi_assign.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on for_init_multi_assign.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export async function main(): Promise { 7 | 8 | // Modify j to see a clearer change in output 9 | for (let i = 0, j = 1; i < 2; i++) { 10 | console.log(i, j) 11 | j += 10 // Modify j to see a clearer change in output 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /compliance/tests/for_init_multi_assign/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/for_init_multi_assign/index.ts -------------------------------------------------------------------------------- /compliance/tests/for_init_value_ok/expected.log: -------------------------------------------------------------------------------- 1 | value: 10 2 | v: 20 3 | -------------------------------------------------------------------------------- /compliance/tests/for_init_value_ok/for_init_value_ok.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | m := make(map[string]int) 5 | m["key1"] = 10 6 | m["key2"] = 20 7 | 8 | // This should trigger the compiler error: for loop initialization with value, ok pattern 9 | for value, ok := m["key1"]; ok; { 10 | println("value:", value) 11 | break 12 | } 13 | 14 | // Another case that might trigger the error 15 | for v, exists := m["key2"]; exists && v > 0; { 16 | println("v:", v) 17 | break 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /compliance/tests/for_init_value_ok/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/for_init_value_ok/index.ts -------------------------------------------------------------------------------- /compliance/tests/for_loop_basic/expected.log: -------------------------------------------------------------------------------- 1 | Starting loop 2 | Iteration: 0 3 | Iteration: 1 4 | Iteration: 2 5 | Loop finished 6 | Starting loop 7 | Iteration: 0 8 | Iteration: 1 9 | Iteration: 2 10 | Iteration: 3 11 | Iteration: 4 12 | Loop finished -------------------------------------------------------------------------------- /compliance/tests/for_loop_basic/for_loop_basic.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | println("Starting loop") 5 | for i := 0; i < 3; i++ { 6 | println("Iteration:", i) 7 | } 8 | println("Loop finished") 9 | 10 | println("Starting loop") 11 | x := 0 12 | for range 5 { 13 | println("Iteration:", x) 14 | x++ 15 | } 16 | println("Loop finished") 17 | } 18 | -------------------------------------------------------------------------------- /compliance/tests/for_loop_basic/for_loop_basic.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on for_loop_basic.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export async function main(): Promise { 7 | console.log("Starting loop") 8 | for (let i = 0; i < 3; i++) { 9 | console.log("Iteration:", i) 10 | } 11 | console.log("Loop finished") 12 | 13 | console.log("Starting loop") 14 | let x = 0 15 | for (let _i = 0; _i < 5; _i++) {{ 16 | console.log("Iteration:", x) 17 | x++ 18 | } 19 | } 20 | console.log("Loop finished") 21 | } 22 | 23 | -------------------------------------------------------------------------------- /compliance/tests/for_loop_basic/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/for_loop_basic/index.ts -------------------------------------------------------------------------------- /compliance/tests/for_loop_condition_only/expected.log: -------------------------------------------------------------------------------- 1 | Current value: 0 2 | Current value: 1 3 | Current value: 2 4 | Loop finished -------------------------------------------------------------------------------- /compliance/tests/for_loop_condition_only/for_loop_condition_only.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | i := 0 5 | for i < 3 { 6 | println("Current value:", i) 7 | i = i + 1 8 | } 9 | println("Loop finished") 10 | } 11 | -------------------------------------------------------------------------------- /compliance/tests/for_loop_condition_only/for_loop_condition_only.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on for_loop_condition_only.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export async function main(): Promise { 7 | let i = 0 8 | for (; i < 3; ) { 9 | console.log("Current value:", i) 10 | i = i + 1 11 | } 12 | console.log("Loop finished") 13 | } 14 | 15 | -------------------------------------------------------------------------------- /compliance/tests/for_loop_condition_only/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/for_loop_condition_only/index.ts -------------------------------------------------------------------------------- /compliance/tests/for_loop_infinite/expected.log: -------------------------------------------------------------------------------- 1 | Looping forever... 2 | Looping forever... 3 | Looping forever... 4 | Loop finished -------------------------------------------------------------------------------- /compliance/tests/for_loop_infinite/for_loop_infinite.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | i := 0 5 | for { 6 | println("Looping forever...") 7 | i++ 8 | if i >= 3 { 9 | break 10 | } 11 | } 12 | println("Loop finished") 13 | } 14 | -------------------------------------------------------------------------------- /compliance/tests/for_loop_infinite/for_loop_infinite.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on for_loop_infinite.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export async function main(): Promise { 7 | let i = 0 8 | for (; ; ) { 9 | console.log("Looping forever...") 10 | i++ 11 | if (i >= 3) { 12 | break 13 | } 14 | } 15 | console.log("Loop finished") 16 | } 17 | 18 | -------------------------------------------------------------------------------- /compliance/tests/for_loop_infinite/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/for_loop_infinite/index.ts -------------------------------------------------------------------------------- /compliance/tests/for_loop_multi_assign_mismatch/expected.log: -------------------------------------------------------------------------------- 1 | value: 42 2 | done 3 | -------------------------------------------------------------------------------- /compliance/tests/for_loop_multi_assign_mismatch/for_loop_multi_assign_mismatch.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func getValues() (int, bool) { 4 | return 42, true 5 | } 6 | 7 | func main() { 8 | // This should trigger the error: multi-assignment in for loop init 9 | // where lhs has 2 variables but rhs has 1 expression that returns 2 values 10 | // but is not a map access 11 | for value, ok := getValues(); ok; { 12 | println("value:", value) 13 | break 14 | } 15 | 16 | println("done") 17 | } 18 | -------------------------------------------------------------------------------- /compliance/tests/for_loop_multi_assign_mismatch/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/for_loop_multi_assign_mismatch/index.ts -------------------------------------------------------------------------------- /compliance/tests/for_post_assign_stmt/expected.log: -------------------------------------------------------------------------------- 1 | looping, i: 0 x_before_post: 0 2 | looping, i: 1 x_before_post: 1 3 | looping, i: 2 x_before_post: 2 4 | final x: 3 -------------------------------------------------------------------------------- /compliance/tests/for_post_assign_stmt/for_post_assign_stmt.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var x int 5 | // The post statement 'x = i' is an AssignStmt 6 | for i := 0; i < 3; x = i { 7 | println("looping, i:", i, "x_before_post:", x) 8 | // Increment i inside the loop body to ensure the loop progresses 9 | // and to clearly separate the loop's own increment from the post statement. 10 | i++ 11 | } 12 | println("final x:", x) 13 | } 14 | -------------------------------------------------------------------------------- /compliance/tests/for_post_assign_stmt/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/for_post_assign_stmt/index.ts -------------------------------------------------------------------------------- /compliance/tests/for_post_exprstmt/expected.log: -------------------------------------------------------------------------------- 1 | loop iteration: 0 2 | counter incremented to 1 3 | loop iteration: 1 4 | counter incremented to 2 5 | done final counter: 2 -------------------------------------------------------------------------------- /compliance/tests/for_post_exprstmt/for_post_exprstmt.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var counter = 0 4 | 5 | func increment_counter() { 6 | counter++ 7 | println("counter incremented to", counter) 8 | } 9 | 10 | func main() { 11 | for i := 0; i < 2; increment_counter() { 12 | println("loop iteration:", i) 13 | // We need to manually increment i or change the condition 14 | // to ensure the loop terminates as increment_counter() in post 15 | // does not affect 'i'. 16 | i++ 17 | } 18 | println("done", "final counter:", counter) 19 | } 20 | -------------------------------------------------------------------------------- /compliance/tests/for_post_exprstmt/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/for_post_exprstmt/index.ts -------------------------------------------------------------------------------- /compliance/tests/for_post_incdec/expected.log: -------------------------------------------------------------------------------- 1 | 0 2 | done -------------------------------------------------------------------------------- /compliance/tests/for_post_incdec/for_post_incdec.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | for i := 0; i < 1; i++ { 5 | println(i) 6 | } 7 | println("done") 8 | } 9 | -------------------------------------------------------------------------------- /compliance/tests/for_post_incdec/for_post_incdec.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on for_post_incdec.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export async function main(): Promise { 7 | for (let i = 0; i < 1; i++) { 8 | console.log(i) 9 | } 10 | console.log("done") 11 | } 12 | 13 | -------------------------------------------------------------------------------- /compliance/tests/for_post_incdec/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/for_post_incdec/index.ts -------------------------------------------------------------------------------- /compliance/tests/for_post_multi_assign/expected.log: -------------------------------------------------------------------------------- 1 | 0 5 2 | 1 4 3 | 2 3 4 | done -------------------------------------------------------------------------------- /compliance/tests/for_post_multi_assign/for_post_multi_assign.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | for i, j := 0, 5; i < j; i, j = i+1, j-1 { 5 | println(i, j) 6 | } 7 | println("done") 8 | } 9 | -------------------------------------------------------------------------------- /compliance/tests/for_post_multi_assign/for_post_multi_assign.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on for_post_multi_assign.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export async function main(): Promise { 7 | for (let i = 0, j = 5; i < j; [i, j] = [i + 1, j - 1]) { 8 | console.log(i, j) 9 | } 10 | console.log("done") 11 | } 12 | 13 | -------------------------------------------------------------------------------- /compliance/tests/for_post_multi_assign/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/for_post_multi_assign/index.ts -------------------------------------------------------------------------------- /compliance/tests/for_range/expected.log: -------------------------------------------------------------------------------- 1 | sum: 9 2 | index: 0 value: 2 3 | index: 1 value: 3 4 | index: 2 value: 4 5 | index: 0 value: a 6 | index: 1 value: b 7 | index: 2 value: c 8 | index: 0 value: 103 9 | index: 1 value: 111 10 | Ranging over slice (no key/value): 11 | Iterating slice 12 | Iterating slice 13 | Iterating slice 14 | Ranging over array (no key/value): 15 | Iterating array 16 | Iterating array 17 | Iterating array 18 | Ranging over string (no key/value): 19 | Iterating string 20 | Iterating string -------------------------------------------------------------------------------- /compliance/tests/for_range/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/for_range/index.ts -------------------------------------------------------------------------------- /compliance/tests/for_range_index_use/expected.log: -------------------------------------------------------------------------------- 1 | Range idx: 0 val: 10 2 | Range idx: 1 val: 20 3 | Range idx: 2 val: 30 4 | Range idx: 3 val: 40 5 | Range idx: 4 val: 50 6 | Sum: 150 -------------------------------------------------------------------------------- /compliance/tests/for_range_index_use/for_range_index_use.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | slice := []int{10, 20, 30, 40, 50} 5 | sum := 0 6 | for idx, val := range slice { 7 | sum += val 8 | println("Range idx:", idx, "val:", val) 9 | } 10 | println("Sum:", sum) 11 | } 12 | -------------------------------------------------------------------------------- /compliance/tests/for_range_index_use/for_range_index_use.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on for_range_index_use.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export async function main(): Promise { 7 | let slice = $.arrayToSlice([10, 20, 30, 40, 50]) 8 | let sum = 0 9 | for (let idx = 0; idx < $.len(slice); idx++) { 10 | const val = slice![idx] 11 | { 12 | sum += val 13 | console.log("Range idx:", idx, "val:", val) 14 | } 15 | } 16 | console.log("Sum:", sum) 17 | } 18 | 19 | -------------------------------------------------------------------------------- /compliance/tests/for_range_index_use/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/for_range_index_use/index.ts -------------------------------------------------------------------------------- /compliance/tests/for_range_key_only/expected.log: -------------------------------------------------------------------------------- 1 | Looping over slice (key only): 2 | 0 3 | 1 4 | 2 5 | Looping over array (key only): 6 | 0 7 | 1 -------------------------------------------------------------------------------- /compliance/tests/for_range_key_only/for_range_key_only.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | s := []int{10, 20, 30} 5 | println("Looping over slice (key only):") 6 | for i := range s { 7 | println(i) 8 | } 9 | // Expected output: 10 | // 0 11 | // 1 12 | // 2 13 | 14 | a := [2]string{"alpha", "beta"} 15 | println("Looping over array (key only):") 16 | for k := range a { 17 | println(k) 18 | } 19 | // Expected output: 20 | // 0 21 | // 1 22 | } 23 | -------------------------------------------------------------------------------- /compliance/tests/for_range_key_only/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/for_range_key_only/index.ts -------------------------------------------------------------------------------- /compliance/tests/for_range_no_vars/expected.log: -------------------------------------------------------------------------------- 1 | Looping over slice (no vars): 2 | 3 3 | Looping over array (no vars): 4 | alpha 5 | beta 6 | 2 7 | Ranging over number (no vars): 8 | 5 -------------------------------------------------------------------------------- /compliance/tests/for_range_no_vars/for_range_no_vars.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | s := []int{10, 20, 30} 5 | println("Looping over slice (no vars):") 6 | count := 0 7 | for range s { 8 | count++ 9 | } 10 | println(count) // Expected output: 3 11 | 12 | a := [2]string{"alpha", "beta"} 13 | println("Looping over array (no vars):") 14 | arrCount := 0 15 | for range a { 16 | println(a[arrCount]) 17 | arrCount++ 18 | } 19 | println(arrCount) // Expected output: 2 20 | 21 | println("Ranging over number (no vars):") 22 | numCount := 0 23 | for range 5 { 24 | numCount++ 25 | } 26 | println(numCount) // Expected output: 5 27 | } 28 | -------------------------------------------------------------------------------- /compliance/tests/for_range_no_vars/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/for_range_no_vars/index.ts -------------------------------------------------------------------------------- /compliance/tests/for_range_value_only/expected.log: -------------------------------------------------------------------------------- 1 | 10 2 | 20 3 | 30 4 | 60 5 | a 6 | b 7 | c 8 | abc 9 | Ranging with blank identifier for value: 10 | 3 -------------------------------------------------------------------------------- /compliance/tests/for_range_value_only/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/for_range_value_only/index.ts -------------------------------------------------------------------------------- /compliance/tests/func_literal/expected.log: -------------------------------------------------------------------------------- 1 | Hello, world -------------------------------------------------------------------------------- /compliance/tests/func_literal/func_literal.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | greet := func(name string) string { 5 | return "Hello, " + name 6 | } 7 | 8 | message := greet("world") 9 | println(message) 10 | } 11 | -------------------------------------------------------------------------------- /compliance/tests/func_literal/func_literal.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on func_literal.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export async function main(): Promise { 7 | let greet = (name: string): string => { 8 | return "Hello, " + name 9 | } 10 | 11 | let message = greet!("world") 12 | console.log(message) 13 | } 14 | 15 | -------------------------------------------------------------------------------- /compliance/tests/func_literal/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/func_literal/index.ts -------------------------------------------------------------------------------- /compliance/tests/function_call_result_assignment/expected.log: -------------------------------------------------------------------------------- 1 | Original struct from function: Expected: function result, Actual: function result 2 | Modified struct from function copy: Expected: modified function result copy, Actual: modified function result copy -------------------------------------------------------------------------------- /compliance/tests/function_call_result_assignment/index.ts: -------------------------------------------------------------------------------- 1 | export { NewMyStruct } from "./function_call_result_assignment.gs.js" 2 | export { MyStruct } from "./function_call_result_assignment.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/function_call_variable_shadowing/expected.log: -------------------------------------------------------------------------------- 1 | Walking: test1 2 | Error: file does not exist 3 | Walking: test2 4 | Walking: test3 5 | Error: file does not exist 6 | Walking: test3 7 | Walking: test 8 | -------------------------------------------------------------------------------- /compliance/tests/function_call_variable_shadowing/index.ts: -------------------------------------------------------------------------------- 1 | export { MockFilesystem } from "./function_call_variable_shadowing.gs.js" 2 | export type { Filesystem } from "./function_call_variable_shadowing.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/function_signature_type/expected.log: -------------------------------------------------------------------------------- 1 | fn1 called with: 10 hello 2 | fn1 result 1: true 3 | nil 4 | fn1 called with: -5 world 5 | fn1 result 2: false 6 | a was not positive 7 | fn2 called with: 5 hello 8 | fn2 result 1: true 9 | fn2 called with: 3 hey 10 | fn2 result 2: true 11 | fn3 called 12 | fn4 called with: 1 13 | 14 | fn4 called with: 2 15 | one 16 | 17 | fn4 called with: 3 18 | two 19 | three -------------------------------------------------------------------------------- /compliance/tests/function_signature_type/index.ts: -------------------------------------------------------------------------------- 1 | export { NewMyError } from "./function_signature_type.gs.js" 2 | export { MyError } from "./function_signature_type.gs.js" 3 | export type { Func1, Func2, Func3, Func4 } from "./function_signature_type.gs.js" 4 | -------------------------------------------------------------------------------- /compliance/tests/function_type_assertion/expected.log: -------------------------------------------------------------------------------- 1 | Hello, World 2 | 8 3 | Hello, Gopher 4 | 30 5 | Hello, Struct 6 | 15 7 | Hello, Map 8 | 3 9 | Hello, Slice 10 | 18 11 | true 12 | false 13 | false 14 | Nil interface assertion correct 15 | Wrong function type assertion correct -------------------------------------------------------------------------------- /compliance/tests/function_type_assertion/index.ts: -------------------------------------------------------------------------------- 1 | export { FuncContainer } from "./function_type_assertion.gs.js" 2 | export type { Adder, Greeter } from "./function_type_assertion.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/generic_index_assignment/expected.log: -------------------------------------------------------------------------------- 1 | slice[0]: 1 2 | slice[1]: 42 3 | slice[2]: 3 4 | test finished -------------------------------------------------------------------------------- /compliance/tests/generic_index_assignment/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/generic_index_assignment/index.ts -------------------------------------------------------------------------------- /compliance/tests/generics/expected.log: -------------------------------------------------------------------------------- 1 | === Basic Generic Function === 2 | 42 3 | hello 4 | true 5 | === Comparable Constraint === 6 | true 7 | false 8 | true 9 | false 10 | === Union Constraint === 11 | 5 12 | 5 13 | === Generic Struct === 14 | 10 15 | 10 16 | 20 17 | foo 18 | foo 19 | bar 20 | === Generic Slice Operations === 21 | 1 22 | 2 23 | 3 24 | 4 25 | a 26 | b 27 | c 28 | === Type Inference === 29 | 100 30 | 200 -------------------------------------------------------------------------------- /compliance/tests/generics/index.ts: -------------------------------------------------------------------------------- 1 | export { Pair } from "./generics.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/generics_basic/expected.log: -------------------------------------------------------------------------------- 1 | 10 2 | hello 3 | true 4 | -------------------------------------------------------------------------------- /compliance/tests/generics_basic/generics_basic.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func printVal[T any](val T) { 4 | println(val) 5 | } 6 | 7 | func main() { 8 | printVal(10) 9 | printVal("hello") 10 | printVal(true) 11 | } 12 | -------------------------------------------------------------------------------- /compliance/tests/generics_basic/generics_basic.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on generics_basic.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export function printVal(val: T): void { 7 | console.log(val) 8 | } 9 | 10 | export async function main(): Promise { 11 | printVal(10) 12 | printVal("hello") 13 | printVal(true) 14 | } 15 | 16 | -------------------------------------------------------------------------------- /compliance/tests/generics_basic/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/generics_basic/index.ts -------------------------------------------------------------------------------- /compliance/tests/generics_interface/expected.log: -------------------------------------------------------------------------------- 1 | === Generic Interface Test === 2 | Int ValueContainer result: 42 3 | Int ValueContainer size: 1 4 | String ValueContainer result: hello 5 | String ValueContainer size: 1 6 | String comparison equal: true 7 | String comparison not equal: false 8 | String comparison -1: -1 9 | String comparison 1: 1 10 | String comparison 0: 0 11 | -------------------------------------------------------------------------------- /compliance/tests/generics_interface/index.ts: -------------------------------------------------------------------------------- 1 | export { StringValueContainer, ValueContainer } from "./generics_interface.gs.js" 2 | export type { Comparable, Container } from "./generics_interface.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/generics_leading_int/expected.log: -------------------------------------------------------------------------------- 1 | 123 abc456 false 2 | 456 def123 false 3 | 0 abc false 4 | 0 true 5 | 123 false 6 | -------------------------------------------------------------------------------- /compliance/tests/generics_leading_int/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/generics_leading_int/index.ts -------------------------------------------------------------------------------- /compliance/tests/go_type_assertion/expected.log: -------------------------------------------------------------------------------- 1 | main finished 2 | goroutine executed 3 | -------------------------------------------------------------------------------- /compliance/tests/go_type_assertion/go_type_assertion.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var x interface{} = func() { 5 | println("goroutine executed") 6 | } 7 | go x.(func())() 8 | println("main finished") 9 | } 10 | -------------------------------------------------------------------------------- /compliance/tests/go_type_assertion/go_type_assertion.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on go_type_assertion.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export async function main(): Promise { 7 | let x: null | any = (): void => { 8 | console.log("goroutine executed") 9 | } 10 | queueMicrotask(() => { 11 | $.mustTypeAssert<(() => void) | null>(x, {kind: $.TypeKind.Function})!() 12 | }) 13 | console.log("main finished") 14 | } 15 | 16 | -------------------------------------------------------------------------------- /compliance/tests/go_type_assertion/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/go_type_assertion/index.ts -------------------------------------------------------------------------------- /compliance/tests/goroutines/expected.log: -------------------------------------------------------------------------------- 1 | 0 Main: Starting workers 2 | 1 Main: Workers started 3 | 10 Worker 0 starting 4 | 11 Worker 1 starting 5 | 12 Worker 2 starting 6 | 20 Worker 0 done 7 | 21 Worker 1 done 8 | 22 Worker 2 done 9 | 40 Another worker: test 10 | 50 Anonymous function worker 11 | 100 Main: All workers completed 12 | done -------------------------------------------------------------------------------- /compliance/tests/goroutines/index.ts: -------------------------------------------------------------------------------- 1 | export { Message } from "./goroutines.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/goroutines_anonymous/expected.log: -------------------------------------------------------------------------------- 1 | anonymous function worker -------------------------------------------------------------------------------- /compliance/tests/goroutines_anonymous/goroutines_anonymous.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | // Start an anonymous function worker 5 | msgs := make(chan string, 1) 6 | go func() { 7 | msgs <- "anonymous function worker" 8 | }() 9 | println(<-msgs) 10 | } 11 | -------------------------------------------------------------------------------- /compliance/tests/goroutines_anonymous/goroutines_anonymous.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on goroutines_anonymous.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export async function main(): Promise { 7 | // Start an anonymous function worker 8 | let msgs = $.makeChannel(1, "", 'both') 9 | queueMicrotask(async () => { 10 | await $.chanSend(msgs, "anonymous function worker") 11 | }) 12 | console.log(await $.chanRecv(msgs)) 13 | } 14 | 15 | -------------------------------------------------------------------------------- /compliance/tests/goroutines_anonymous/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/goroutines_anonymous/index.ts -------------------------------------------------------------------------------- /compliance/tests/goroutines_selector/expected.log: -------------------------------------------------------------------------------- 1 | Foo.Bar called 2 | main done 3 | -------------------------------------------------------------------------------- /compliance/tests/goroutines_selector/goroutines_selector.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Foo struct { 4 | done chan bool 5 | } 6 | 7 | func NewFoo() *Foo { 8 | return &Foo{done: make(chan bool)} 9 | } 10 | 11 | func (f *Foo) Bar() { 12 | println("Foo.Bar called") 13 | f.done <- true 14 | } 15 | 16 | func main() { 17 | f := NewFoo() 18 | go f.Bar() 19 | <-f.done // Wait for the goroutine to complete 20 | println("main done") 21 | } 22 | -------------------------------------------------------------------------------- /compliance/tests/goroutines_selector/index.ts: -------------------------------------------------------------------------------- 1 | export { NewFoo } from "./goroutines_selector.gs.js" 2 | export { Foo } from "./goroutines_selector.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/hex_escape_sequence/expected.log: -------------------------------------------------------------------------------- 1 | Appended raw string with \x: \x 2 | Raw string with \x: \x 3 | Raw string with \xG: \xG 4 | Interpreted string: A 5 | -------------------------------------------------------------------------------- /compliance/tests/hex_escape_sequence/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/hex_escape_sequence/index.ts -------------------------------------------------------------------------------- /compliance/tests/if_statement/expected.log: -------------------------------------------------------------------------------- 1 | Odd: Expected: Odd, Actual: Odd -------------------------------------------------------------------------------- /compliance/tests/if_statement/if_statement.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | // === If Statement === 5 | n := 7 6 | if n%2 == 0 { 7 | println("Even: Expected: (no output)") 8 | } else { 9 | println("Odd: Expected: Odd, Actual: Odd") 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /compliance/tests/if_statement/if_statement.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on if_statement.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export async function main(): Promise { 7 | // === If Statement === 8 | let n = 7 9 | if (n % 2 == 0) { 10 | console.log("Even: Expected: (no output)") 11 | } 12 | else { 13 | console.log("Odd: Expected: Odd, Actual: Odd") 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /compliance/tests/if_statement/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/if_statement/index.ts -------------------------------------------------------------------------------- /compliance/tests/import_interface/expected.log: -------------------------------------------------------------------------------- 1 | Testing os.FileInfo interface preservation 2 | -------------------------------------------------------------------------------- /compliance/tests/import_interface/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/import_interface/index.ts -------------------------------------------------------------------------------- /compliance/tests/import_named_multiple/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/import_named_multiple/index.ts -------------------------------------------------------------------------------- /compliance/tests/index_expr_destructuring/expected.log: -------------------------------------------------------------------------------- 1 | intArray[0]: 42 2 | stringSlice[1]: hello 3 | matrix[0][1]: 42 4 | intArray[1]: 24 -------------------------------------------------------------------------------- /compliance/tests/index_expr_destructuring/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/index_expr_destructuring/index.ts -------------------------------------------------------------------------------- /compliance/tests/index_expr_type_assertion/expected.log: -------------------------------------------------------------------------------- 1 | slice[1] as int: 42 2 | m[key2] as int: 123 -------------------------------------------------------------------------------- /compliance/tests/index_expr_type_assertion/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/index_expr_type_assertion/index.ts -------------------------------------------------------------------------------- /compliance/tests/inline_function_type_cast/expected.log: -------------------------------------------------------------------------------- 1 | Hello, Inline World 2 | 12 -------------------------------------------------------------------------------- /compliance/tests/inline_function_type_cast/index.ts: -------------------------------------------------------------------------------- 1 | export type { Greeter } from "./inline_function_type_cast.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/inline_interface_type_assertion/expected.log: -------------------------------------------------------------------------------- 1 | Greet assertion successful: Hello from Greeter 2 | NonExistentMethod assertion failed as expected 3 | Inline String assertion successful: MyStringer implementation 4 | k.(interface{ String() string }) successful: MyStringer implementation 5 | l.(*struct{ Name string }) successful, ptr is nil as expected -------------------------------------------------------------------------------- /compliance/tests/inline_interface_type_assertion/index.ts: -------------------------------------------------------------------------------- 1 | export { Greeter, MyStringer } from "./inline_interface_type_assertion.gs.js" 2 | export type { Stringer } from "./inline_interface_type_assertion.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/interface_embedding/expected.log: -------------------------------------------------------------------------------- 1 | Custom name: custom_name.txt 2 | File name: test.txt 3 | Lock successful 4 | Unlock successful 5 | Wrote bytes: 9 6 | Read bytes: 5 7 | ReadAt bytes: 5 8 | Seek position: 0 9 | Truncate successful 10 | Close successful 11 | Qualified file name: qualified.txt 12 | Qualified close successful 13 | Qualified wrote bytes: 14 14 | -------------------------------------------------------------------------------- /compliance/tests/interface_embedding/index.ts: -------------------------------------------------------------------------------- 1 | export { MockFile } from "./interface_embedding.gs.js" 2 | export type { File } from "./interface_embedding.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/interface_embedding/subpkg/index.ts: -------------------------------------------------------------------------------- 1 | export { NewMockFile } from "./subpkg.gs.js" 2 | export { MockFile } from "./subpkg.gs.js" 3 | export type { File } from "./subpkg.gs.js" 4 | -------------------------------------------------------------------------------- /compliance/tests/interface_method_comments/expected.log: -------------------------------------------------------------------------------- 1 | Test started 2 | Test finished -------------------------------------------------------------------------------- /compliance/tests/interface_method_comments/index.ts: -------------------------------------------------------------------------------- 1 | export type { MyInterface } from "./interface_method_comments.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/interface_method_comments/interface_method_comments.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type MyInterface interface { 4 | // MyMethod is a method with a comment 5 | MyMethod() 6 | } 7 | 8 | func main() { 9 | // This test verifies that comments on interface methods are preserved. 10 | println("Test started") 11 | // No actual execution needed, just compilation check. 12 | println("Test finished") 13 | } 14 | -------------------------------------------------------------------------------- /compliance/tests/interface_multi_param_return/expected.log: -------------------------------------------------------------------------------- 1 | Processing successful 2 | Main: Success reported 3 | Processing successful 4 | Main: Success reported -------------------------------------------------------------------------------- /compliance/tests/interface_multi_param_return/index.ts: -------------------------------------------------------------------------------- 1 | export { MyProcessor } from "./interface_multi_param_return.gs.js" 2 | export type { MultiParamReturner } from "./interface_multi_param_return.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/interface_to_interface_type_assertion/expected.log: -------------------------------------------------------------------------------- 1 | Type assertion successful -------------------------------------------------------------------------------- /compliance/tests/interface_to_interface_type_assertion/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./interface_to_interface_type_assertion.gs.js" 2 | export type { MyInterface, MyOtherInterface } from "./interface_to_interface_type_assertion.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/interface_to_interface_type_assertion/interface_to_interface_type_assertion.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type MyInterface interface { 4 | Method1() int 5 | } 6 | 7 | type MyStruct struct { 8 | Value int 9 | } 10 | 11 | func (m MyStruct) Method1() int { 12 | return m.Value 13 | } 14 | 15 | type MyOtherInterface interface { 16 | Method1() int 17 | } 18 | 19 | func main() { 20 | var i MyInterface 21 | s := MyStruct{Value: 10} 22 | i = s 23 | 24 | _, ok := i.(MyOtherInterface) 25 | if ok { 26 | println("Type assertion successful") 27 | } else { 28 | println("Type assertion failed") 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /compliance/tests/interface_type_assertion/expected.log: -------------------------------------------------------------------------------- 1 | Type assertion successful 2 | Type assertion failed 3 | type assertion success 10 -------------------------------------------------------------------------------- /compliance/tests/interface_type_assertion/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./interface_type_assertion.gs.js" 2 | export type { MyInterface } from "./interface_type_assertion.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/interface_type_reference/expected.log: -------------------------------------------------------------------------------- 1 | Stat call successful 2 | -------------------------------------------------------------------------------- /compliance/tests/interface_type_reference/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStorage } from "./interface_type_reference.gs.js" 2 | export type { Basic } from "./interface_type_reference.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/iterator_simple/expected.log: -------------------------------------------------------------------------------- 1 | Testing single value iterator: 2 | value: 0 3 | value: 1 4 | value: 2 5 | Testing key-value iterator: 6 | key: 0 value: a 7 | key: 1 value: b 8 | key: 2 value: c 9 | test finished 10 | -------------------------------------------------------------------------------- /compliance/tests/iterator_simple/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/iterator_simple/index.ts -------------------------------------------------------------------------------- /compliance/tests/keyed_array_literal/expected.log: -------------------------------------------------------------------------------- 1 | arr1[0]: 2 | arr1[1]: first 3 | arr1[2]: 4 | arr1[3]: third 5 | arr1[4]: 6 | arr2[10]: 7 | arr2[11]: at index 11 8 | arr2[12]: 9 | arr2[13]: at index 13 10 | arr2[14]: 11 | arr3[0]: 1 12 | arr3[1]: 2 13 | arr3[2]: 0 14 | arr3[5]: 100 15 | arr3[6]: 200 16 | arr3[7]: 0 17 | slice1[0]: 18 | slice1[1]: 19 | slice1[2]: second 20 | slice1[3]: 21 | slice1[4]: fourth 22 | keyed array literal test completed 23 | -------------------------------------------------------------------------------- /compliance/tests/keyed_array_literal/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/keyed_array_literal/index.ts -------------------------------------------------------------------------------- /compliance/tests/labeled_statement/actual.log: -------------------------------------------------------------------------------- 1 | continue test i: 0 2 | continue test i: 2 3 | x: 42 4 | this should be skipped 5 | y: 100 6 | i: 0 7 | i: 1 8 | i: 2 9 | nested: 0 0 10 | nested: 0 2 11 | nested: 1 0 12 | nested: 2 0 13 | nested: 2 2 14 | test finished 15 | -------------------------------------------------------------------------------- /compliance/tests/labeled_statement/expected.log: -------------------------------------------------------------------------------- 1 | continue test i: 0 2 | continue test i: 2 3 | x: 42 4 | y: 100 5 | i: 0 6 | i: 1 7 | i: 2 8 | nested: 0 0 9 | nested: 0 2 10 | nested: 1 0 11 | test finished 12 | -------------------------------------------------------------------------------- /compliance/tests/labeled_statement/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/labeled_statement/index.ts -------------------------------------------------------------------------------- /compliance/tests/labeled_statement/skip-test: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/labeled_statement/skip-test -------------------------------------------------------------------------------- /compliance/tests/linkname/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/linkname/index.ts -------------------------------------------------------------------------------- /compliance/tests/linkname/linkname.go: -------------------------------------------------------------------------------- 1 | //go:build linkname 2 | 3 | package main 4 | 5 | import ( 6 | "time" 7 | _ "unsafe" 8 | ) 9 | 10 | //go:linkname timeNow time.Now 11 | func timeNow() time.Time { 12 | return time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC) 13 | } 14 | 15 | func main() { 16 | now := time.Now() 17 | println("overridden time now", now.String()) 18 | } 19 | -------------------------------------------------------------------------------- /compliance/tests/linkname/skip-test: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/linkname/skip-test -------------------------------------------------------------------------------- /compliance/tests/make_generic_type/expected.log: -------------------------------------------------------------------------------- 1 | Value exists: true 2 | String exists: true 3 | -------------------------------------------------------------------------------- /compliance/tests/make_generic_type/index.ts: -------------------------------------------------------------------------------- 1 | export type { Ints } from "./make_generic_type.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/make_named_types/expected.log: -------------------------------------------------------------------------------- 1 | Length: 5 2 | Value: 42 -------------------------------------------------------------------------------- /compliance/tests/make_named_types/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/make_named_types/index.ts -------------------------------------------------------------------------------- /compliance/tests/make_named_types/make_named_types.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | // Test make() calls with named types as the first argument 5 | // This tests the compiler's ability to handle make() with type aliases/named types 6 | // rather than direct type expressions like []int or map[string]int 7 | 8 | type MySlice []int 9 | var s MySlice = make(MySlice, 5) 10 | println("Length:", len(s)) 11 | 12 | // Test make() with named map type 13 | type MyMap map[string]int 14 | var m MyMap = make(MyMap) 15 | m["test"] = 42 16 | println("Value:", m["test"]) 17 | } 18 | -------------------------------------------------------------------------------- /compliance/tests/make_selector_type/expected.log: -------------------------------------------------------------------------------- 1 | Created map: 1 2 | Content: hello world 3 | -------------------------------------------------------------------------------- /compliance/tests/make_selector_type/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/make_selector_type/index.ts -------------------------------------------------------------------------------- /compliance/tests/make_selector_type/make_selector_type.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | // Test make() with a map type 5 | // This verifies that our fix for selector expressions in make() calls works 6 | // The original issue was "unhandled make call" when using selector expressions 7 | 8 | mfs := make(map[string][]byte) 9 | mfs["test.txt"] = []byte("hello world") 10 | println("Created map:", len(mfs)) 11 | println("Content:", string(mfs["test.txt"])) 12 | } 13 | -------------------------------------------------------------------------------- /compliance/tests/make_slice/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/make_slice/index.ts -------------------------------------------------------------------------------- /compliance/tests/map_assign_blank_both/expected.log: -------------------------------------------------------------------------------- 1 | Assigning m["one"] to _, _ (key exists) 2 | Assigning m["two"] to _, _ (key does not exist) 3 | done -------------------------------------------------------------------------------- /compliance/tests/map_assign_blank_both/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/map_assign_blank_both/index.ts -------------------------------------------------------------------------------- /compliance/tests/map_assign_blank_both/map_assign_blank_both.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | m := make(map[string]int) 5 | m["one"] = 1 6 | println("Assigning m[\"one\"] to _, _ (key exists)") 7 | _, _ = m["one"] 8 | println("Assigning m[\"two\"] to _, _ (key does not exist)") 9 | _, _ = m["two"] 10 | println("done") 11 | } 12 | -------------------------------------------------------------------------------- /compliance/tests/map_assign_blank_both/map_assign_blank_both.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on map_assign_blank_both.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export async function main(): Promise { 7 | let m = $.makeMap() 8 | $.mapSet(m, "one", 1) 9 | console.log("Assigning m[\"one\"] to _, _ (key exists)") 10 | ;[, ] = $.mapGet(m, "one", 0) 11 | console.log("Assigning m[\"two\"] to _, _ (key does not exist)") 12 | ;[, ] = $.mapGet(m, "two", 0) 13 | console.log("done") 14 | } 15 | 16 | -------------------------------------------------------------------------------- /compliance/tests/map_support/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/map_support/index.ts -------------------------------------------------------------------------------- /compliance/tests/map_type_assertion/expected.log: -------------------------------------------------------------------------------- 1 | Age: 30 2 | Second type assertion (map[string]string) failed as expected 3 | Third type assertion (map[int]int) failed as expected -------------------------------------------------------------------------------- /compliance/tests/map_type_assertion/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/map_type_assertion/index.ts -------------------------------------------------------------------------------- /compliance/tests/method_binding/expected.log: -------------------------------------------------------------------------------- 1 | Initial value: 0 2 | After calling Increment via parameter: 1 3 | After calling Increment via variable: 2 4 | Value from assigned method: 2 5 | Value from method via parameter: 2 6 | Initial value2: 10 7 | After calling IncrementValue via parameter (should be unchanged): 10 8 | After calling IncrementValue via variable (should be unchanged): 10 9 | Value from assigned value method: 10 10 | -------------------------------------------------------------------------------- /compliance/tests/method_binding/index.ts: -------------------------------------------------------------------------------- 1 | export { Counter } from "./method_binding.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/method_call_on_pointer_receiver/expected.log: -------------------------------------------------------------------------------- 1 | Method call on pointer (structPointer): Expected: hello world, Actual: hello world -------------------------------------------------------------------------------- /compliance/tests/method_call_on_pointer_receiver/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./method_call_on_pointer_receiver.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/method_call_on_pointer_receiver/method_call_on_pointer_receiver.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type MyStruct struct { 4 | MyInt int 5 | MyString string 6 | } 7 | 8 | // GetMyString returns the MyString field. 9 | func (m *MyStruct) GetMyString() string { 10 | return m.MyString 11 | } 12 | 13 | func main() { 14 | structPointer := &MyStruct{MyInt: 4, MyString: "hello world"} 15 | // === Method Call on Pointer Receiver === 16 | // Calling a method with a pointer receiver (*MyStruct) using a pointer variable. 17 | println("Method call on pointer (structPointer): Expected: hello world, Actual: " + structPointer.GetMyString()) 18 | } 19 | -------------------------------------------------------------------------------- /compliance/tests/method_call_on_pointer_via_value/expected.log: -------------------------------------------------------------------------------- 1 | Value after pointer method call via value: Expected: 200, Actual: 200 -------------------------------------------------------------------------------- /compliance/tests/method_call_on_pointer_via_value/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./method_call_on_pointer_via_value.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/method_call_on_value_receiver/expected.log: -------------------------------------------------------------------------------- 1 | Method call on value: Expected: bar, Actual: bar -------------------------------------------------------------------------------- /compliance/tests/method_call_on_value_receiver/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./method_call_on_value_receiver.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/method_call_on_value_receiver/method_call_on_value_receiver.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type MyStruct struct { 4 | MyInt int 5 | MyString string 6 | } 7 | 8 | // GetMyString returns the MyString field. 9 | func (m MyStruct) GetMyString() string { 10 | return m.MyString 11 | } 12 | 13 | func main() { 14 | ms := MyStruct{MyInt: 1, MyString: "bar"} 15 | println("Method call on value: Expected: bar, Actual:", ms.GetMyString()) 16 | } 17 | -------------------------------------------------------------------------------- /compliance/tests/method_call_on_value_via_pointer/expected.log: -------------------------------------------------------------------------------- 1 | Value via pointer call: Expected: 100, Actual: 100 2 | Value via pointer call after modification: Expected: 200, Actual: 200 -------------------------------------------------------------------------------- /compliance/tests/method_call_on_value_via_pointer/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./method_call_on_value_via_pointer.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/missing_valueof_error/expected.log: -------------------------------------------------------------------------------- 1 | Initial capacity: 100000 2 | Initial length: 0 3 | After append length: 11 4 | Buffer was freed 5 | -------------------------------------------------------------------------------- /compliance/tests/missing_valueof_error/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/missing_valueof_error/index.ts -------------------------------------------------------------------------------- /compliance/tests/multiple_return_values/expected.log: -------------------------------------------------------------------------------- 1 | 42 2 | hello 3 | true 4 | 42 5 | true 6 | hello -------------------------------------------------------------------------------- /compliance/tests/multiple_return_values/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/multiple_return_values/index.ts -------------------------------------------------------------------------------- /compliance/tests/multiple_return_values/multiple_return_values.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func multipleReturnValues() (int, string, bool) { 4 | return 42, "hello", true 5 | } 6 | 7 | func main() { 8 | a, b, c := multipleReturnValues() 9 | println(a) 10 | println(b) 11 | println(c) 12 | 13 | x, _, z := multipleReturnValues() 14 | println(x) 15 | println(z) 16 | 17 | _, y, _ := multipleReturnValues() 18 | println(y) 19 | } 20 | -------------------------------------------------------------------------------- /compliance/tests/named_function_type_call/expected.log: -------------------------------------------------------------------------------- 1 | Walking: /test size: 50 2 | Walking: /test size: 50 3 | Walking: /test size: 50 4 | Processing pattern: *.go 5 | Processing pattern: test 6 | -------------------------------------------------------------------------------- /compliance/tests/named_function_type_call/index.ts: -------------------------------------------------------------------------------- 1 | export { MockFileInfo, MockFilesystem } from "./named_function_type_call.gs.js" 2 | export type { FileInfo, Filesystem, WalkFunc } from "./named_function_type_call.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/named_return_method/expected.log: -------------------------------------------------------------------------------- 1 | 5 2 | nil 3 | Hello 4 | 6 5 | nil 6 | World! 7 | 30 8 | high 9 | true 10 | 10 11 | low 12 | true 13 | -2 14 | invalid 15 | false -------------------------------------------------------------------------------- /compliance/tests/named_return_method/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/named_return_method/index.ts -------------------------------------------------------------------------------- /compliance/tests/named_return_multiple/expected.log: -------------------------------------------------------------------------------- 1 | 20 2 | greater than five 3 | true 4 | 6 5 | five or less 6 | false 7 | 100 8 | 9 | false 10 | 200 11 | set string for val 2 12 | false 13 | 0 14 | 15 | false 16 | -------------------------------------------------------------------------------- /compliance/tests/named_return_multiple/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/named_return_multiple/index.ts -------------------------------------------------------------------------------- /compliance/tests/named_slice_wrapper/expected.log: -------------------------------------------------------------------------------- 1 | Length: 2 2 | Slice length: 2 -------------------------------------------------------------------------------- /compliance/tests/named_slice_wrapper/index.ts: -------------------------------------------------------------------------------- 1 | export type { ByName } from "./named_slice_wrapper.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/named_slice_wrapper/named_slice_wrapper.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "os" 4 | 5 | type ByName []os.FileInfo 6 | 7 | func (a ByName) Len() int { return len(a) } 8 | func (a ByName) Less(i, j int) bool { return a[i].Name() < a[j].Name() } 9 | func (a ByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] } 10 | 11 | func main() { 12 | // Create a ByName instance to test the wrapper 13 | var files ByName = make([]os.FileInfo, 2) 14 | println("Length:", files.Len()) 15 | 16 | // Test type conversion 17 | var slice []os.FileInfo = []os.FileInfo(files) 18 | println("Slice length:", len(slice)) 19 | } 20 | -------------------------------------------------------------------------------- /compliance/tests/named_type_wrapper/expected.log: -------------------------------------------------------------------------------- 1 | Mode value: 420 2 | Mode string: mode 3 | Status mode: 493 4 | Status size: 1024 5 | Generic mode: 511 6 | -------------------------------------------------------------------------------- /compliance/tests/named_type_wrapper/index.ts: -------------------------------------------------------------------------------- 1 | export { FileStatus } from "./named_type_wrapper.gs.js" 2 | export type { MyFileMode } from "./named_type_wrapper.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/named_types_valueof/index.ts: -------------------------------------------------------------------------------- 1 | export type { LocalBool, LocalFloat, LocalInt, LocalLevel1, LocalLevel2, LocalLevel3, LocalString, LocalUint } from "./named_types_valueof.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/named_types_valueof/subpkg/index.ts: -------------------------------------------------------------------------------- 1 | export { BoolValue, FloatValue, GetCombinedFlags, GetLevelValue, IntValue, LevelValue, StringValue, UintValue } from "./types.gs.js" 2 | export type { Level1, Level2, Level3, MyBool, MyFloat, MyInt, MyString, MyUint } from "./types.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/nil_channel/expected.log: -------------------------------------------------------------------------------- 1 | Test 1: Select with nil channel and default 2 | PASS: Default case executed correctly 3 | 4 | Test 2: Select with multiple nil channels and default 5 | PASS: Default case executed with multiple nil channels 6 | 7 | Test 3: Select with mix of nil and valid channels 8 | PASS: Received from valid channel: true 9 | 10 | All nil channel tests completed 11 | -------------------------------------------------------------------------------- /compliance/tests/nil_channel/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/nil_channel/index.ts -------------------------------------------------------------------------------- /compliance/tests/nil_pkg_pointer_dereference/expected.log: -------------------------------------------------------------------------------- 1 | Mode: 420 2 | File is nil: true 3 | Zero Mode: 0 4 | Zero File is nil: true -------------------------------------------------------------------------------- /compliance/tests/nil_pkg_pointer_dereference/index.ts: -------------------------------------------------------------------------------- 1 | export { TestStruct } from "./nil_pkg_pointer_dereference.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/nil_pkg_pointer_dereference/nil_pkg_pointer_dereference.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "os" 4 | 5 | type TestStruct struct { 6 | Mode os.FileMode 7 | File *os.File 8 | } 9 | 10 | func main() { 11 | // Test initialized struct 12 | s := TestStruct{ 13 | Mode: 420, // 420 in decimal 14 | File: nil, 15 | } 16 | 17 | println("Mode:", int(s.Mode)) 18 | println("File is nil:", s.File == nil) 19 | 20 | // Test zero values 21 | var zero TestStruct 22 | println("Zero Mode:", int(zero.Mode)) 23 | println("Zero File is nil:", zero.File == nil) 24 | } 25 | -------------------------------------------------------------------------------- /compliance/tests/nil_pkg_pointer_dereference/no-all-deps: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/nil_pkg_pointer_dereference/output.txt: -------------------------------------------------------------------------------- 1 | # command-line-arguments 2 | ../../../cmd/goscript/main.go:17:38: undefined: CompileCommands 3 | -------------------------------------------------------------------------------- /compliance/tests/nullable_function_param_call/expected.log: -------------------------------------------------------------------------------- 1 | Walking: /test size: 50 2 | Walking: /test size: 50 3 | Process result: processed: hello 4 | -------------------------------------------------------------------------------- /compliance/tests/nullable_function_param_call/index.ts: -------------------------------------------------------------------------------- 1 | export { SkipDir } from "./nullable_function_param_call.gs.js" 2 | export { MockFileInfo, MockFilesystem } from "./nullable_function_param_call.gs.js" 3 | export type { FileInfo, Filesystem, ProcessFunc, WalkFunc } from "./nullable_function_param_call.gs.js" 4 | -------------------------------------------------------------------------------- /compliance/tests/octal_literals/expected.log: -------------------------------------------------------------------------------- 1 | perm1: 511 2 | perm2: 438 3 | perm3: 420 4 | perm4: 493 5 | test finished 6 | -------------------------------------------------------------------------------- /compliance/tests/octal_literals/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/octal_literals/index.ts -------------------------------------------------------------------------------- /compliance/tests/octal_literals/octal_literals.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | // Test octal literals that cause TypeScript compilation errors 5 | perm1 := 0o777 6 | perm2 := 0o666 7 | perm3 := 0o644 8 | perm4 := 0o755 9 | 10 | println("perm1:", perm1) 11 | println("perm2:", perm2) 12 | println("perm3:", perm3) 13 | println("perm4:", perm4) 14 | 15 | println("test finished") 16 | } 17 | -------------------------------------------------------------------------------- /compliance/tests/octal_literals/octal_literals.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on octal_literals.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export async function main(): Promise { 7 | // Test octal literals that cause TypeScript compilation errors 8 | let perm1 = 0o777 9 | let perm2 = 0o666 10 | let perm3 = 0o644 11 | let perm4 = 0o755 12 | 13 | console.log("perm1:", perm1) 14 | console.log("perm2:", perm2) 15 | console.log("perm3:", perm3) 16 | console.log("perm4:", perm4) 17 | 18 | console.log("test finished") 19 | } 20 | 21 | -------------------------------------------------------------------------------- /compliance/tests/os_filemode_struct/expected.log: -------------------------------------------------------------------------------- 1 | File mode: 420 2 | File name: test.txt 3 | Mode type: 493 4 | -------------------------------------------------------------------------------- /compliance/tests/os_filemode_struct/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/os_filemode_struct/index.ts -------------------------------------------------------------------------------- /compliance/tests/os_filemode_struct/os_filemode_struct.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "os" 4 | 5 | type file struct { 6 | mode os.FileMode 7 | name string 8 | } 9 | 10 | func main() { 11 | f := file{ 12 | mode: os.FileMode(0o644), 13 | name: "test.txt", 14 | } 15 | 16 | println("File mode:", int(f.mode)) 17 | println("File name:", f.name) 18 | 19 | // Test type assertion 20 | var mode os.FileMode = os.FileMode(0o755) 21 | println("Mode type:", int(mode)) 22 | } 23 | -------------------------------------------------------------------------------- /compliance/tests/package_import/.gitignore: -------------------------------------------------------------------------------- 1 | !go.mod -------------------------------------------------------------------------------- /compliance/tests/package_import/expected.log: -------------------------------------------------------------------------------- 1 | Hello, world -------------------------------------------------------------------------------- /compliance/tests/package_import/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import/package_import.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/aperturerobotics/goscript/compliance/tests/package_import/subpkg" 5 | ) 6 | 7 | func main() { 8 | println(subpkg.Greet("world")) 9 | } 10 | -------------------------------------------------------------------------------- /compliance/tests/package_import/package_import.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on package_import.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | import * as subpkg from "@goscript/github.com/aperturerobotics/goscript/compliance/tests/package_import/subpkg/index.js" 7 | 8 | export async function main(): Promise { 9 | console.log(subpkg.Greet("world")) 10 | } 11 | 12 | -------------------------------------------------------------------------------- /compliance/tests/package_import/subpkg/index.ts: -------------------------------------------------------------------------------- 1 | export { Greet } from "./subpkg.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/package_import/subpkg/subpkg.go: -------------------------------------------------------------------------------- 1 | package subpkg 2 | 3 | func Greet(name string) string { 4 | return "Hello, " + name 5 | } 6 | -------------------------------------------------------------------------------- /compliance/tests/package_import/subpkg/subpkg.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on subpkg/subpkg.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export function Greet(name: string): string { 7 | return "Hello, " + name 8 | } 9 | 10 | -------------------------------------------------------------------------------- /compliance/tests/package_import_bytes/expected.log: -------------------------------------------------------------------------------- 1 | Equal works correctly 2 | Compare works: hello < world 3 | Contains works correctly 4 | Index works correctly, found at position: 2 5 | Joined: hello world 6 | Split result length: 2 7 | Split works correctly 8 | HasPrefix works correctly 9 | HasSuffix works correctly 10 | Trimmed: hello 11 | Upper: HELLO 12 | Lower: hello 13 | Repeated: xxx 14 | Count of 'a' in 'banana': 3 15 | Replace result: hi hello 16 | ReplaceAll result: hi hi 17 | Buffer content: Hello World 18 | Buffer length: 11 19 | Read 5 bytes: Hello 20 | Buffer after reset, length: 0 21 | test finished 22 | -------------------------------------------------------------------------------- /compliance/tests/package_import_bytes/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_bytes/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_context/expected.log: -------------------------------------------------------------------------------- 1 | myCh is not be readable yet 2 | read successfully 3 | test finished 4 | -------------------------------------------------------------------------------- /compliance/tests/package_import_context/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_context/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_context/packages: -------------------------------------------------------------------------------- 1 | # compile this test case 2 | . 3 | -------------------------------------------------------------------------------- /compliance/tests/package_import_csync/expect-typecheck-fail: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_csync/expect-typecheck-fail -------------------------------------------------------------------------------- /compliance/tests/package_import_csync/expected.log: -------------------------------------------------------------------------------- 1 | All workers completed successfully 2 | Final counter value: 5 3 | success: csync.Mutex test completed 4 | -------------------------------------------------------------------------------- /compliance/tests/package_import_csync/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_csync/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_errors/expected.log: -------------------------------------------------------------------------------- 1 | err1: first error 2 | err2: second error 3 | err1 == err2: false 4 | err1 == nil: false 5 | nilErr == nil: true 6 | test finished 7 | -------------------------------------------------------------------------------- /compliance/tests/package_import_errors/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_errors/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_errors/package_import_errors.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "errors" 4 | 5 | func main() { 6 | // Test basic error creation 7 | err1 := errors.New("first error") 8 | err2 := errors.New("second error") 9 | 10 | println("err1:", err1.Error()) 11 | println("err2:", err2.Error()) 12 | 13 | // Test error comparison 14 | println("err1 == err2:", err1 == err2) 15 | println("err1 == nil:", err1 == nil) 16 | 17 | // Test nil error 18 | var nilErr error 19 | println("nilErr == nil:", nilErr == nil) 20 | 21 | println("test finished") 22 | } 23 | -------------------------------------------------------------------------------- /compliance/tests/package_import_fmt/actual.log: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /compliance/tests/package_import_fmt/expected.log: -------------------------------------------------------------------------------- 1 | Hello World 2 | This is a line 3 | String: test 4 | Integer: 42 5 | Float: 3.14 6 | Boolean: true 7 | Character: A 8 | Sprintf result: Formatted string: value 123 9 | Multiple: text 100 2.500000 false 10 | Width: ' hi' 11 | Precision: '1.235' 12 | Both: ' 123.46' 13 | Left aligned: 'left ' 14 | Zero padded: '00000042' 15 | Hex: ff 16 | Hex upper: FF 17 | Octal: 100 18 | Address-like: 0x1400000e120 19 | Quoted: "hello\nworld" 20 | Type: int 21 | Type: string 22 | Default: 42 23 | Default: string 24 | Default: true 25 | Struct: {Name:Alice Age:30} 26 | Go syntax: main.Person{Name:"Alice", Age:30}test finished 27 | -------------------------------------------------------------------------------- /compliance/tests/package_import_fmt/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_fmt/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_fmt/skip-test: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_fmt/skip-test -------------------------------------------------------------------------------- /compliance/tests/package_import_io/expected.log: -------------------------------------------------------------------------------- 1 | EOF: EOF 2 | ErrClosedPipe: io: read/write on closed pipe 3 | ErrShortWrite: short write 4 | ErrUnexpectedEOF: unexpected EOF 5 | SeekStart: 0 6 | SeekCurrent: 1 7 | SeekEnd: 2 8 | WriteString to Discard - bytes: 11 err: true 9 | test finished 10 | -------------------------------------------------------------------------------- /compliance/tests/package_import_io/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_io/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_io_fs/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_io_fs/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_maps/expected.log: -------------------------------------------------------------------------------- 1 | Result: atest+ 2 | Result: atest+_local 3 | Result: btest, 4 | Result: btest,_local 5 | Result: ctest- 6 | Result: ctest-_local 7 | test finished 8 | -------------------------------------------------------------------------------- /compliance/tests/package_import_maps/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_maps/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_os/expected.log: -------------------------------------------------------------------------------- 1 | Current working directory: / 2 | Set environment variable TEST_VAR 3 | Got environment variable TEST_VAR: test_value 4 | Environment variable TEST_VAR unset successfully 5 | Hostname: goscript 6 | -------------------------------------------------------------------------------- /compliance/tests/package_import_os/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_os/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_path/expected.log: -------------------------------------------------------------------------------- 1 | Clean result: /a/c/d 2 | Join result: a/b/c 3 | Base result: c.txt 4 | Dir result: /a/b 5 | Ext result: .txt 6 | IsAbs result: true 7 | Split dir: /a/b/ 8 | Split file: c.txt 9 | Match result: true 10 | test finished 11 | -------------------------------------------------------------------------------- /compliance/tests/package_import_path/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_path/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_path_filepath/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_path_filepath/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_pkg_errors/expected.log: -------------------------------------------------------------------------------- 1 | New error: basic error 2 | Errorf error: formatted error: 42 3 | WithStack error: base error 4 | Wrap error: wrapped message: base error 5 | Wrapf error: wrapped with format: test: base error 6 | WithMessage error: additional message: base error 7 | WithMessagef error: additional formatted message: 123: base error 8 | Cause error: base error 9 | WithStack with nil returns nil 10 | Wrap with nil returns nil 11 | Unwrap error: wrapped message: base error 12 | Is check passed 13 | test finished 14 | -------------------------------------------------------------------------------- /compliance/tests/package_import_pkg_errors/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_pkg_errors/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_reflect/index.ts: -------------------------------------------------------------------------------- 1 | export { Person } from "./package_import_reflect.gs.js" 2 | export type { Stringer } from "./package_import_reflect.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/package_import_runtime/expected.log: -------------------------------------------------------------------------------- 1 | GOOS: js 2 | GOARCH: wasm 3 | GOMAXPROCS(-1): 1 4 | GOMAXPROCS(0): 1 5 | NumGoroutine: 1 6 | GC called successfully 7 | -------------------------------------------------------------------------------- /compliance/tests/package_import_runtime/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_runtime/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_runtime/packages: -------------------------------------------------------------------------------- 1 | # compile this test case 2 | . -------------------------------------------------------------------------------- /compliance/tests/package_import_slices/expected.log: -------------------------------------------------------------------------------- 1 | index: 0 value: 1 2 | index: 1 value: 2 3 | index: 2 value: 3 4 | index: 3 value: 4 5 | index: 4 value: 5 6 | test finished 7 | -------------------------------------------------------------------------------- /compliance/tests/package_import_slices/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_slices/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_slices/package_import_slices.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "slices" 4 | 5 | func main() { 6 | s := []int{1, 2, 3, 4, 5} 7 | 8 | // This should trigger the interface range issue 9 | // slices.All returns an iterator interface that can be ranged over 10 | for i, v := range slices.All(s) { 11 | println("index:", i, "value:", v) 12 | } 13 | 14 | println("test finished") 15 | } 16 | -------------------------------------------------------------------------------- /compliance/tests/package_import_sort/expected.log: -------------------------------------------------------------------------------- 1 | Original ints: 3 1 4 1 5 9 2 | Sorted ints: 1 1 3 4 5 9 3 | Ints are sorted: true 4 | Original strings: banana apple cherry 5 | Sorted strings: apple banana cherry 6 | Strings are sorted: true 7 | Original floats: 3.14 2.71 1.41 8 | Sorted floats: 1.41 2.71 3.14 9 | Floats are sorted: true 10 | Index of 4 in sorted ints: 3 11 | Index of 'banana' in sorted strings: 1 12 | Index of 2.71 in sorted floats: 1 13 | First index where value >= 5: 4 14 | Custom sorted slice: 1 2 5 8 9 15 | Custom slice is sorted: true 16 | test finished 17 | -------------------------------------------------------------------------------- /compliance/tests/package_import_sort/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_sort/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_strconv/expected.log: -------------------------------------------------------------------------------- 1 | Itoa result: 123 2 | FormatInt result: 789 3 | ParseFloat result: 3.14 4 | FormatFloat result: 2.718 5 | ParseBool result: true 6 | FormatBool result: false 7 | Quote result: "hello world" 8 | Unquote result: hello world 9 | Atoi error handled 10 | ParseFloat error handled 11 | test finished 12 | -------------------------------------------------------------------------------- /compliance/tests/package_import_strconv/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_strconv/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_strings/expected.log: -------------------------------------------------------------------------------- 1 | Result: Hello World 2 | Direct: Direct make test 3 | -------------------------------------------------------------------------------- /compliance/tests/package_import_strings/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_strings/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_strings/package_import_strings.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "strings" 4 | 5 | func main() { 6 | // This should trigger the unhandled make call error 7 | // strings.Builder uses make internally for its buffer 8 | var builder strings.Builder 9 | builder.WriteString("Hello") 10 | builder.WriteString(" ") 11 | builder.WriteString("World") 12 | 13 | result := builder.String() 14 | println("Result:", result) 15 | 16 | // Also test direct make with strings.Builder 17 | builderPtr := &strings.Builder{} 18 | builderPtr.WriteString("Direct make test") 19 | println("Direct:", builderPtr.String()) 20 | } 21 | -------------------------------------------------------------------------------- /compliance/tests/package_import_sync/expected.log: -------------------------------------------------------------------------------- 1 | Mutex locked 2 | Mutex unlocked 3 | TryLock succeeded 4 | WaitGroup counter set to 1 5 | WaitGroup counter decremented 6 | WaitGroup wait completed 7 | Once function executed, counter: 1 8 | Final counter: 1 9 | OnceFunc executed 10 | OnceValue function executed 11 | OnceValue results: 42 42 12 | Stored key1 13 | Loaded key1: value1 14 | Stored key2: value2 15 | Range: key1 -> value1 16 | Range: key2 -> value2 17 | key1 deleted successfully 18 | Pool creating new object 19 | Got from pool: new object 20 | Got from pool: reused object 21 | test finished 22 | -------------------------------------------------------------------------------- /compliance/tests/package_import_sync/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_sync/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_sync_atomic/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_sync_atomic/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_testing_fstest/actual.log: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /compliance/tests/package_import_testing_fstest/expected.log: -------------------------------------------------------------------------------- 1 | Read from hello.txt: Hello, World! 2 | ReadFile dir/subfile.txt: This is a subfile 3 | hello.txt size: 13 4 | hello.txt name: hello.txt 5 | Directory entries: 6 | Entry: binary.bin IsDir: false 7 | Entry: dir IsDir: false 8 | Entry: hello.txt IsDir: false 9 | Error reading dir: readdir dir: not implemented 10 | -------------------------------------------------------------------------------- /compliance/tests/package_import_testing_fstest/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_testing_fstest/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_testing_fstest/skip-test: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_testing_fstest/skip-test -------------------------------------------------------------------------------- /compliance/tests/package_import_time/expected.log: -------------------------------------------------------------------------------- 1 | preset time 2025-05-15 01:10:42 +0000 UTC 2 | unix 1747271442 3 | unix micro 1747271442000000 4 | unix nano 1747271442000000000 5 | unix milli 1747271442000 6 | day 15 7 | month 5 8 | year 2025 9 | hour 1 10 | minute 10 11 | second 42 12 | nanosecond 0 13 | weekday Thursday 14 | location UTC 15 | -------------------------------------------------------------------------------- /compliance/tests/package_import_time/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_time/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_unicode/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_unicode/index.ts -------------------------------------------------------------------------------- /compliance/tests/package_import_unicode_utf8/expected.log: -------------------------------------------------------------------------------- 1 | Rune count: 9 2 | First rune: 72 size: 1 3 | Valid UTF-8: true 4 | Byte rune count: 9 5 | First rune from bytes: 72 size: 1 6 | Valid UTF-8 bytes: true 7 | Encoded rune size: 3 8 | Rune length: 3 9 | Valid rune: true 10 | RuneSelf: 128 11 | MaxRune: 1114111 12 | UTFMax: 4 13 | -------------------------------------------------------------------------------- /compliance/tests/package_import_unicode_utf8/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/package_import_unicode_utf8/index.ts -------------------------------------------------------------------------------- /compliance/tests/path_error_constructor/expected.log: -------------------------------------------------------------------------------- 1 | readlink 2 | /some/path 3 | not a symlink 4 | -------------------------------------------------------------------------------- /compliance/tests/path_error_constructor/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/path_error_constructor/index.ts -------------------------------------------------------------------------------- /compliance/tests/path_error_constructor/path_error_constructor.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | ) 7 | 8 | func main() { 9 | // Test creating a PathError using composite literal syntax 10 | err := &os.PathError{ 11 | Op: "readlink", 12 | Path: "/some/path", 13 | Err: fmt.Errorf("not a symlink"), 14 | } 15 | 16 | println(err.Op) 17 | println(err.Path) 18 | println(err.Err.Error()) 19 | } 20 | -------------------------------------------------------------------------------- /compliance/tests/pointer_assignment_no_copy/expected.log: -------------------------------------------------------------------------------- 1 | Pointer copy value: Expected: modified original, Actual: modified original 2 | Original value after pointer copy modification: Expected: 20, Actual: 20 -------------------------------------------------------------------------------- /compliance/tests/pointer_assignment_no_copy/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./pointer_assignment_no_copy.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/pointer_composite_literal_assignment/expected.log: -------------------------------------------------------------------------------- 1 | MyInt via pointer: Expected: 42, Actual: 42 2 | MyString via pointer: Expected: composite literal pointer, Actual: composite literal pointer 3 | MyInt after modification: Expected: 99, Actual: 99 -------------------------------------------------------------------------------- /compliance/tests/pointer_composite_literal_assignment/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./pointer_composite_literal_assignment.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/pointer_composite_literal_untyped/expected.log: -------------------------------------------------------------------------------- 1 | Pointer value x: 42 2 | First element x: 42 3 | Second element x: 43 4 | -------------------------------------------------------------------------------- /compliance/tests/pointer_composite_literal_untyped/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/pointer_composite_literal_untyped/index.ts -------------------------------------------------------------------------------- /compliance/tests/pointer_deref_multiassign/expected.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/pointer_deref_multiassign/expected.log -------------------------------------------------------------------------------- /compliance/tests/pointer_deref_multiassign/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./pointer_deref_multiassign.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/pointer_initialization/expected.log: -------------------------------------------------------------------------------- 1 | Initial MyString (via pointer): Expected: hello world, Actual: hello world -------------------------------------------------------------------------------- /compliance/tests/pointer_initialization/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./pointer_initialization.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/pointer_initialization/pointer_initialization.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // MyStruct demonstrates a simple struct with public and private fields. 4 | type MyStruct struct { 5 | MyInt int 6 | MyString string 7 | } 8 | 9 | func main() { 10 | // === Pointer Initialization === 11 | // Create a pointer to a MyStruct instance using a composite literal. 12 | structPointer := &MyStruct{MyInt: 4, MyString: "hello world"} 13 | // Expected: "hello world" 14 | println("Initial MyString (via pointer): Expected: hello world, Actual: " + structPointer.MyString) 15 | } 16 | -------------------------------------------------------------------------------- /compliance/tests/pointer_range_loop/expected.log: -------------------------------------------------------------------------------- 1 | index: 0 value: 1 2 | index: 1 value: 2 3 | index: 2 value: 3 4 | -------------------------------------------------------------------------------- /compliance/tests/pointer_range_loop/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/pointer_range_loop/index.ts -------------------------------------------------------------------------------- /compliance/tests/pointer_range_loop/pointer_range_loop.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | arr := [3]int{1, 2, 3} 5 | arrPtr := &arr 6 | 7 | for i, v := range arrPtr { 8 | println("index:", i, "value:", v) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /compliance/tests/pointer_range_loop/pointer_range_loop.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on pointer_range_loop.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export async function main(): Promise { 7 | let arr = $.varRef($.arrayToSlice([1, 2, 3])) 8 | let arrPtr = arr 9 | 10 | for (let i = 0; i < $.len(arrPtr!.value); i++) { 11 | const v = arrPtr!.value![i] 12 | { 13 | console.log("index:", i, "value:", v) 14 | } 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /compliance/tests/pointer_struct_assign_clone/actual.log: -------------------------------------------------------------------------------- 1 | 20 2 | 20 3 | 50 4 | 50 5 | 80 6 | 70 7 | 90 -------------------------------------------------------------------------------- /compliance/tests/pointer_struct_assign_clone/expect-fail: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/pointer_struct_assign_clone/expect-fail -------------------------------------------------------------------------------- /compliance/tests/pointer_struct_assign_clone/expected.log: -------------------------------------------------------------------------------- 1 | 10 2 | 10 3 | 40 4 | 40 5 | 100 6 | 70 7 | 110 -------------------------------------------------------------------------------- /compliance/tests/pointer_struct_assign_clone/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./pointer_struct_assign_clone.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/pointers/expect-typecheck-fail: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/pointers/expect-typecheck-fail -------------------------------------------------------------------------------- /compliance/tests/pointers/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./pointers.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/private_field_access/expected.log: -------------------------------------------------------------------------------- 1 | Accessing privateField: 123 -------------------------------------------------------------------------------- /compliance/tests/private_field_access/index.ts: -------------------------------------------------------------------------------- 1 | export { NewMyStruct } from "./private_field_access.gs.js" 2 | export { MyStruct } from "./private_field_access.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/private_field_access/private_field_access.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type MyStruct struct { 4 | publicField string 5 | privateField int 6 | } 7 | 8 | func NewMyStruct(pub string, priv int) MyStruct { 9 | return MyStruct{ 10 | publicField: pub, 11 | privateField: priv, 12 | } 13 | } 14 | 15 | func accessPrivateField(s MyStruct) { 16 | // Accessing privateField directly from a function in the same package 17 | // This should trigger the generation of the _private field 18 | println("Accessing privateField:", s.privateField) 19 | } 20 | 21 | func main() { 22 | s := NewMyStruct("hello", 123) 23 | accessPrivateField(s) 24 | } 25 | -------------------------------------------------------------------------------- /compliance/tests/protobuf_lite_ts/expected.log: -------------------------------------------------------------------------------- 1 | data: Uint8Array(14) [ 2 | 10, 5, 104, 101, 108, 3 | 108, 111, 18, 5, 119, 4 | 111, 114, 108, 100 5 | ] 6 | out: { 7 | exampleField: Uint8Array(5) [ 104, 101, 108, 108, 111 ], 8 | exampleText: 'world' 9 | } 10 | json marshaled: {"exampleField":"aGVsbG8=","exampleText":"world"} 11 | json unmarshaled: { 12 | exampleField: Uint8Array(5) [ 104, 101, 108, 108, 111 ], 13 | exampleText: 'world' 14 | } 15 | -------------------------------------------------------------------------------- /compliance/tests/protobuf_lite_ts/index.ts: -------------------------------------------------------------------------------- 1 | export { ExampleMsg, protobufPackage } from "./protobuf_lite_ts.pb.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/protobuf_lite_ts/protobuf_lite_ts.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package main; 3 | 4 | message ExampleMsg { 5 | bytes example_field = 1; 6 | string example_text = 2; 7 | } -------------------------------------------------------------------------------- /compliance/tests/receiver_binding/expected.log: -------------------------------------------------------------------------------- 1 | Name: test 2 | Length: 5 3 | Empty: false 4 | Length after truncate: 0 5 | New name: new_name 6 | -------------------------------------------------------------------------------- /compliance/tests/receiver_binding/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/receiver_binding/index.ts -------------------------------------------------------------------------------- /compliance/tests/receiver_binding/methods.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on methods.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | import { storage } from "./storage.gs.js"; 6 | 7 | -------------------------------------------------------------------------------- /compliance/tests/receiver_binding/storage.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type storage struct { 4 | bytes []byte 5 | name string 6 | } 7 | 8 | func main() { 9 | s := &storage{ 10 | bytes: make([]byte, 5), 11 | name: "test", 12 | } 13 | 14 | println("Name:", s.Name()) 15 | println("Length:", s.Len()) 16 | println("Empty:", s.IsEmpty()) 17 | 18 | s.Truncate() 19 | println("Length after truncate:", s.Len()) 20 | 21 | s.SetName("new_name") 22 | println("New name:", s.Name()) 23 | } 24 | -------------------------------------------------------------------------------- /compliance/tests/receiver_method/expected.log: -------------------------------------------------------------------------------- 1 | 10 2 | 42 3 | -------------------------------------------------------------------------------- /compliance/tests/receiver_method/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./main.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/receiver_method/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type MyStruct struct { 4 | Value int 5 | } 6 | 7 | // Method that uses the receiver 8 | func (m *MyStruct) UsesReceiver() int { 9 | return m.Value 10 | } 11 | 12 | // Method that doesn't use the receiver 13 | func (m *MyStruct) DoesNotUseReceiver() int { 14 | return 42 15 | } 16 | 17 | func main() { 18 | s := &MyStruct{Value: 10} 19 | println(s.UsesReceiver()) 20 | println(s.DoesNotUseReceiver()) 21 | } 22 | -------------------------------------------------------------------------------- /compliance/tests/receiver_variable/expected.log: -------------------------------------------------------------------------------- 1 | Complex method completed, size: 16 2 | -------------------------------------------------------------------------------- /compliance/tests/receiver_variable/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/receiver_variable/index.ts -------------------------------------------------------------------------------- /compliance/tests/recursive_type_definition/expected.log: -------------------------------------------------------------------------------- 1 | recursive type definition test 2 | -------------------------------------------------------------------------------- /compliance/tests/recursive_type_definition/index.ts: -------------------------------------------------------------------------------- 1 | export { B } from "./recursive_type_definition.gs.js" 2 | export type { A, C, D } from "./recursive_type_definition.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/recursive_type_definition/recursive_type_definition.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type A interface { 4 | MethodA(a A) 5 | } 6 | 7 | type B struct{} 8 | 9 | func (b *B) MethodB(valB *B) {} 10 | 11 | // It's also possible with mutually recursive types 12 | type C interface { 13 | MethodC(d D) 14 | } 15 | 16 | type D interface { 17 | MethodD(c C) 18 | } 19 | 20 | func main() { 21 | println("recursive type definition test") 22 | } 23 | -------------------------------------------------------------------------------- /compliance/tests/redeclaration_assign/expected.log: -------------------------------------------------------------------------------- 1 | initial i: 0 2 | after assign i: 7 3 | err is true -------------------------------------------------------------------------------- /compliance/tests/redeclaration_assign/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/redeclaration_assign/index.ts -------------------------------------------------------------------------------- /compliance/tests/redeclaration_assign/redeclaration_assign.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func returnsOneIntOneBool() (int, bool) { 4 | return 7, true 5 | } 6 | 7 | func main() { 8 | var i int 9 | println("initial i:", i) /* Use i to avoid unused error before := */ 10 | 11 | // i already exists from the var declaration above. 12 | // err is a new variable being declared. 13 | i, err := returnsOneIntOneBool() 14 | 15 | println("after assign i:", i) // Use i 16 | if err { // Use err 17 | println("err is true") 18 | } else { 19 | println("err is false") 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /compliance/tests/reserved_words/expected.log: -------------------------------------------------------------------------------- 1 | new: 42 2 | class: test 3 | typeof: true 4 | named return result: 100 5 | test finished 6 | -------------------------------------------------------------------------------- /compliance/tests/reserved_words/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/reserved_words/index.ts -------------------------------------------------------------------------------- /compliance/tests/rune_const_import/expected.log: -------------------------------------------------------------------------------- 1 | separator: 47 2 | newline: 10 3 | space: 32 4 | separator matches '/' 5 | newline matches '\n' 6 | space matches ' ' 7 | separator + 1: 48 8 | space - 1: 31 9 | -------------------------------------------------------------------------------- /compliance/tests/rune_const_import/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/rune_const_import/index.ts -------------------------------------------------------------------------------- /compliance/tests/rune_const_import/subpkg/index.ts: -------------------------------------------------------------------------------- 1 | export { Newline, Separator, Space } from "./subpkg.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/rune_const_import/subpkg/subpkg.go: -------------------------------------------------------------------------------- 1 | package subpkg 2 | 3 | // Rune constants that should be compiled as numbers, not strings 4 | const ( 5 | Separator = '/' 6 | Newline = '\n' 7 | Space = ' ' 8 | ) 9 | -------------------------------------------------------------------------------- /compliance/tests/rune_const_import/subpkg/subpkg.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on subpkg/subpkg.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export let Separator: number = 47 7 | 8 | export let Newline: number = 10 9 | 10 | export let Space: number = 32 11 | 12 | -------------------------------------------------------------------------------- /compliance/tests/rune_const_reference/expected.log: -------------------------------------------------------------------------------- 1 | separator used in function: 48 2 | newline used in function: 11 3 | -------------------------------------------------------------------------------- /compliance/tests/rune_const_reference/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/rune_const_reference/index.ts -------------------------------------------------------------------------------- /compliance/tests/rune_const_reference/rune_const_reference.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/aperturerobotics/goscript/compliance/tests/rune_const_reference/subpkg" 4 | 5 | func main() { 6 | // Test importing rune constants from another package 7 | const separator = subpkg.Separator 8 | const newline = subpkg.Newline 9 | 10 | // This should use the variable name instead of evaluating to numeric literal 11 | println("separator used in function:", useInFunction(separator)) 12 | println("newline used in function:", useInFunction(newline)) 13 | } 14 | 15 | func useInFunction(r rune) rune { 16 | return r + 1 17 | } 18 | -------------------------------------------------------------------------------- /compliance/tests/rune_const_reference/subpkg/index.ts: -------------------------------------------------------------------------------- 1 | export { Newline, Separator } from "./subpkg.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/rune_const_reference/subpkg/subpkg.go: -------------------------------------------------------------------------------- 1 | package subpkg 2 | 3 | // Rune constants that should be compiled as numbers, not strings 4 | const ( 5 | Separator = '/' 6 | Newline = '\n' 7 | ) 8 | -------------------------------------------------------------------------------- /compliance/tests/rune_const_reference/subpkg/subpkg.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on subpkg/subpkg.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export let Separator: number = 47 7 | 8 | export let Newline: number = 10 9 | 10 | -------------------------------------------------------------------------------- /compliance/tests/select_receive_on_closed_channel_no_default/expected.log: -------------------------------------------------------------------------------- 1 | Received zero value with ok==false: 0 -------------------------------------------------------------------------------- /compliance/tests/select_receive_on_closed_channel_no_default/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/select_receive_on_closed_channel_no_default/index.ts -------------------------------------------------------------------------------- /compliance/tests/select_receive_on_closed_channel_no_default/select_receive_on_closed_channel_no_default.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | ch := make(chan int) // Unbuffered 5 | close(ch) 6 | 7 | select { //nolint:staticcheck 8 | case val, ok := <-ch: 9 | if ok { 10 | println("Received value with ok==true:", val) // Should not be reached 11 | } else { 12 | println("Received zero value with ok==false:", val) // Should be reached 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /compliance/tests/select_send_on_full_buffered_channel_with_default/expected.log: -------------------------------------------------------------------------------- 1 | Default case hit -------------------------------------------------------------------------------- /compliance/tests/select_send_on_full_buffered_channel_with_default/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/select_send_on_full_buffered_channel_with_default/index.ts -------------------------------------------------------------------------------- /compliance/tests/select_send_on_full_buffered_channel_with_default/select_send_on_full_buffered_channel_with_default.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | ch := make(chan int, 1) 5 | ch <- 1 // Fill the buffer 6 | 7 | // TODO: The comments on the following cases are written twice in the output. 8 | select { 9 | case ch <- 2: 10 | println("Sent value") // Should not be reached 11 | default: 12 | println("Default case hit") // Should be reached 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /compliance/tests/select_statement/expected.log: -------------------------------------------------------------------------------- 1 | TEST1: Default case hit correctly 2 | TEST2: Received expected value: hello 3 | TEST3: Received buffered value with ok==true: 42 4 | TEST4: Received zero value with ok==false: 0 5 | TEST5: Sent value successfully 6 | TEST6: Default hit correctly (channel full) 7 | TEST7: Selected ch4 correctly: from ch4 8 | TEST8: Selected ch5 correctly: from ch5 9 | TEST9: Channel is closed, ok is false, val: false -------------------------------------------------------------------------------- /compliance/tests/select_statement/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/select_statement/index.ts -------------------------------------------------------------------------------- /compliance/tests/selective_exports/expected.log: -------------------------------------------------------------------------------- 1 | === Selective Exports Test === 2 | ExportedFunc called 3 | unexportedFunc called 4 | ExportedFromUtils called 5 | unexportedFromUtils called 6 | === End Selective Exports Test === -------------------------------------------------------------------------------- /compliance/tests/selective_exports/index.ts: -------------------------------------------------------------------------------- 1 | export { ExportedFunc } from "./selective_exports.gs.js" 2 | export { ExportedFromUtils } from "./utils.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/selective_exports/utils.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // ExportedFromUtils is exported (uppercase) - should appear in index.ts 4 | func ExportedFromUtils() { 5 | println("ExportedFromUtils called") 6 | } 7 | 8 | // unexportedFromUtils is not exported (lowercase) - should NOT appear in index.ts 9 | func unexportedFromUtils() { 10 | println("unexportedFromUtils called") 11 | } 12 | -------------------------------------------------------------------------------- /compliance/tests/selective_exports/utils.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on utils.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | // ExportedFromUtils is exported (uppercase) - should appear in index.ts 7 | export function ExportedFromUtils(): void { 8 | console.log("ExportedFromUtils called") 9 | } 10 | 11 | // unexportedFromUtils is not exported (lowercase) - should NOT appear in index.ts 12 | export function unexportedFromUtils(): void { 13 | console.log("unexportedFromUtils called") 14 | } 15 | 16 | -------------------------------------------------------------------------------- /compliance/tests/selector_expr_lhs_multi_assign/expected.log: -------------------------------------------------------------------------------- 1 | 10 20 -------------------------------------------------------------------------------- /compliance/tests/selector_expr_lhs_multi_assign/index.ts: -------------------------------------------------------------------------------- 1 | export { Point } from "./selector_expr_lhs_multi_assign.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/selector_expr_lhs_multi_assign/selector_expr_lhs_multi_assign.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Point struct { 4 | X int 5 | Y int 6 | } 7 | 8 | func getCoords() (int, int) { 9 | return 10, 20 10 | } 11 | 12 | func main() { 13 | var p Point 14 | // p.X and p.Y are *ast.SelectorExpr 15 | // test writeMultiVarAssignFromCall in WriteStmtAssign 16 | p.X, p.Y = getCoords() 17 | println(p.X, p.Y) 18 | } 19 | -------------------------------------------------------------------------------- /compliance/tests/selector_expr_ok_variable/expected.log: -------------------------------------------------------------------------------- 1 | Type assertion successful: true 2 | -------------------------------------------------------------------------------- /compliance/tests/selector_expr_ok_variable/index.ts: -------------------------------------------------------------------------------- 1 | export { Result } from "./selector_expr_ok_variable.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/selector_expr_ok_variable/selector_expr_ok_variable.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Result struct { 4 | ok bool 5 | } 6 | 7 | func main() { 8 | var x interface{} = 42 9 | result := Result{} 10 | 11 | // This should trigger the error: ok expression is not an identifier: *ast.SelectorExpr 12 | // The 'ok' variable is result.ok (a selector expression) instead of a simple identifier 13 | _, result.ok = x.(int) 14 | 15 | println("Type assertion successful:", result.ok) 16 | } 17 | -------------------------------------------------------------------------------- /compliance/tests/simple/expected.log: -------------------------------------------------------------------------------- 1 | Hello world! -------------------------------------------------------------------------------- /compliance/tests/simple/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/simple/index.ts -------------------------------------------------------------------------------- /compliance/tests/simple/simple.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | println("Hello world!") 5 | } 6 | -------------------------------------------------------------------------------- /compliance/tests/simple/simple.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on simple.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export async function main(): Promise { 7 | console.log("Hello world!") 8 | } 9 | 10 | -------------------------------------------------------------------------------- /compliance/tests/simple_deref_assignment/expected.log: -------------------------------------------------------------------------------- 1 | Original structPointer after modifying simpleDereferencedCopy: Expected: hello world, Actual: hello world 2 | Simple Dereferenced Copy: Expected: modified dereferenced copy, Actual: modified dereferenced copy -------------------------------------------------------------------------------- /compliance/tests/simple_deref_assignment/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./simple_deref_assignment.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/slice/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/slice/index.ts -------------------------------------------------------------------------------- /compliance/tests/star_expr_destructuring/expected.log: -------------------------------------------------------------------------------- 1 | a: 42 2 | b: hello 3 | -------------------------------------------------------------------------------- /compliance/tests/star_expr_destructuring/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/star_expr_destructuring/index.ts -------------------------------------------------------------------------------- /compliance/tests/star_expr_destructuring/star_expr_destructuring.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func returnTwoValues() (int, string) { 4 | return 42, "hello" 5 | } 6 | 7 | func main() { 8 | var a int = 0 9 | var b string = "" 10 | 11 | // Create pointers - these will be properly varrefed 12 | var pA *int = &a 13 | var pB *string = &b 14 | 15 | // This should trigger the "unhandled LHS expression in destructuring: *ast.StarExpr" error 16 | *pA, *pB = returnTwoValues() 17 | 18 | println("a:", a) 19 | println("b:", b) 20 | } 21 | -------------------------------------------------------------------------------- /compliance/tests/string_conversion/expected.log: -------------------------------------------------------------------------------- 1 | hello world 2 | A 3 | a 4 | € 5 | GoScript 6 | 7 | 你好世界 8 | 你好世界 9 | true 10 | mutable string -------------------------------------------------------------------------------- /compliance/tests/string_conversion/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/string_conversion/index.ts -------------------------------------------------------------------------------- /compliance/tests/string_index_access/expected.log: -------------------------------------------------------------------------------- 1 | Byte from myStr1[0]: 116 2 | Byte from myStr1[2]: 115 3 | Byte from myStr1[6]: 103 4 | Byte from myStr2[0]: 228 5 | Byte from myStr2[1]: 189 6 | Byte from myStr2[2]: 160 7 | Byte from myStr2[3]: 229 8 | -------------------------------------------------------------------------------- /compliance/tests/string_index_access/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/string_index_access/index.ts -------------------------------------------------------------------------------- /compliance/tests/string_slice/expected.log: -------------------------------------------------------------------------------- 1 | myStr1: testing 2 | len(myStr1): 7 3 | myStr1[0:2]: te 4 | myStr1[2:5]: sti 5 | myStr1[5:7]: ng 6 | myStr1[3:]: ting 7 | myStr1[:4]: test 8 | myStr1[:]: testing 9 | myStr2: 你好世界 10 | len(myStr2): 12 11 | myStr2[0:3]: 你 12 | myStr2[3:6]: 好 13 | myStr2[0:6]: 你好 14 | myStr1[1:1]: 15 | myStr1[0:0]: 16 | myStr1[7:7]: 17 | a b c 18 | -------------------------------------------------------------------------------- /compliance/tests/string_slice/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/string_slice/index.ts -------------------------------------------------------------------------------- /compliance/tests/string_type_assertion/expected.log: -------------------------------------------------------------------------------- 1 | value is test 2 | -------------------------------------------------------------------------------- /compliance/tests/string_type_assertion/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/string_type_assertion/index.ts -------------------------------------------------------------------------------- /compliance/tests/string_type_assertion/string_type_assertion.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var w interface{} = "test" 5 | println("value is", w.(string)) 6 | } 7 | -------------------------------------------------------------------------------- /compliance/tests/string_type_assertion/string_type_assertion.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on string_type_assertion.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js"; 5 | 6 | export async function main(): Promise { 7 | let w: null | any = "test" 8 | console.log("value is", $.mustTypeAssert(w, {kind: $.TypeKind.Basic, name: 'string'})) 9 | } 10 | 11 | -------------------------------------------------------------------------------- /compliance/tests/struct_embedding/index.ts: -------------------------------------------------------------------------------- 1 | export { Address, Contact, Employee, Manager, Person } from "./struct_embedding.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/struct_field_access/expected.log: -------------------------------------------------------------------------------- 1 | MyInt: Expected: 42, Actual: 42 2 | MyString: Expected: foo, Actual: foo -------------------------------------------------------------------------------- /compliance/tests/struct_field_access/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./struct_field_access.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/struct_field_access/struct_field_access.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type MyStruct struct { 4 | MyInt int 5 | MyString string 6 | } 7 | 8 | func main() { 9 | // === Struct Field Access === 10 | ms := MyStruct{MyInt: 42, MyString: "foo"} 11 | println("MyInt: Expected: 42, Actual:", ms.MyInt) 12 | println("MyString: Expected: foo, Actual:", ms.MyString) 13 | } 14 | -------------------------------------------------------------------------------- /compliance/tests/struct_new/expected.log: -------------------------------------------------------------------------------- 1 | ptr.MyInt (default): 0 2 | ptr.MyString (default): 3 | ptr.myBool (default): false 4 | ptr.MyInt (assigned): 42 5 | ptr.MyString (assigned): hello 6 | ptr.myBool (assigned): true 7 | s.MyInt (default): 0 8 | s.MyString (default): 9 | s.myBool (default): false 10 | s.MyInt (assigned): 100 11 | s.MyString (assigned): world 12 | s.myBool (assigned): false 13 | -------------------------------------------------------------------------------- /compliance/tests/struct_new/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./struct_new.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/struct_pointer_interface_fields/expected.log: -------------------------------------------------------------------------------- 1 | true 2 | true 3 | true 4 | 10 5 | 15 6 | true -------------------------------------------------------------------------------- /compliance/tests/struct_pointer_interface_fields/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./struct_pointer_interface_fields.gs.js" 2 | export type { MyInterface } from "./struct_pointer_interface_fields.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/struct_pointer_interface_fields/struct_pointer_interface_fields.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type MyInterface interface { 4 | Method() 5 | } 6 | 7 | type MyStruct struct { 8 | PointerField *int 9 | interfaceField MyInterface 10 | } 11 | 12 | func main() { 13 | s := MyStruct{} 14 | println(s.PointerField == nil) 15 | println(s.interfaceField == nil) 16 | 17 | i := 10 18 | s.PointerField = &i 19 | println(s.PointerField != nil) 20 | println(*s.PointerField) 21 | i = 15 22 | println(*s.PointerField) 23 | 24 | var mi MyInterface 25 | s.interfaceField = mi 26 | println(s.interfaceField == nil) 27 | } 28 | -------------------------------------------------------------------------------- /compliance/tests/struct_private_field/expected.log: -------------------------------------------------------------------------------- 1 | 10 -------------------------------------------------------------------------------- /compliance/tests/struct_private_field/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./struct_private_field.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/struct_private_field/struct_private_field.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type MyStruct struct { 4 | myPrivate int 5 | } 6 | 7 | func main() { 8 | myStruct := &MyStruct{myPrivate: 4} 9 | myStruct.myPrivate = 10 10 | println(myStruct.myPrivate) 11 | } 12 | -------------------------------------------------------------------------------- /compliance/tests/struct_private_field_ptr/expected.log: -------------------------------------------------------------------------------- 1 | 15 -------------------------------------------------------------------------------- /compliance/tests/struct_private_field_ptr/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./struct_private_field_ptr.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/struct_private_field_ptr/struct_private_field_ptr.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type MyStruct struct { 4 | myPrivate *int 5 | } 6 | 7 | func main() { 8 | myStruct := &MyStruct{myPrivate: nil} 9 | var intVar int = 10 10 | myStruct.myPrivate = &intVar 11 | intVar = 15 12 | println(*myStruct.myPrivate) 13 | } 14 | -------------------------------------------------------------------------------- /compliance/tests/struct_type_assertion/expected.log: -------------------------------------------------------------------------------- 1 | Name: Alice Number: 8005553424 2 | Second type assertion failed as expected -------------------------------------------------------------------------------- /compliance/tests/struct_type_assertion/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/struct_type_assertion/index.ts -------------------------------------------------------------------------------- /compliance/tests/struct_type_assertion/struct_type_assertion.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var i any = struct { 5 | Name string 6 | Number int 7 | }{"Alice", 8005553424} 8 | 9 | s, ok := i.(struct { 10 | Name string 11 | Number int 12 | }) 13 | if ok { 14 | println("Name:", s.Name, "Number:", s.Number) 15 | } else { 16 | println("Type assertion failed") 17 | } 18 | 19 | j, ok2 := i.(struct{ Age int }) 20 | if ok2 { 21 | println("Age:", j.Age) 22 | } else { 23 | println("Second type assertion failed as expected") 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /compliance/tests/struct_value_init_clone/expected.log: -------------------------------------------------------------------------------- 1 | p1: 1 2 2 | p1 after p2 mod: 1 2 3 | p2: 10 2 4 | v after p3 mod: 3 4 5 | p3: 3 40 -------------------------------------------------------------------------------- /compliance/tests/struct_value_init_clone/index.ts: -------------------------------------------------------------------------------- 1 | export { Point } from "./struct_value_init_clone.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/switch_multi_case/expected.log: -------------------------------------------------------------------------------- 1 | Month: 12 Value: someValue_processed_flag_true 2 | Month: 1 Value: someValue_processed_flag_true_processed_flag_false 3 | -------------------------------------------------------------------------------- /compliance/tests/switch_multi_case/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/switch_multi_case/index.ts -------------------------------------------------------------------------------- /compliance/tests/switch_statement/expected.log: -------------------------------------------------------------------------------- 1 | Integer switch: 2 | two 3 | 4 | String switch: 5 | hello 6 | 7 | Switch without expression: 8 | negative 9 | 10 | Switch without expression (zero): 11 | zero 12 | 13 | Switch without expression (positive): 14 | positive -------------------------------------------------------------------------------- /compliance/tests/switch_statement/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/switch_statement/index.ts -------------------------------------------------------------------------------- /compliance/tests/time_format_ext/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/time_format_ext/index.ts -------------------------------------------------------------------------------- /compliance/tests/type_assertion_duplicate_vars/expected.log: -------------------------------------------------------------------------------- 1 | hasA: true 2 | hasB: false 3 | -------------------------------------------------------------------------------- /compliance/tests/type_assertion_duplicate_vars/index.ts: -------------------------------------------------------------------------------- 1 | export { ConcreteA, ConcreteB, Container } from "./type_assertion_duplicate_vars.gs.js" 2 | export type { Interface } from "./type_assertion_duplicate_vars.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/type_declaration_receiver/expected.log: -------------------------------------------------------------------------------- 1 | FileMode(0).String(): none 2 | FileMode(0).IsZero(): true 3 | FileMode(5).String(): some 4 | FileMode(5).IsZero(): false 5 | FileMode(3).Add(2): 5 6 | FileMode(3).Add(2).String(): some 7 | CustomString("hello").Length(): 5 8 | CustomString("hello").Upper(): HELLO 9 | CustomString("world").Length(): 5 10 | CustomString("world").Upper(): WORLD 11 | -------------------------------------------------------------------------------- /compliance/tests/type_declaration_receiver/index.ts: -------------------------------------------------------------------------------- 1 | export type { CustomString, FileMode } from "./type_declaration_receiver.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/type_missing_imports/expected.log: -------------------------------------------------------------------------------- 1 | Created storage with file: test.txt 2 | -------------------------------------------------------------------------------- /compliance/tests/type_missing_imports/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/type_missing_imports/index.ts -------------------------------------------------------------------------------- /compliance/tests/type_separate_files/expected.log: -------------------------------------------------------------------------------- 1 | Created storage with file: test.txt 2 | -------------------------------------------------------------------------------- /compliance/tests/type_separate_files/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/type_separate_files/index.ts -------------------------------------------------------------------------------- /compliance/tests/type_separate_files/memory.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type file struct { 4 | name string 5 | data []byte 6 | } 7 | -------------------------------------------------------------------------------- /compliance/tests/type_separate_files/storage.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type storage struct { 4 | files map[string]*file 5 | children map[string]map[string]*file 6 | } 7 | -------------------------------------------------------------------------------- /compliance/tests/type_separate_files/type_separate_files.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | s := storage{ 5 | files: make(map[string]*file), 6 | children: make(map[string]map[string]*file), 7 | } 8 | 9 | f := &file{ 10 | name: "test.txt", 11 | data: []byte("hello world"), 12 | } 13 | 14 | s.files["test"] = f 15 | 16 | println("Created storage with file:", s.files["test"].name) 17 | } 18 | -------------------------------------------------------------------------------- /compliance/tests/type_switch_statement/expected.log: -------------------------------------------------------------------------------- 1 | string hello 2 | int 3 | string or bool true 4 | z is int 42 5 | default only 6 | default only, value is test -------------------------------------------------------------------------------- /compliance/tests/type_switch_statement/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/type_switch_statement/index.ts -------------------------------------------------------------------------------- /compliance/tests/undefined_type_error/expected.log: -------------------------------------------------------------------------------- 1 | Formatter test completed 2 | -------------------------------------------------------------------------------- /compliance/tests/undefined_type_error/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/undefined_type_error/index.ts -------------------------------------------------------------------------------- /compliance/tests/value_type_copy_behavior/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct, NestedStruct } from "./value_type_copy_behavior.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/variable_shadowing_scope/expected.log: -------------------------------------------------------------------------------- 1 | Got value: 42 2 | Completed successfully 3 | -------------------------------------------------------------------------------- /compliance/tests/variable_shadowing_scope/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/variable_shadowing_scope/index.ts -------------------------------------------------------------------------------- /compliance/tests/variable_shadowing_scope/variable_shadowing_scope.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func firstFunc() (string, int) { 4 | return "", 42 5 | } 6 | 7 | func secondFunc(x int) int { 8 | if x != 0 { 9 | println("Got value:", x) 10 | return 0 11 | } 12 | return 99 13 | } 14 | 15 | func main() { 16 | _, x := firstFunc() 17 | // This is the problematic pattern: x is shadowed but also used in the call 18 | if x := secondFunc(x); x != 0 { 19 | println("Function returned value") 20 | return 21 | } 22 | println("Completed successfully") 23 | } 24 | -------------------------------------------------------------------------------- /compliance/tests/variadic_function_call/expected.log: -------------------------------------------------------------------------------- 1 | Expected[0]: file1.txt 2 | Expected[1]: file2.txt 3 | Expected[2]: file3.txt 4 | File system: myfs 5 | Success! -------------------------------------------------------------------------------- /compliance/tests/variadic_function_call/index.ts: -------------------------------------------------------------------------------- 1 | export { TestFS } from "./variadic_function_call.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/variadic_interface_method/expected.log: -------------------------------------------------------------------------------- 1 | Result1: path/to/file 2 | Result2: single 3 | Result3: 4 | Result4: another/path/here 5 | -------------------------------------------------------------------------------- /compliance/tests/variadic_interface_method/index.ts: -------------------------------------------------------------------------------- 1 | export { PathJoiner } from "./variadic_interface_method.gs.js" 2 | export type { Basic } from "./variadic_interface_method.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/variadic_interface_param/expected.log: -------------------------------------------------------------------------------- 1 | Name: test1 2 | Values count: 3 3 | Value 0 is not nil 4 | Value 1 is not nil 5 | Value 2 is not nil 6 | Name: test2 7 | Values count: 2 8 | Value 0 is nil 9 | Value 1 is not nil 10 | Name: test3 11 | Values count: 0 12 | Name: test4 13 | Values count: 3 14 | Value 0 is not nil 15 | Value 1 is not nil 16 | Value 2 is not nil -------------------------------------------------------------------------------- /compliance/tests/variadic_interface_param/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/variadic_interface_param/index.ts -------------------------------------------------------------------------------- /compliance/tests/varref/expected.log: -------------------------------------------------------------------------------- 1 | setting x to 10 2 | ***p3 == 10 3 | 4 | setting ***p3 to 12 5 | ***p3 == 12 6 | 7 | setting y to 15, p1 to &y 8 | ***p3 == 15 -------------------------------------------------------------------------------- /compliance/tests/varref/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/varref/index.ts -------------------------------------------------------------------------------- /compliance/tests/varref_assign/expected.log: -------------------------------------------------------------------------------- 1 | ***p3 == 15 -------------------------------------------------------------------------------- /compliance/tests/varref_assign/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/varref_assign/index.ts -------------------------------------------------------------------------------- /compliance/tests/varref_assign/varref_assign.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var x int = 10 // x is varrefed as p1 takes the address 5 | 6 | var p1 *int = &x // p1 is varrefed as p2 takes the address 7 | var p2 **int = &p1 // p2 is varrefed as p3 takes the address 8 | var p3 ***int = &p2 // p3 is not varrefed as nothing takes its address 9 | _ = p3 10 | 11 | // should be: let y: $.VarRef = $.varRef(15) 12 | var y int = 15 // y is varrefed as p1 takes the address 13 | // should be: p1.value = y 14 | p1 = &y 15 | 16 | println("***p3 ==", ***p3) 17 | } 18 | -------------------------------------------------------------------------------- /compliance/tests/varref_composite_lit/expected.log: -------------------------------------------------------------------------------- 1 | childInode.Value: 42 2 | childInode.getValue(): 42 -------------------------------------------------------------------------------- /compliance/tests/varref_composite_lit/index.ts: -------------------------------------------------------------------------------- 1 | export { MockInode } from "./varref_composite_lit.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/varref_deref_set/expected.log: -------------------------------------------------------------------------------- 1 | 15 -------------------------------------------------------------------------------- /compliance/tests/varref_deref_set/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/varref_deref_set/index.ts -------------------------------------------------------------------------------- /compliance/tests/varref_deref_struct/expected.log: -------------------------------------------------------------------------------- 1 | 5 2 | expected not equal -------------------------------------------------------------------------------- /compliance/tests/varref_deref_struct/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./varref_deref_struct.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/varref_deref_struct/varref_deref_struct.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type MyStruct struct { 4 | MyInt int 5 | } 6 | 7 | func main() { 8 | // We need to make sure we don't add .value for this 9 | myStruct := &MyStruct{} 10 | (*myStruct).MyInt = 5 11 | println((*myStruct).MyInt) 12 | 13 | myOtherStruct := &MyStruct{MyInt: 1} 14 | if myOtherStruct != myStruct { 15 | println("expected not equal") 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /compliance/tests/varref_pointers/expected.log: -------------------------------------------------------------------------------- 1 | ***p3 before == 10 2 | ***p3 after == 12 -------------------------------------------------------------------------------- /compliance/tests/varref_pointers/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/varref_pointers/index.ts -------------------------------------------------------------------------------- /compliance/tests/varref_pointers_deref/expected.log: -------------------------------------------------------------------------------- 1 | p1==p2: true 2 | *p1==*p2: true 3 | p1==p3: true 4 | Value through ppp1: 10 5 | pp1==savedPP1: true 6 | **pp1: 10 7 | **savedPP1: 10 8 | -------------------------------------------------------------------------------- /compliance/tests/varref_pointers_deref/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/varref_pointers_deref/index.ts -------------------------------------------------------------------------------- /compliance/tests/varref_pointers_number/expect-fail: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/varref_pointers_number/expect-fail -------------------------------------------------------------------------------- /compliance/tests/varref_pointers_number/expected.log: -------------------------------------------------------------------------------- 1 | p1==p2: true 2 | *p1==*p2: true 3 | pp1 deref: 10 4 | -------------------------------------------------------------------------------- /compliance/tests/varref_pointers_number/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aperturerobotics/goscript/4ab69357cba73ae48dfb00728a4b448965cba28a/compliance/tests/varref_pointers_number/index.ts -------------------------------------------------------------------------------- /compliance/tests/varref_pointers_number/varref_pointers_number.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | // Create a simple integer 5 | x := 10 6 | 7 | // p1 will be varrefed because its address is taken later 8 | p1 := &x 9 | 10 | // p2 is not varrefed as nothing takes its address 11 | p2 := &x 12 | 13 | // Take the address of p1 to make it varrefed 14 | pp1 := &p1 15 | 16 | // Compare the pointers - they should be different pointers 17 | // but point to the same value 18 | println("p1==p2:", p1 == p2) 19 | println("*p1==*p2:", *p1 == *p2) 20 | println("pp1 deref:", **pp1) 21 | } 22 | -------------------------------------------------------------------------------- /compliance/tests/varref_struct/expected.log: -------------------------------------------------------------------------------- 1 | ptrToVal.MyInt: 10 2 | myIntVal: 10 -------------------------------------------------------------------------------- /compliance/tests/varref_struct/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./varref_struct.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/varref_struct/varref_struct.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type MyStruct struct { 4 | MyInt int 5 | } 6 | 7 | func main() { 8 | // 'val' is a value type, but its address is taken, so it should be varrefed in TS. 9 | val := MyStruct{MyInt: 10} 10 | ptrToVal := &val 11 | 12 | // Accessing pointer value, should use .value 13 | println("ptrToVal.MyInt:", ptrToVal.MyInt) 14 | 15 | // Accessing pointer value, should use .value 16 | myIntVal := ptrToVal.MyInt 17 | println("myIntVal:", myIntVal) 18 | } 19 | -------------------------------------------------------------------------------- /compliance/tests/varref_struct_init/expected.log: -------------------------------------------------------------------------------- 1 | ptr.MyInt: 40 2 | ptrToVal.MyInt: 20 3 | myIntVal: 20 -------------------------------------------------------------------------------- /compliance/tests/varref_struct_init/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./varref_struct_init.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/wrapper_type_args/expected.log: -------------------------------------------------------------------------------- 1 | TestFileMode called with mode=-rw-r--r-- 2 | TestFileMode called with mode=-rwxr-xr-x 3 | TestMyMode called with mode=755, executable=true 4 | TestMyMode called with mode=600, executable=false 5 | MkdirAll called with path=/tmp/test, perm=-rwx------ 6 | TestFileMode called with mode=-rw-r--r-- 7 | TestFileMode called with mode=-rwxrwxrwx 8 | Test completed 9 | -------------------------------------------------------------------------------- /compliance/tests/wrapper_type_args/index.ts: -------------------------------------------------------------------------------- 1 | export { TestFileMode, TestMyMode } from "./wrapper_type_args.gs.js" 2 | export { MyDir } from "./wrapper_type_args.gs.js" 3 | export type { DirInterface, MyMode } from "./wrapper_type_args.gs.js" 4 | -------------------------------------------------------------------------------- /example/simple/.gitignore: -------------------------------------------------------------------------------- 1 | output/ 2 | node_modules/ 3 | example 4 | -------------------------------------------------------------------------------- /example/simple/.rooignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | output 3 | go.mod 4 | go.sum 5 | yarn.lock 6 | -------------------------------------------------------------------------------- /example/simple/build.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eo pipefail 3 | set -x 4 | 5 | pkgs=( "." ) 6 | for pkg in ${pkgs[@]}; do 7 | go run -v github.com/aperturerobotics/goscript/cmd/goscript \ 8 | compile \ 9 | --package $pkg 10 | done 11 | 12 | # Copy for reference 13 | cp ./output/@goscript/example/main.gs.ts ./main.gs.ts -------------------------------------------------------------------------------- /example/simple/main.ts: -------------------------------------------------------------------------------- 1 | import { main } from '@goscript/example/main.gs.js' 2 | 3 | main() 4 | -------------------------------------------------------------------------------- /example/simple/main_tools.go: -------------------------------------------------------------------------------- 1 | //go:build tools 2 | 3 | package main 4 | 5 | import _ "github.com/aperturerobotics/goscript/cmd/goscript" 6 | -------------------------------------------------------------------------------- /example/simple/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@example/simple", 3 | "private": true, 4 | "devDependencies": { 5 | "typescript": "^5.4.2" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /example/simple/run.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eo pipefail 3 | 4 | bash build.bash 5 | 6 | tsx --tsconfig ./tsconfig.json ./main.ts -------------------------------------------------------------------------------- /example/simple/yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | typescript@^5.4.2: 6 | version "5.8.3" 7 | resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.8.3.tgz#92f8a3e5e3cf497356f4178c34cd65a7f5e8440e" 8 | integrity sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ== 9 | -------------------------------------------------------------------------------- /expected.log: -------------------------------------------------------------------------------- 1 | Custom name: custom_name.txt 2 | File name: test.txt 3 | Lock successful 4 | Unlock successful 5 | Wrote bytes: 9 6 | Read bytes: 5 7 | ReadAt bytes: 5 8 | Seek position: 0 9 | Truncate successful 10 | Close successful 11 | Qualified file name: qualified.txt 12 | Qualified close successful 13 | Qualified wrote bytes: 14 -------------------------------------------------------------------------------- /gs.go: -------------------------------------------------------------------------------- 1 | package goscript 2 | 3 | import "embed" 4 | 5 | // GsOverrides gs/ tree contains hand-written TypeScript packages corresponding to Go packages. 6 | // 7 | //go:embed gs 8 | var GsOverrides embed.FS 9 | -------------------------------------------------------------------------------- /gs/README.md: -------------------------------------------------------------------------------- 1 | # Hand-written Go Packages 2 | 3 | This directory contains hand-written .gs.ts files corresponding to select 4 | packages from the standard library. These packages are hard or impossible to 5 | transpile correctly, so we hand-write the TypeScript equivalents here. 6 | 7 | -------------------------------------------------------------------------------- /gs/builtin/index.ts: -------------------------------------------------------------------------------- 1 | export * from './builtin.js' 2 | export * from './slice.js' 3 | export * from './channel.js' 4 | export * from './map.js' 5 | export * from './type.js' 6 | export * from './varRef.js' 7 | export * from './defer.js' 8 | export * from './errors.js' 9 | -------------------------------------------------------------------------------- /gs/bytes/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "errors", 4 | "io", 5 | "iter", 6 | "unicode", 7 | "unicode/utf8", 8 | "unsafe" 9 | ] 10 | } -------------------------------------------------------------------------------- /gs/cmp/godoc.txt: -------------------------------------------------------------------------------- 1 | package cmp // import "cmp" 2 | 3 | Package cmp provides types and functions related to comparing ordered values. 4 | 5 | func Compare[T Ordered](x, y T) int 6 | func Less[T Ordered](x, y T) bool 7 | func Or[T comparable](vals ...T) T 8 | type Ordered interface{ ... } 9 | -------------------------------------------------------------------------------- /gs/context/index.ts: -------------------------------------------------------------------------------- 1 | export * from './context.js' 2 | -------------------------------------------------------------------------------- /gs/errors/index.ts: -------------------------------------------------------------------------------- 1 | export * from './errors.js' 2 | -------------------------------------------------------------------------------- /gs/fmt/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | Errorf, 3 | Print, 4 | Printf, 5 | Println, 6 | Sprint, 7 | Sprintf, 8 | Sprintln, 9 | Fprint, 10 | Fprintf, 11 | Fprintln, 12 | Append, 13 | Appendf, 14 | Appendln, 15 | FormatString, 16 | Scan, 17 | Scanf, 18 | Scanln, 19 | Sscan, 20 | Sscanf, 21 | Sscanln, 22 | Fscan, 23 | Fscanf, 24 | Fscanln, 25 | } from './fmt.js' 26 | 27 | // Re-export types for TypeScript compilation 28 | export type { 29 | Formatter, 30 | GoStringer, 31 | Stringer, 32 | State, 33 | Scanner, 34 | ScanState, 35 | } from './fmt.js' 36 | -------------------------------------------------------------------------------- /gs/fmt/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "errors" 4 | ] 5 | } -------------------------------------------------------------------------------- /gs/github.com/pkg/errors/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | Cause, 3 | Errorf, 4 | New, 5 | WithMessage, 6 | WithMessagef, 7 | WithStack, 8 | Wrap, 9 | Wrapf, 10 | } from './errors.js' 11 | export { As, Is, Unwrap } from './go113.js' 12 | export { Frame, StackTrace } from './stack.js' 13 | -------------------------------------------------------------------------------- /gs/internal/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "errors" 4 | ] 5 | } -------------------------------------------------------------------------------- /gs/internal/oserror/errors.ts: -------------------------------------------------------------------------------- 1 | import * as $ from '@goscript/builtin/index.js' 2 | 3 | import * as errors from '@goscript/errors/index.js' 4 | 5 | export let ErrInvalid: $.GoError = errors.New('invalid argument') 6 | 7 | export let ErrPermission: $.GoError = errors.New('permission denied') 8 | 9 | export let ErrExist: $.GoError = errors.New('file already exists') 10 | 11 | export let ErrNotExist: $.GoError = errors.New('file does not exist') 12 | 13 | export let ErrClosed: $.GoError = errors.New('file already closed') 14 | -------------------------------------------------------------------------------- /gs/internal/oserror/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | ErrClosed, 3 | ErrExist, 4 | ErrInvalid, 5 | ErrNotExist, 6 | ErrPermission, 7 | } from './errors.js' 8 | -------------------------------------------------------------------------------- /gs/io/fs/index.ts: -------------------------------------------------------------------------------- 1 | export * from './format.js' 2 | export * from './fs.js' 3 | export * from './glob.js' 4 | export * from './readdir.js' 5 | export * from './readfile.js' 6 | export * from './stat.js' 7 | export * from './sub.js' 8 | export * from './walk.js' 9 | -------------------------------------------------------------------------------- /gs/io/index.ts: -------------------------------------------------------------------------------- 1 | export * from './io.js' 2 | -------------------------------------------------------------------------------- /gs/io/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "errors", 4 | "internal/oserror", 5 | "path", 6 | "time", 7 | "unicode/utf8" 8 | ] 9 | } -------------------------------------------------------------------------------- /gs/iter/index.ts: -------------------------------------------------------------------------------- 1 | export * from './iter.js' 2 | -------------------------------------------------------------------------------- /gs/maps/index.ts: -------------------------------------------------------------------------------- 1 | export { All, Collect, Insert, Keys, Values } from './iter.js' 2 | export { Clone, Copy, DeleteFunc, Equal, EqualFunc } from './maps.js' 3 | -------------------------------------------------------------------------------- /gs/maps/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "iter", 4 | "unsafe" 5 | ] 6 | } -------------------------------------------------------------------------------- /gs/math/abs.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | import { Float64bits, Float64frombits } from "./unsafe.gs.js"; 3 | 4 | // Abs returns the absolute value of x. 5 | // 6 | // Special cases are: 7 | // 8 | // Abs(±Inf) = +Inf 9 | // Abs(NaN) = NaN 10 | export function Abs(x: number): number { 11 | return Math.abs(x) 12 | } 13 | 14 | -------------------------------------------------------------------------------- /gs/math/acosh.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | import { IsNaN, NaN } from "./bits.gs.js"; 3 | import { Log } from "./log.gs.js"; 4 | import { Log1p } from "./log1p.gs.js"; 5 | import { Sqrt } from "./sqrt.gs.js"; 6 | 7 | // Acosh returns the inverse hyperbolic cosine of x. 8 | // 9 | // Special cases are: 10 | // 11 | // Acosh(+Inf) = +Inf 12 | // Acosh(x) = NaN if x < 1 13 | // Acosh(NaN) = NaN 14 | export function Acosh(x: number): number { 15 | return Math.acosh(x) 16 | } 17 | 18 | export function acosh(x: number): number { 19 | return Math.acosh(x) 20 | } 21 | 22 | -------------------------------------------------------------------------------- /gs/math/asin.gs.ts: -------------------------------------------------------------------------------- 1 | // Asin returns the arcsine, in radians, of x. 2 | // 3 | // Special cases are: 4 | // 5 | // Asin(±0) = ±0 6 | // Asin(x) = NaN if x < -1 or x > 1 7 | export function Asin(x: number): number { 8 | return Math.asin(x) 9 | } 10 | 11 | export function asin(x: number): number { 12 | return Math.asin(x) 13 | } 14 | 15 | // Acos returns the arccosine, in radians, of x. 16 | // 17 | // Special case is: 18 | // 19 | // Acos(x) = NaN if x < -1 or x > 1 20 | export function Acos(x: number): number { 21 | return Math.acos(x) 22 | } 23 | 24 | export function acos(x: number): number { 25 | return Math.acos(x) 26 | } 27 | 28 | -------------------------------------------------------------------------------- /gs/math/asinh.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | import { IsInf, IsNaN } from "./bits.gs.js"; 3 | import { Log } from "./log.gs.js"; 4 | import { Log1p } from "./log1p.gs.js"; 5 | import { Sqrt } from "./sqrt.gs.js"; 6 | 7 | // Asinh returns the inverse hyperbolic sine of x. 8 | // 9 | // Special cases are: 10 | // 11 | // Asinh(±0) = ±0 12 | // Asinh(±Inf) = ±Inf 13 | // Asinh(NaN) = NaN 14 | export function Asinh(x: number): number { 15 | return Math.asinh(x) 16 | } 17 | 18 | export function asinh(x: number): number { 19 | return Math.asinh(x) 20 | } 21 | 22 | -------------------------------------------------------------------------------- /gs/math/atanh.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | import { Inf, IsNaN, NaN } from "./bits.gs.js"; 3 | import { Log1p } from "./log1p.gs.js"; 4 | 5 | // Atanh returns the inverse hyperbolic tangent of x. 6 | // 7 | // Special cases are: 8 | // 9 | // Atanh(1) = +Inf 10 | // Atanh(±0) = ±0 11 | // Atanh(-1) = -Inf 12 | // Atanh(x) = NaN if x < -1 or x > 1 13 | // Atanh(NaN) = NaN 14 | export function Atanh(x: number): number { 15 | return Math.atanh(x) 16 | } 17 | 18 | export function atanh(x: number): number { 19 | return Math.atanh(x) 20 | } 21 | 22 | -------------------------------------------------------------------------------- /gs/math/cbrt.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | import { IsInf, IsNaN } from "./bits.gs.js"; 3 | 4 | import { Float64bits, Float64frombits } from "./unsafe.gs.js"; 5 | 6 | // Cbrt returns the cube root of x. 7 | // 8 | // Special cases are: 9 | // 10 | // Cbrt(±0) = ±0 11 | // Cbrt(±Inf) = ±Inf 12 | // Cbrt(NaN) = NaN 13 | export function Cbrt(x: number): number { 14 | return Math.cbrt(x) 15 | } 16 | 17 | export function cbrt(x: number): number { 18 | return Math.cbrt(x) 19 | } 20 | 21 | -------------------------------------------------------------------------------- /gs/math/fma.gs.ts: -------------------------------------------------------------------------------- 1 | // FMA returns x * y + z, computed with only one rounding. 2 | // (That is, FMA returns the fused multiply-add of x, y, and z.) 3 | export function FMA(x: number, y: number, z: number): number { 4 | // JavaScript doesn't have native FMA, so we use the simple implementation 5 | // This may not be as precise as a true FMA but is much simpler 6 | return x * y + z 7 | } -------------------------------------------------------------------------------- /gs/math/log.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | import { Inf, IsInf, IsNaN, NaN } from "./bits.gs.js"; 3 | import { Frexp } from "./frexp.gs.js"; 4 | // archLog import removed - using optimized implementation 5 | 6 | // Log returns the natural logarithm of x. 7 | // 8 | // Special cases are: 9 | // 10 | // Log(+Inf) = +Inf 11 | // Log(0) = -Inf 12 | // Log(x < 0) = NaN 13 | // Log(NaN) = NaN 14 | export function Log(x: number): number { 15 | return Math.log(x) 16 | } 17 | 18 | export function log(x: number): number { 19 | return Math.log(x) 20 | } 21 | 22 | -------------------------------------------------------------------------------- /gs/math/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "math/bits" 4 | ] 5 | } -------------------------------------------------------------------------------- /gs/math/signbit.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | import { Float64bits } from "./unsafe.gs.js"; 3 | 4 | // Signbit reports whether x is negative or negative zero. 5 | export function Signbit(x: number): boolean { 6 | return x < 0 || Object.is(x, -0) 7 | } 8 | 9 | -------------------------------------------------------------------------------- /gs/math/sincos.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | import { IsInf, IsNaN, NaN } from "./bits.gs.js"; 3 | import { trigReduce } from "./trig_reduce.gs.js"; 4 | 5 | // Sincos returns Sin(x), Cos(x). 6 | // 7 | // Special cases are: 8 | // 9 | // Sincos(±0) = ±0, 1 10 | // Sincos(±Inf) = NaN, NaN 11 | // Sincos(NaN) = NaN, NaN 12 | export function Sincos(x: number): [number, number] { 13 | return [Math.sin(x), Math.cos(x)] 14 | } 15 | 16 | -------------------------------------------------------------------------------- /gs/math/sqrt.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | import { IsInf, IsNaN, NaN } from "./bits.gs.js"; 3 | import { Float64bits, Float64frombits } from "./unsafe.gs.js"; 4 | 5 | // Sqrt returns the square root of x. 6 | // 7 | // Special cases are: 8 | // 9 | // Sqrt(+Inf) = +Inf 10 | // Sqrt(±0) = ±0 11 | // Sqrt(x < 0) = NaN 12 | // Sqrt(NaN) = NaN 13 | export function Sqrt(x: number): number { 14 | return Math.sqrt(x) 15 | } 16 | 17 | export function sqrt(x: number): number { 18 | return Math.sqrt(x) 19 | } 20 | 21 | -------------------------------------------------------------------------------- /gs/os/error_errno.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.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 | 13 | -------------------------------------------------------------------------------- /gs/os/exec_nohandle.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | 3 | -------------------------------------------------------------------------------- /gs/os/executable_js.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | import { ErrUnimplemented } from "./error.gs.js"; 3 | 4 | export function executable(): [string, $.GoError] { 5 | return ["", ErrUnimplemented] 6 | } -------------------------------------------------------------------------------- /gs/os/executable_wasm.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.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 | 11 | -------------------------------------------------------------------------------- /gs/os/file_open_unix.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | import { ErrUnimplemented } from "./error.gs.js"; 3 | 4 | import * as syscall from "@goscript/syscall/index.js" 5 | 6 | // Stub SysFile for JavaScript environment 7 | class SysFile { 8 | constructor(init?: any) {} 9 | } 10 | 11 | export function open(path: string, flag: number, perm: number): [number, SysFile, $.GoError] { 12 | let [fd, err] = syscall.Open(path, flag, perm) 13 | return [fd, new SysFile({}), err] 14 | } 15 | 16 | -------------------------------------------------------------------------------- /gs/os/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "errors", 4 | "internal/byteorder", 5 | "internal/goarch", 6 | "internal/poll", 7 | "io", 8 | "io/fs", 9 | "runtime", 10 | "sync", 11 | "syscall", 12 | "time", 13 | "unsafe" 14 | ] 15 | } -------------------------------------------------------------------------------- /gs/os/pipe_wasm.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | import { NewSyscallError } from "./error.gs.js"; 3 | 4 | import * as syscall from "@goscript/syscall/index.js" 5 | 6 | // Pipe returns a connected pair of Files; reads from r return bytes written to w. 7 | // It returns the files and an error, if any. 8 | export function Pipe(): [File | null, File | null, $.GoError] { 9 | let r: File | null = null 10 | let w: File | null = null 11 | let err: $.GoError = null 12 | { 13 | // Neither GOOS=js nor GOOS=wasip1 have pipes. 14 | return [null, null, NewSyscallError("pipe", syscall.ENOSYS)] 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /gs/os/proc_js.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | import { ErrUnimplemented } from "./error.gs.js"; 3 | 4 | // JavaScript-specific process functions 5 | 6 | // runtime_args returns command line arguments (stub for JS) 7 | export function runtime_args(): $.Slice { 8 | // In JavaScript environment, return empty args or process.argv equivalent 9 | return $.arrayToSlice([]) 10 | } 11 | 12 | // runtime_beforeExit is called before exit (stub for JS) 13 | export function runtime_beforeExit(exitCode: number): void { 14 | // No-op in JavaScript 15 | } -------------------------------------------------------------------------------- /gs/os/removeall_js.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | import { ErrUnimplemented } from "./error.gs.js"; 3 | 4 | // JavaScript-specific stub for removeall operations 5 | // These operations cannot be implemented in JavaScript environments 6 | 7 | export function RemoveAll(path: string): $.GoError { 8 | return ErrUnimplemented 9 | } -------------------------------------------------------------------------------- /gs/os/root_nonwindows.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | 3 | export function rootCleanPath(s: string, prefix: $.Slice, suffix: $.Slice): [string, $.GoError] { 4 | return [s, null] 5 | } 6 | 7 | -------------------------------------------------------------------------------- /gs/os/sticky_bsd.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | 3 | let supportsCreateWithStickyBit: boolean = false 4 | 5 | -------------------------------------------------------------------------------- /gs/os/sys.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | import { hostname } from "./sys_js.gs.js"; 3 | 4 | // Hostname returns the host name reported by the kernel. 5 | export function Hostname(): [string, $.GoError] { 6 | let name: string = "" 7 | let err: $.GoError = null 8 | { 9 | return hostname() 10 | } 11 | } 12 | 13 | -------------------------------------------------------------------------------- /gs/os/sys_bsd.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | import { NewSyscallError } from "./error.gs.js"; 3 | 4 | import * as syscall from "@goscript/syscall/index.js" 5 | 6 | export function hostname(): [string, $.GoError] { 7 | let name: string = "" 8 | let err: $.GoError = null 9 | { 10 | ;[name, err] = syscall.Sysctl("kern.hostname") 11 | if (err != null) { 12 | return ["", NewSyscallError("sysctl kern.hostname", err)] 13 | } 14 | return [name, null] 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /gs/os/sys_js.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | 3 | let supportsCloseOnExec: boolean = false 4 | 5 | // hostname function for JavaScript environment - return mock data 6 | export function hostname(): [string, $.GoError] { 7 | return ["goscript", null] 8 | } 9 | 10 | -------------------------------------------------------------------------------- /gs/os/wait_unimp.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | 3 | -------------------------------------------------------------------------------- /gs/os/zero_copy_stub.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | 3 | import * as io from "@goscript/io/index.js" 4 | 5 | -------------------------------------------------------------------------------- /gs/path/filepath/index.ts: -------------------------------------------------------------------------------- 1 | export { ErrBadPattern, Glob, Match } from './match.js' 2 | export { 3 | Abs, 4 | Base, 5 | Clean, 6 | Dir, 7 | EvalSymlinks, 8 | Ext, 9 | FromSlash, 10 | IsAbs, 11 | IsLocal, 12 | Join, 13 | ListSeparator, 14 | Localize, 15 | Rel, 16 | Separator, 17 | SkipAll, 18 | SkipDir, 19 | Split, 20 | SplitList, 21 | ToSlash, 22 | VolumeName, 23 | Walk, 24 | WalkDir, 25 | HasPrefix, 26 | } from './path.js' 27 | export type { WalkFunc } from './path.js' 28 | -------------------------------------------------------------------------------- /gs/path/index.ts: -------------------------------------------------------------------------------- 1 | export { ErrBadPattern, Match } from './match.js' 2 | export { Base, Clean, Dir, Ext, IsAbs, Join, Split } from './path.js' 3 | -------------------------------------------------------------------------------- /gs/path/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "errors", 4 | "unicode/utf8" 5 | ] 6 | } -------------------------------------------------------------------------------- /gs/reflect/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "iter" 4 | ] 5 | } -------------------------------------------------------------------------------- /gs/runtime/index.ts: -------------------------------------------------------------------------------- 1 | export * from './runtime.js' 2 | -------------------------------------------------------------------------------- /gs/slices/index.ts: -------------------------------------------------------------------------------- 1 | export * from './slices.js' 2 | -------------------------------------------------------------------------------- /gs/sort/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | Find, 3 | Search, 4 | SearchFloat64s, 5 | SearchInts, 6 | SearchStrings, 7 | } from './search.gs' 8 | export { Slice, SliceIsSorted, SliceStable } from './slice.gs' 9 | export { 10 | Float64Slice, 11 | Float64s, 12 | Float64sAreSorted, 13 | IntSlice, 14 | Ints, 15 | IntsAreSorted, 16 | IsSorted, 17 | Reverse, 18 | Sort, 19 | Stable, 20 | StringSlice, 21 | Strings, 22 | StringsAreSorted, 23 | } from './sort.gs' 24 | export type { Interface } from './sort.gs' 25 | -------------------------------------------------------------------------------- /gs/strconv/doc.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | 3 | -------------------------------------------------------------------------------- /gs/strconv/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "errors" 4 | ] 5 | } -------------------------------------------------------------------------------- /gs/strings/compare.ts: -------------------------------------------------------------------------------- 1 | // Compare returns an integer comparing two strings lexicographically. 2 | // The result will be 0 if a == b, -1 if a < b, and +1 if a > b. 3 | // 4 | // Compare is included only for symmetry with package bytes. 5 | // It is usually clearer and always faster to use the built-in 6 | // string comparison operators ==, <, >, and so on. 7 | export function Compare(a: string, b: string): number { 8 | if (a < b) return -1 9 | if (a > b) return 1 10 | return 0 11 | } 12 | -------------------------------------------------------------------------------- /gs/strings/index.ts: -------------------------------------------------------------------------------- 1 | export * from './builder.js' 2 | export * from './strings.js' 3 | export * from './reader.js' 4 | export { Replacer, NewReplacer } from './replace.js' 5 | export { 6 | Lines, 7 | FieldsSeq, 8 | FieldsFuncSeq, 9 | SplitSeq, 10 | SplitAfterSeq, 11 | } from './iter.js' 12 | // Clone and Compare are already exported from strings.js, so we don't re-export them 13 | -------------------------------------------------------------------------------- /gs/strings/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "errors", 4 | "io", 5 | "iter", 6 | "unicode", 7 | "unicode/utf8" 8 | ] 9 | } -------------------------------------------------------------------------------- /gs/sync/index.ts: -------------------------------------------------------------------------------- 1 | export * from './sync.js' 2 | -------------------------------------------------------------------------------- /gs/sync/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "unsafe" 4 | ], 5 | "asyncMethods": { 6 | "Mutex.Lock": true, 7 | "RWMutex.Lock": true, 8 | "RWMutex.RLock": true, 9 | "WaitGroup.Wait": true, 10 | "Once.Do": true, 11 | "Cond.Wait": true, 12 | "Map.Delete": true, 13 | "Map.Load": true, 14 | "Map.LoadAndDelete": true, 15 | "Map.LoadOrStore": true, 16 | "Map.Range": true, 17 | "Map.Store": true 18 | } 19 | } -------------------------------------------------------------------------------- /gs/time/index.ts: -------------------------------------------------------------------------------- 1 | export * from './time.js' 2 | -------------------------------------------------------------------------------- /gs/unicode/index.ts: -------------------------------------------------------------------------------- 1 | export * from './unicode.js' 2 | -------------------------------------------------------------------------------- /gs/unicode/utf8/index.ts: -------------------------------------------------------------------------------- 1 | // Package utf8 implements functions and constants to support text encoded in UTF-8. 2 | export * from './utf8.js' 3 | -------------------------------------------------------------------------------- /gs/unsafe/index.ts: -------------------------------------------------------------------------------- 1 | export * from './unsafe.js' 2 | -------------------------------------------------------------------------------- /gs_test.go: -------------------------------------------------------------------------------- 1 | package goscript 2 | 3 | import ( 4 | "io/fs" 5 | "slices" 6 | "testing" 7 | ) 8 | 9 | func TestGsOverrides(t *testing.T) { 10 | ents, err := GsOverrides.ReadDir("gs/builtin") 11 | if err != nil { 12 | t.Fatal(err.Error()) 13 | } 14 | 15 | idx := slices.IndexFunc(ents, func(e fs.DirEntry) bool { 16 | return e.Name() == "builtin.ts" 17 | }) 18 | if idx == -1 { 19 | t.FailNow() 20 | } 21 | 22 | builtinContents, err := fs.ReadFile(GsOverrides, "gs/builtin/builtin.ts") 23 | if err != nil { 24 | t.Fatal(err.Error()) 25 | } 26 | t.Logf("Loaded builtin.ts successfully with %d bytes", len(builtinContents)) 27 | } 28 | -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "**/*.test.ts", "compliance"] 4 | } --------------------------------------------------------------------------------