├── .prettierignore ├── .ignore ├── compliance ├── tests │ ├── bytes │ │ └── index.ts │ ├── float64 │ │ ├── index.ts │ │ └── expected.log │ ├── simple │ │ ├── index.ts │ │ ├── expected.log │ │ ├── simple.go │ │ └── simple.gs.ts │ ├── slice │ │ └── index.ts │ ├── varref │ │ ├── index.ts │ │ └── expected.log │ ├── assign_op │ │ ├── index.ts │ │ └── expected.log │ ├── async_basic │ │ ├── index.ts │ │ └── expected.log │ ├── build_tags │ │ ├── index.ts │ │ ├── build_tags_generic.go │ │ ├── build_tags_js.go │ │ ├── expected.log │ │ ├── build_tags_darwin.go │ │ ├── build_tags_windows.go │ │ ├── build_tags_other.go │ │ ├── build_tags_js.gs.ts │ │ ├── build_tags_generic.gs.ts │ │ └── build_tags.go │ ├── for_range │ │ ├── index.ts │ │ └── expected.log │ ├── func_literal │ │ ├── index.ts │ │ ├── expected.log │ │ ├── func_literal.go │ │ └── func_literal.gs.ts │ ├── if_statement │ │ ├── index.ts │ │ ├── expected.log │ │ ├── if_statement.go │ │ └── if_statement.gs.ts │ ├── linkname │ │ ├── index.ts │ │ ├── skip-test │ │ └── linkname.go │ ├── make_slice │ │ └── index.ts │ ├── map_support │ │ └── index.ts │ ├── nil_channel │ │ ├── index.ts │ │ └── expected.log │ ├── slice_nil │ │ ├── index.ts │ │ ├── expected.log │ │ └── slice_nil.go │ ├── slices_grow │ │ ├── index.ts │ │ ├── expected.log │ │ └── slices_grow.go │ ├── string_slice │ │ ├── index.ts │ │ └── expected.log │ ├── array_literal │ │ ├── index.ts │ │ ├── expected.log │ │ └── array_literal.go │ ├── basic_arithmetic │ │ ├── index.ts │ │ ├── expected.log │ │ └── basic_arithmetic.go │ ├── block_comments │ │ ├── index.ts │ │ ├── expected.log │ │ ├── block_comments.go │ │ └── block_comments.gs.ts │ ├── boolean_logic │ │ ├── index.ts │ │ ├── expected.log │ │ └── boolean_logic.go │ ├── channel_basic │ │ ├── index.ts │ │ ├── expected.log │ │ ├── channel_basic.go │ │ └── channel_basic.gs.ts │ ├── defer_statement │ │ ├── index.ts │ │ ├── expected.log │ │ ├── defer_statement.go │ │ └── defer_statement.gs.ts │ ├── flag_bitwise_op │ │ ├── index.ts │ │ └── expected.log │ ├── for_init_exprstmt │ │ ├── index.ts │ │ ├── expected.log │ │ └── for_init_exprstmt.go │ ├── for_init_value_ok │ │ ├── index.ts │ │ ├── expected.log │ │ └── for_init_value_ok.go │ ├── for_loop_basic │ │ ├── index.ts │ │ ├── expected.log │ │ └── for_loop_basic.go │ ├── for_loop_infinite │ │ ├── index.ts │ │ ├── expected.log │ │ ├── for_loop_infinite.go │ │ └── for_loop_infinite.gs.ts │ ├── for_post_exprstmt │ │ ├── index.ts │ │ ├── expected.log │ │ └── for_post_exprstmt.go │ ├── for_post_incdec │ │ ├── index.ts │ │ ├── expected.log │ │ ├── for_post_incdec.go │ │ └── for_post_incdec.gs.ts │ ├── for_range_channel │ │ ├── index.ts │ │ ├── expected.log │ │ └── for_range_channel.go │ ├── for_range_no_vars │ │ ├── index.ts │ │ └── expected.log │ ├── generics_basic │ │ ├── index.ts │ │ ├── expected.log │ │ ├── generics_basic.go │ │ └── generics_basic.gs.ts │ ├── go_type_assertion │ │ ├── index.ts │ │ ├── expected.log │ │ ├── go_type_assertion.go │ │ └── go_type_assertion.gs.ts │ ├── if_type_assert │ │ ├── index.ts │ │ └── expected.log │ ├── import_interface │ │ ├── index.ts │ │ └── expected.log │ ├── iterator_simple │ │ ├── index.ts │ │ └── expected.log │ ├── labeled_statement │ │ ├── index.ts │ │ ├── skip-test │ │ ├── expected.log │ │ └── actual.log │ ├── make_named_types │ │ ├── index.ts │ │ └── expected.log │ ├── octal_literals │ │ ├── index.ts │ │ ├── expected.log │ │ └── octal_literals.go │ ├── package_import │ │ ├── index.ts │ │ ├── .gitignore │ │ ├── expected.log │ │ ├── subpkg │ │ │ ├── index.ts │ │ │ ├── subpkg.go │ │ │ └── subpkg.gs.ts │ │ ├── package_import.go │ │ └── package_import.gs.ts │ ├── package_import_io │ │ ├── index.ts │ │ └── expected.log │ ├── package_import_os │ │ ├── index.ts │ │ └── expected.log │ ├── receiver_binding │ │ ├── index.ts │ │ ├── expected.log │ │ ├── methods.gs.ts │ │ └── storage.go │ ├── receiver_variable │ │ ├── index.ts │ │ └── expected.log │ ├── reserved_words │ │ ├── index.ts │ │ └── expected.log │ ├── rune_const_import │ │ ├── index.ts │ │ ├── subpkg │ │ │ ├── index.ts │ │ │ ├── subpkg.go │ │ │ └── subpkg.gs.ts │ │ └── expected.log │ ├── select_statement │ │ ├── index.ts │ │ └── expected.log │ ├── string_conversion │ │ ├── index.ts │ │ └── expected.log │ ├── switch_case_scope │ │ ├── index.ts │ │ ├── expected.log │ │ └── switch_case_scope.go │ ├── switch_multi_case │ │ ├── index.ts │ │ └── expected.log │ ├── switch_statement │ │ ├── index.ts │ │ └── expected.log │ ├── time_format_ext │ │ └── index.ts │ ├── var_init_order │ │ ├── index.ts │ │ ├── expected.log │ │ ├── var_init_order.go │ │ └── var_init_order.gs.ts │ ├── varref_assign │ │ ├── index.ts │ │ └── expected.log │ ├── varref_deref_set │ │ ├── index.ts │ │ └── expected.log │ ├── varref_pointers │ │ ├── index.ts │ │ └── expected.log │ ├── async_call_in_return │ │ ├── index.ts │ │ └── expected.log │ ├── async_defer_statement │ │ ├── index.ts │ │ ├── expected.log │ │ └── async_defer_statement.go │ ├── chan_type_assertion │ │ ├── index.ts │ │ └── expected.log │ ├── for_init_multi_assign │ │ ├── index.ts │ │ ├── expected.log │ │ ├── for_init_multi_assign.go │ │ └── for_init_multi_assign.gs.ts │ ├── for_post_assign_stmt │ │ ├── index.ts │ │ ├── expected.log │ │ └── for_post_assign_stmt.go │ ├── for_post_multi_assign │ │ ├── index.ts │ │ ├── expected.log │ │ ├── for_post_multi_assign.go │ │ └── for_post_multi_assign.gs.ts │ ├── for_range_index_use │ │ ├── index.ts │ │ ├── expected.log │ │ └── for_range_index_use.go │ ├── for_range_key_only │ │ ├── index.ts │ │ ├── expected.log │ │ └── for_range_key_only.go │ ├── for_range_value_only │ │ ├── index.ts │ │ └── expected.log │ ├── generics_leading_int │ │ ├── index.ts │ │ └── expected.log │ ├── goroutines_anonymous │ │ ├── index.ts │ │ ├── expected.log │ │ ├── goroutines_anonymous.go │ │ └── goroutines_anonymous.gs.ts │ ├── hex_escape_sequence │ │ ├── index.ts │ │ └── expected.log │ ├── import_named_multiple │ │ └── index.ts │ ├── import_type_methods │ │ ├── index.ts │ │ ├── expected.log │ │ ├── errlist │ │ │ ├── index.ts │ │ │ ├── errlist.go │ │ │ └── errlist.gs.ts │ │ └── import_type_methods.go │ ├── keyed_array_literal │ │ ├── index.ts │ │ └── expected.log │ ├── make_selector_type │ │ ├── index.ts │ │ ├── expected.log │ │ └── make_selector_type.go │ ├── map_assign_blank_both │ │ ├── index.ts │ │ ├── expected.log │ │ └── map_assign_blank_both.go │ ├── map_type_assertion │ │ ├── index.ts │ │ └── expected.log │ ├── missing_valueof_error │ │ ├── index.ts │ │ └── expected.log │ ├── multiple_return_values │ │ ├── index.ts │ │ ├── expected.log │ │ └── multiple_return_values.go │ ├── named_return_method │ │ ├── index.ts │ │ └── expected.log │ ├── named_return_multiple │ │ ├── index.ts │ │ └── expected.log │ ├── os_filemode_struct │ │ ├── index.ts │ │ ├── expected.log │ │ └── os_filemode_struct.go │ ├── package_import_bytes │ │ └── index.ts │ ├── package_import_context │ │ ├── index.ts │ │ ├── packages │ │ └── expected.log │ ├── package_import_csync │ │ ├── index.ts │ │ └── expected.log │ ├── package_import_errors │ │ ├── index.ts │ │ └── expected.log │ ├── package_import_fmt │ │ ├── index.ts │ │ └── expected.log │ ├── package_import_io_fs │ │ └── index.ts │ ├── package_import_maps │ │ ├── index.ts │ │ └── expected.log │ ├── package_import_path │ │ ├── index.ts │ │ └── expected.log │ ├── package_import_runtime │ │ ├── index.ts │ │ ├── packages │ │ └── expected.log │ ├── package_import_slices │ │ ├── index.ts │ │ ├── expected.log │ │ └── package_import_slices.go │ ├── package_import_sort │ │ └── index.ts │ ├── package_import_strconv │ │ ├── index.ts │ │ └── expected.log │ ├── package_import_strings │ │ ├── index.ts │ │ └── expected.log │ ├── package_import_sync │ │ └── index.ts │ ├── package_import_time │ │ ├── index.ts │ │ └── expected.log │ ├── package_import_unicode │ │ └── index.ts │ ├── path_error_constructor │ │ ├── index.ts │ │ ├── expected.log │ │ └── path_error_constructor.go │ ├── pointer_range_loop │ │ ├── index.ts │ │ ├── expected.log │ │ ├── pointer_range_loop.go │ │ └── pointer_range_loop.gs.ts │ ├── redeclaration_assign │ │ ├── index.ts │ │ └── expected.log │ ├── reflect_struct_field │ │ ├── index.ts │ │ ├── expected.log │ │ └── reflect_struct_field.go │ ├── rune_const_reference │ │ ├── index.ts │ │ ├── subpkg │ │ │ ├── index.ts │ │ │ ├── subpkg.go │ │ │ └── subpkg.gs.ts │ │ └── expected.log │ ├── select_mixed_returns │ │ ├── index.ts │ │ └── expected.log │ ├── simple_pointer_assign │ │ ├── index.ts │ │ ├── expected.log │ │ └── simple_pointer_assign.go │ ├── slices_sortfunc_nil │ │ ├── index.ts │ │ ├── expected.log │ │ └── slices_sortfunc_nil.go │ ├── star_compound_assign │ │ ├── index.ts │ │ ├── expected.log │ │ └── star_compound_assign.go │ ├── string_copy_to_array │ │ ├── index.ts │ │ ├── expected.log │ │ └── string_copy_to_array.go │ ├── string_index_access │ │ ├── index.ts │ │ └── expected.log │ ├── string_type_assertion │ │ ├── index.ts │ │ ├── expected.log │ │ ├── string_type_assertion.go │ │ └── string_type_assertion.gs.ts │ ├── struct_type_assertion │ │ ├── index.ts │ │ └── expected.log │ ├── type_missing_imports │ │ ├── index.ts │ │ └── expected.log │ ├── type_separate_files │ │ ├── index.ts │ │ ├── expected.log │ │ ├── memory.go │ │ ├── storage.go │ │ └── type_separate_files.go │ ├── type_switch_statement │ │ ├── index.ts │ │ └── expected.log │ ├── undefined_type_error │ │ ├── index.ts │ │ └── expected.log │ ├── varref_pointers_deref │ │ ├── index.ts │ │ └── expected.log │ ├── varref_pointers_number │ │ ├── index.ts │ │ └── expected.log │ ├── wrapper_slice_append │ │ ├── index.ts │ │ ├── expected.log │ │ ├── errlist │ │ │ ├── index.ts │ │ │ └── errlist.go │ │ └── wrapper_slice_append.go │ ├── bitwise_and_not_assignment │ │ ├── index.ts │ │ ├── expected.log │ │ └── bitwise_and_not_assignment.go │ ├── buffer_value_field_error │ │ ├── index.ts │ │ └── expected.log │ ├── channel_receive_both_blank │ │ ├── index.ts │ │ ├── expected.log │ │ └── channel_receive_both_blank.go │ ├── destructure_trailing_comma │ │ ├── index.ts │ │ ├── expected.log │ │ └── destructure_trailing_comma.go │ ├── destructuring_assignment │ │ ├── index.ts │ │ └── expected.log │ ├── discarded_channel_receive │ │ ├── index.ts │ │ ├── expected.log │ │ └── discarded_channel_receive.go │ ├── for_loop_condition_only │ │ ├── index.ts │ │ ├── expected.log │ │ ├── for_loop_condition_only.go │ │ └── for_loop_condition_only.gs.ts │ ├── function_returns_function │ │ ├── index.ts │ │ ├── expected.log │ │ └── function_returns_function.go │ ├── generic_index_assignment │ │ ├── index.ts │ │ └── expected.log │ ├── index_expr_destructuring │ │ ├── index.ts │ │ └── expected.log │ ├── index_expr_type_assertion │ │ ├── index.ts │ │ └── expected.log │ ├── method_async_call │ │ ├── expected.log │ │ └── index.ts │ ├── package_import_go_parser │ │ ├── index.ts │ │ ├── actual.log │ │ └── expected.log │ ├── package_import_go_scanner │ │ ├── index.ts │ │ ├── actual.log │ │ ├── expect-fail │ │ ├── expected.log │ │ └── package_import_go_scanner.go │ ├── package_import_pkg_errors │ │ └── index.ts │ ├── package_import_sync_atomic │ │ └── index.ts │ ├── package_import_unicode_utf8 │ │ ├── index.ts │ │ └── expected.log │ ├── package_var_async_method │ │ ├── index.ts │ │ ├── expected.log │ │ └── package_var_async_method.go │ ├── star_expr_destructuring │ │ ├── index.ts │ │ ├── expected.log │ │ └── star_expr_destructuring.go │ ├── string_index_array_access │ │ ├── index.ts │ │ ├── expected.log │ │ └── string_index_array_access.go │ ├── struct_literal_interface │ │ ├── index.ts │ │ ├── expected.log │ │ └── struct_literal_interface.go │ ├── struct_private_field │ │ ├── expected.log │ │ ├── index.ts │ │ └── struct_private_field.go │ ├── variable_shadowing_scope │ │ ├── index.ts │ │ └── expected.log │ ├── variadic_interface_param │ │ ├── index.ts │ │ └── expected.log │ ├── call_async_returned_function │ │ ├── index.ts │ │ └── expected.log │ ├── call_returned_function_async │ │ ├── index.ts │ │ └── expected.log │ ├── for_loop_multi_assign_mismatch │ │ ├── index.ts │ │ ├── expected.log │ │ └── for_loop_multi_assign_mismatch.go │ ├── missing_package_methods_issue │ │ ├── index.ts │ │ └── expected.log │ ├── nil_pkg_pointer_dereference │ │ ├── no-all-deps │ │ ├── index.ts │ │ ├── expected.log │ │ └── output.txt │ ├── package_import_encoding_json │ │ ├── skip-test │ │ ├── index.ts │ │ ├── actual.log │ │ └── expected.log │ ├── package_import_path_filepath │ │ └── index.ts │ ├── package_import_testing_fstest │ │ ├── index.ts │ │ ├── skip-test │ │ ├── actual.log │ │ └── expected.log │ ├── pointer_deref_multiassign │ │ ├── expected.log │ │ └── index.ts │ ├── pointer_struct_assign_clone │ │ ├── expect-fail │ │ ├── actual.log │ │ ├── expected.log │ │ └── index.ts │ ├── struct_private_field_ptr │ │ ├── expected.log │ │ ├── index.ts │ │ └── struct_private_field_ptr.go │ ├── pointer_composite_literal_untyped │ │ ├── index.ts │ │ └── expected.log │ ├── receiver_method │ │ ├── expected.log │ │ ├── index.ts │ │ └── main.go │ ├── method_async_dependency │ │ ├── expected.log │ │ └── index.ts │ ├── promise_return_type │ │ ├── expected.log │ │ └── index.ts │ ├── selector_expr_lhs_multi_assign │ │ ├── expected.log │ │ ├── index.ts │ │ └── selector_expr_lhs_multi_assign.go │ ├── method_receiver_async_paren │ │ ├── expected.log │ │ └── index.ts │ ├── method_receiver_await_paren │ │ ├── expected.log │ │ └── index.ts │ ├── method_receiver_call_return │ │ ├── expected.log │ │ ├── index.ts │ │ └── method_receiver_call_return.go │ ├── method_receiver_paren_line │ │ ├── expected.log │ │ ├── index.ts │ │ └── method_receiver_paren_line.go │ ├── method_receiver_shadowing │ │ ├── expected.log │ │ ├── index.ts │ │ └── method_receiver_shadowing.go │ ├── select_receive_on_closed_channel_no_default │ │ ├── index.ts │ │ ├── expected.log │ │ └── select_receive_on_closed_channel_no_default.go │ ├── varref_deref_struct │ │ ├── expected.log │ │ ├── index.ts │ │ └── varref_deref_struct.go │ ├── generics │ │ ├── index.ts │ │ └── expected.log │ ├── method_receiver_with_call_expr │ │ ├── expected.log │ │ └── index.ts │ ├── private_field_access │ │ ├── expected.log │ │ └── index.ts │ ├── select_send_on_full_buffered_channel_with_default │ │ ├── index.ts │ │ ├── expected.log │ │ └── select_send_on_full_buffered_channel_with_default.go │ ├── varref_struct │ │ ├── expected.log │ │ ├── index.ts │ │ └── varref_struct.go │ ├── comments_struct │ │ ├── expected.log │ │ ├── index.ts │ │ └── comments_struct.go │ ├── constants │ │ ├── expected.log │ │ └── index.ts │ ├── defer_async_method │ │ ├── expected.log │ │ └── index.ts │ ├── goroutines_selector │ │ ├── expected.log │ │ ├── index.ts │ │ └── goroutines_selector.go │ ├── inline_function_type_cast │ │ ├── expected.log │ │ └── index.ts │ ├── interface_type_reference │ │ ├── expected.log │ │ └── index.ts │ ├── named_slice_wrapper │ │ ├── expected.log │ │ └── index.ts │ ├── pointers │ │ └── index.ts │ ├── simple_interface │ │ ├── expected.log │ │ ├── index.ts │ │ └── simple_interface.go │ ├── var_init_method_call │ │ ├── expected.log │ │ ├── index.ts │ │ └── var_init_method_call.go │ ├── generic_string_constraint │ │ ├── expected.log │ │ └── index.ts │ ├── goroutines │ │ ├── index.ts │ │ └── expected.log │ ├── interface_method_comments │ │ ├── expected.log │ │ ├── index.ts │ │ └── interface_method_comments.go │ ├── slices_sortfunc │ │ ├── expected.log │ │ └── index.ts │ ├── struct_new │ │ ├── index.ts │ │ └── expected.log │ ├── interface_to_interface_type_assertion │ │ ├── expected.log │ │ └── index.ts │ ├── method_binding │ │ ├── index.ts │ │ └── expected.log │ ├── recursive_type_definition │ │ ├── expected.log │ │ ├── index.ts │ │ └── recursive_type_definition.go │ ├── return_async_call │ │ ├── expected.log │ │ └── index.ts │ ├── selector_expr_ok_variable │ │ ├── expected.log │ │ ├── index.ts │ │ └── selector_expr_ok_variable.go │ ├── type_assertion_duplicate_vars │ │ ├── expected.log │ │ └── index.ts │ ├── embedded_interface_assertion │ │ ├── expected.log │ │ └── index.ts │ ├── make_generic_type │ │ ├── expected.log │ │ └── index.ts │ ├── method_call_slice_type │ │ ├── expected.log │ │ ├── index.ts │ │ └── method_call_slice_type.go │ ├── type_method_primitive │ │ ├── expected.log │ │ ├── index.ts │ │ └── type_method_primitive.go │ ├── copy_independence │ │ ├── index.ts │ │ └── expected.log │ ├── varref_composite_lit │ │ ├── expected.log │ │ └── index.ts │ ├── varref_struct_init │ │ ├── expected.log │ │ └── index.ts │ ├── method_call_on_value_receiver │ │ ├── expected.log │ │ ├── index.ts │ │ └── method_call_on_value_receiver.go │ ├── struct_field_access │ │ ├── index.ts │ │ ├── expected.log │ │ └── struct_field_access.go │ ├── struct_pointer_interface_fields │ │ ├── expected.log │ │ └── index.ts │ ├── variadic_function_call │ │ ├── index.ts │ │ └── expected.log │ ├── embedded_interface_null_assertion │ │ ├── expected.log │ │ └── index.ts │ ├── pointer_initialization │ │ ├── index.ts │ │ └── expected.log │ ├── simple_deref_assignment │ │ ├── index.ts │ │ └── expected.log │ ├── struct_pointer_marking │ │ └── index.ts │ ├── struct_value_init_clone │ │ ├── index.ts │ │ └── expected.log │ ├── atomic_struct_field_init │ │ ├── index.ts │ │ └── expected.log │ ├── pointer_assignment_no_copy │ │ ├── index.ts │ │ └── expected.log │ ├── protobuf_lite_ts │ │ ├── index.ts │ │ ├── protobuf_lite_ts.proto │ │ └── expected.log │ ├── struct_embedding_bytes_buffer │ │ ├── expected.log │ │ ├── index.ts │ │ └── struct_embedding_bytes_buffer.go │ ├── composite_literal_assignment │ │ ├── index.ts │ │ └── expected.log │ ├── interface_async_method_call │ │ ├── expected.log │ │ └── index.ts │ ├── interface_pointer_assignment │ │ └── index.ts │ ├── reflect_implements │ │ ├── expected.log │ │ └── index.ts │ ├── filepath_walkfunc_call │ │ ├── expected.log │ │ └── index.ts │ ├── method_call_on_pointer_receiver │ │ ├── index.ts │ │ └── expected.log │ ├── value_type_copy_behavior │ │ └── index.ts │ ├── method_call_on_pointer_via_value │ │ ├── expected.log │ │ └── index.ts │ ├── method_call_on_value_via_pointer │ │ ├── index.ts │ │ └── expected.log │ ├── pointer_circular_ref │ │ ├── index.ts │ │ └── expected.log │ ├── struct_embedding │ │ └── index.ts │ ├── interface_type_assertion │ │ ├── expected.log │ │ └── index.ts │ ├── pointer_composite_literal_assignment │ │ ├── index.ts │ │ └── expected.log │ ├── type_conversion_interface_ptr_nil │ │ ├── index.ts │ │ └── expected.log │ ├── variadic_interface_method │ │ ├── expected.log │ │ └── index.ts │ ├── nullable_function_param_call │ │ ├── expected.log │ │ └── index.ts │ ├── named_type_wrapper │ │ ├── expected.log │ │ └── index.ts │ ├── selective_exports │ │ ├── index.ts │ │ ├── expected.log │ │ └── utils.go │ ├── interface_multi_param_return │ │ ├── expected.log │ │ └── index.ts │ ├── reflect_typefor │ │ ├── index.ts │ │ └── expected.log │ ├── interface_embedding │ │ ├── index.ts │ │ ├── subpkg │ │ │ └── index.ts │ │ └── expected.log │ ├── util_promise │ │ ├── index.ts │ │ └── expected.log │ ├── package_import_reflect │ │ └── index.ts │ ├── interface_subset_cast │ │ ├── expected.log │ │ └── index.ts │ ├── interface_subset_type_switch │ │ ├── expected.log │ │ └── index.ts │ ├── function_type_assertion │ │ ├── index.ts │ │ └── expected.log │ ├── named_function_type_call │ │ ├── expected.log │ │ └── index.ts │ ├── named_types_valueof │ │ ├── index.ts │ │ └── subpkg │ │ │ └── index.ts │ ├── function_call_result_assignment │ │ ├── index.ts │ │ └── expected.log │ ├── generics_interface │ │ ├── index.ts │ │ └── expected.log │ ├── function_call_variable_shadowing │ │ ├── expected.log │ │ └── index.ts │ ├── inline_interface_type_assertion │ │ ├── index.ts │ │ └── expected.log │ ├── function_signature_type │ │ ├── index.ts │ │ └── expected.log │ ├── type_declaration_receiver │ │ ├── index.ts │ │ └── expected.log │ ├── wrapper_type_args │ │ ├── index.ts │ │ └── expected.log │ └── constants_iota │ │ ├── index.ts │ │ └── expected.log ├── .ignore ├── .gitignore └── deps │ ├── github.com │ └── aperturerobotics │ │ └── util │ │ ├── broadcast │ │ └── index.ts │ │ └── csync │ │ └── index.ts │ ├── unicode │ └── utf16 │ │ └── index.ts │ ├── encoding │ ├── index.ts │ └── base64 │ │ └── index.ts │ └── go │ └── scanner │ └── index.ts ├── cmd └── goscript │ ├── .gitignore │ ├── deps.go │ └── main.go ├── gs ├── io │ ├── index.ts │ ├── meta.json │ └── fs │ │ └── index.ts ├── iter │ └── index.ts ├── sync │ ├── index.ts │ └── meta.json ├── time │ ├── index.ts │ └── meta.json ├── context │ ├── index.ts │ └── meta.json ├── errors │ └── index.ts ├── runtime │ └── index.ts ├── slices │ └── index.ts ├── unicode │ ├── index.ts │ └── utf8 │ │ └── index.ts ├── unsafe │ └── index.ts ├── fmt │ └── meta.json ├── internal │ ├── meta.json │ └── oserror │ │ ├── index.ts │ │ └── errors.ts ├── math │ ├── meta.json │ ├── signbit.gs.ts │ ├── abs.gs.ts │ ├── fma.gs.ts │ ├── sincos.gs.ts │ ├── cbrt.gs.ts │ └── sqrt.gs.ts ├── reflect │ └── meta.json ├── strconv │ ├── doc.gs.ts │ └── meta.json ├── os │ ├── exec_nohandle.gs.ts │ ├── wait_unimp.gs.ts │ ├── sticky_bsd.gs.ts │ ├── zero_copy_stub.gs.ts │ ├── executable_js.gs.ts │ ├── root_nonwindows.gs.ts │ ├── meta.json │ ├── sys_js.gs.ts │ ├── sys.gs.ts │ ├── removeall_js.gs.ts │ ├── executable_wasm.gs.ts │ ├── error_errno.gs.ts │ ├── file_open_unix.gs.ts │ └── sys_bsd.gs.ts ├── maps │ ├── meta.json │ └── index.ts ├── path │ ├── meta.json │ ├── index.ts │ └── filepath │ │ └── index.ts ├── strings │ ├── meta.json │ ├── index.ts │ └── compare.ts ├── bytes │ └── meta.json ├── builtin │ └── index.ts ├── README.md ├── cmp │ └── godoc.txt ├── github.com │ └── pkg │ │ └── errors │ │ └── index.ts ├── syscall │ └── index.ts └── sort │ └── index.ts ├── example └── simple │ ├── .gitignore │ ├── .rooignore │ ├── main.ts │ ├── run.bash │ ├── main_tools.go │ ├── package.json │ ├── build.bash │ └── yarn.lock ├── .prettierrc.yaml ├── .gitignore ├── tsconfig.build.json ├── .vscode └── extensions.json ├── gs.go └── .npmignore /.prettierignore: -------------------------------------------------------------------------------- 1 | *.gs.ts -------------------------------------------------------------------------------- /.ignore: -------------------------------------------------------------------------------- 1 | .aider* 2 | yarn.lock 3 | -------------------------------------------------------------------------------- /compliance/tests/bytes/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/float64/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/simple/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/slice/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/varref/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/assign_op/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/async_basic/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/build_tags/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/for_range/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/func_literal/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/if_statement/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/linkname/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/linkname/skip-test: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/make_slice/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/map_support/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/nil_channel/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/slice_nil/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/slices_grow/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/string_slice/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cmd/goscript/.gitignore: -------------------------------------------------------------------------------- 1 | output/ 2 | goscript -------------------------------------------------------------------------------- /compliance/tests/array_literal/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/async_basic/expected.log: -------------------------------------------------------------------------------- 1 | 11 -------------------------------------------------------------------------------- /compliance/tests/basic_arithmetic/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/block_comments/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/boolean_logic/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/channel_basic/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/defer_statement/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/flag_bitwise_op/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/for_init_exprstmt/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/for_init_value_ok/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/for_loop_basic/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/for_loop_infinite/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/for_post_exprstmt/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/for_post_incdec/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/for_range_channel/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/for_range_no_vars/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/generics_basic/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/go_type_assertion/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/if_type_assert/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/import_interface/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/iterator_simple/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/labeled_statement/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/make_named_types/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/octal_literals/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_io/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_os/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/receiver_binding/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/receiver_variable/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/reserved_words/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/rune_const_import/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/select_statement/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/string_conversion/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/switch_case_scope/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/switch_multi_case/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/switch_statement/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/time_format_ext/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/var_init_order/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/varref_assign/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/varref_deref_set/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/varref_pointers/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /gs/io/index.ts: -------------------------------------------------------------------------------- 1 | export * from './io.js' 2 | -------------------------------------------------------------------------------- /compliance/.ignore: -------------------------------------------------------------------------------- 1 | *.gs.ts 2 | expected.log 3 | -------------------------------------------------------------------------------- /compliance/tests/async_call_in_return/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/async_defer_statement/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/chan_type_assertion/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/channel_basic/expected.log: -------------------------------------------------------------------------------- 1 | ping -------------------------------------------------------------------------------- /compliance/tests/for_init_multi_assign/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/for_post_assign_stmt/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/for_post_multi_assign/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/for_range_index_use/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/for_range_key_only/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/for_range_value_only/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/generics_leading_int/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/goroutines_anonymous/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/hex_escape_sequence/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/import_named_multiple/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/import_type_methods/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/keyed_array_literal/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/labeled_statement/skip-test: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/make_selector_type/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/map_assign_blank_both/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/map_type_assertion/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/missing_valueof_error/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/multiple_return_values/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/named_return_method/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/named_return_multiple/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/os_filemode_struct/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_bytes/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_context/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_csync/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_errors/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_fmt/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_io_fs/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_maps/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_path/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_runtime/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_slices/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_sort/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_strconv/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_strings/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_sync/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_time/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_unicode/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/path_error_constructor/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/pointer_range_loop/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/redeclaration_assign/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/reflect_struct_field/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/rune_const_reference/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/select_mixed_returns/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/simple/expected.log: -------------------------------------------------------------------------------- 1 | Hello world! -------------------------------------------------------------------------------- /compliance/tests/simple_pointer_assign/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/slices_sortfunc_nil/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/star_compound_assign/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/string_copy_to_array/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/string_index_access/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/string_type_assertion/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/struct_type_assertion/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/type_missing_imports/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/type_separate_files/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/type_switch_statement/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/undefined_type_error/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/varref_deref_set/expected.log: -------------------------------------------------------------------------------- 1 | 15 -------------------------------------------------------------------------------- /compliance/tests/varref_pointers_deref/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/varref_pointers_number/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/wrapper_slice_append/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /gs/iter/index.ts: -------------------------------------------------------------------------------- 1 | export * from './iter.js' 2 | -------------------------------------------------------------------------------- /gs/sync/index.ts: -------------------------------------------------------------------------------- 1 | export * from './sync.js' 2 | -------------------------------------------------------------------------------- /gs/time/index.ts: -------------------------------------------------------------------------------- 1 | export * from './time.js' 2 | -------------------------------------------------------------------------------- /compliance/.gitignore: -------------------------------------------------------------------------------- 1 | run 2 | go.mod 3 | go.sum 4 | -------------------------------------------------------------------------------- /compliance/tests/bitwise_and_not_assignment/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/buffer_value_field_error/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/channel_receive_both_blank/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/destructure_trailing_comma/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/destructuring_assignment/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/discarded_channel_receive/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/for_loop_condition_only/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/function_returns_function/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/generic_index_assignment/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/index_expr_destructuring/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/index_expr_type_assertion/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/method_async_call/expected.log: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /compliance/tests/package_import/.gitignore: -------------------------------------------------------------------------------- 1 | !go.mod -------------------------------------------------------------------------------- /compliance/tests/package_import_go_parser/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_go_scanner/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_pkg_errors/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_sync_atomic/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_unicode_utf8/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_var_async_method/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/star_expr_destructuring/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/string_index_array_access/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/struct_literal_interface/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/struct_private_field/expected.log: -------------------------------------------------------------------------------- 1 | 10 -------------------------------------------------------------------------------- /compliance/tests/variable_shadowing_scope/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/variadic_interface_param/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /gs/context/index.ts: -------------------------------------------------------------------------------- 1 | export * from './context.js' 2 | -------------------------------------------------------------------------------- /gs/errors/index.ts: -------------------------------------------------------------------------------- 1 | export * from './errors.js' 2 | -------------------------------------------------------------------------------- /gs/runtime/index.ts: -------------------------------------------------------------------------------- 1 | export * from './runtime.js' 2 | -------------------------------------------------------------------------------- /gs/slices/index.ts: -------------------------------------------------------------------------------- 1 | export * from './slices.js' 2 | -------------------------------------------------------------------------------- /gs/unicode/index.ts: -------------------------------------------------------------------------------- 1 | export * from './unicode.js' 2 | -------------------------------------------------------------------------------- /gs/unsafe/index.ts: -------------------------------------------------------------------------------- 1 | export * from './unsafe.js' 2 | -------------------------------------------------------------------------------- /compliance/tests/call_async_returned_function/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/call_returned_function_async/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/for_loop_multi_assign_mismatch/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/for_post_incdec/expected.log: -------------------------------------------------------------------------------- 1 | 0 2 | done -------------------------------------------------------------------------------- /compliance/tests/for_range_channel/expected.log: -------------------------------------------------------------------------------- 1 | 0 2 | 1 -------------------------------------------------------------------------------- /compliance/tests/func_literal/expected.log: -------------------------------------------------------------------------------- 1 | Hello, world -------------------------------------------------------------------------------- /compliance/tests/import_type_methods/expected.log: -------------------------------------------------------------------------------- 1 | error -------------------------------------------------------------------------------- /compliance/tests/missing_package_methods_issue/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/nil_pkg_pointer_dereference/no-all-deps: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import/expected.log: -------------------------------------------------------------------------------- 1 | Hello, world -------------------------------------------------------------------------------- /compliance/tests/package_import_encoding_json/skip-test: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_go_parser/actual.log: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /compliance/tests/package_import_go_scanner/actual.log: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /compliance/tests/package_import_go_scanner/expect-fail: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_path_filepath/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_testing_fstest/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/package_import_testing_fstest/skip-test: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/pointer_deref_multiassign/expected.log: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/pointer_struct_assign_clone/expect-fail: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/struct_private_field_ptr/expected.log: -------------------------------------------------------------------------------- 1 | 15 -------------------------------------------------------------------------------- /compliance/tests/varref_assign/expected.log: -------------------------------------------------------------------------------- 1 | ***p3 == 15 -------------------------------------------------------------------------------- /compliance/tests/defer_statement/expected.log: -------------------------------------------------------------------------------- 1 | main 2 | deferred -------------------------------------------------------------------------------- /compliance/tests/discarded_channel_receive/expected.log: -------------------------------------------------------------------------------- 1 | done -------------------------------------------------------------------------------- /compliance/tests/for_init_multi_assign/expected.log: -------------------------------------------------------------------------------- 1 | 0 1 2 | 1 11 -------------------------------------------------------------------------------- /compliance/tests/package_import_testing_fstest/actual.log: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /compliance/tests/pointer_composite_literal_untyped/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/receiver_method/expected.log: -------------------------------------------------------------------------------- 1 | 10 2 | 42 3 | -------------------------------------------------------------------------------- /compliance/tests/star_compound_assign/expected.log: -------------------------------------------------------------------------------- 1 | 5 2 | 4 3 | -------------------------------------------------------------------------------- /compliance/tests/switch_case_scope/expected.log: -------------------------------------------------------------------------------- 1 | 30 2 | done 3 | -------------------------------------------------------------------------------- /compliance/tests/destructure_trailing_comma/expected.log: -------------------------------------------------------------------------------- 1 | nref: 42 -------------------------------------------------------------------------------- /compliance/tests/method_async_dependency/expected.log: -------------------------------------------------------------------------------- 1 | Success 2 | -------------------------------------------------------------------------------- /compliance/tests/promise_return_type/expected.log: -------------------------------------------------------------------------------- 1 | Result: 42 2 | -------------------------------------------------------------------------------- /compliance/tests/selector_expr_lhs_multi_assign/expected.log: -------------------------------------------------------------------------------- 1 | 10 20 -------------------------------------------------------------------------------- /example/simple/.gitignore: -------------------------------------------------------------------------------- 1 | output/ 2 | node_modules/ 3 | example 4 | -------------------------------------------------------------------------------- /compliance/tests/for_init_exprstmt/expected.log: -------------------------------------------------------------------------------- 1 | init_func called 2 | done -------------------------------------------------------------------------------- /compliance/tests/for_init_value_ok/expected.log: -------------------------------------------------------------------------------- 1 | value: 10 2 | v: 20 3 | -------------------------------------------------------------------------------- /compliance/tests/function_returns_function/expected.log: -------------------------------------------------------------------------------- 1 | Result: 8 2 | -------------------------------------------------------------------------------- /compliance/tests/generics_basic/expected.log: -------------------------------------------------------------------------------- 1 | 10 2 | hello 3 | true 4 | -------------------------------------------------------------------------------- /compliance/tests/if_statement/expected.log: -------------------------------------------------------------------------------- 1 | Odd: Expected: Odd, Actual: Odd -------------------------------------------------------------------------------- /compliance/tests/make_named_types/expected.log: -------------------------------------------------------------------------------- 1 | Length: 5 2 | Value: 42 -------------------------------------------------------------------------------- /compliance/tests/method_receiver_async_paren/expected.log: -------------------------------------------------------------------------------- 1 | Result: 42 2 | -------------------------------------------------------------------------------- /compliance/tests/method_receiver_await_paren/expected.log: -------------------------------------------------------------------------------- 1 | Result: 42 2 | -------------------------------------------------------------------------------- /compliance/tests/method_receiver_call_return/expected.log: -------------------------------------------------------------------------------- 1 | Result: 42 2 | -------------------------------------------------------------------------------- /compliance/tests/method_receiver_paren_line/expected.log: -------------------------------------------------------------------------------- 1 | Result: 42 2 | -------------------------------------------------------------------------------- /compliance/tests/method_receiver_shadowing/expected.log: -------------------------------------------------------------------------------- 1 | Result: 42 2 | -------------------------------------------------------------------------------- /compliance/tests/package_var_async_method/expected.log: -------------------------------------------------------------------------------- 1 | Found: world 2 | -------------------------------------------------------------------------------- /compliance/tests/select_receive_on_closed_channel_no_default/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/string_copy_to_array/expected.log: -------------------------------------------------------------------------------- 1 | Copy succeeded 2 | -------------------------------------------------------------------------------- /compliance/tests/string_type_assertion/expected.log: -------------------------------------------------------------------------------- 1 | value is test 2 | -------------------------------------------------------------------------------- /compliance/tests/varref_deref_struct/expected.log: -------------------------------------------------------------------------------- 1 | 5 2 | expected not equal -------------------------------------------------------------------------------- /gs/fmt/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "errors" 4 | ] 5 | } -------------------------------------------------------------------------------- /compliance/tests/call_async_returned_function/expected.log: -------------------------------------------------------------------------------- 1 | Callback: hello 2 | -------------------------------------------------------------------------------- /compliance/tests/generics/index.ts: -------------------------------------------------------------------------------- 1 | export { Pair } from "./generics.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/goroutines_anonymous/expected.log: -------------------------------------------------------------------------------- 1 | anonymous function worker -------------------------------------------------------------------------------- /compliance/tests/method_receiver_with_call_expr/expected.log: -------------------------------------------------------------------------------- 1 | value: 42 2 | -------------------------------------------------------------------------------- /compliance/tests/private_field_access/expected.log: -------------------------------------------------------------------------------- 1 | Accessing privateField: 123 -------------------------------------------------------------------------------- /compliance/tests/select_send_on_full_buffered_channel_with_default/index.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /compliance/tests/star_expr_destructuring/expected.log: -------------------------------------------------------------------------------- 1 | a: 42 2 | b: hello 3 | -------------------------------------------------------------------------------- /compliance/tests/var_init_order/expected.log: -------------------------------------------------------------------------------- 1 | a: 10 2 | b: 15 3 | c: 30 4 | -------------------------------------------------------------------------------- /compliance/tests/varref_struct/expected.log: -------------------------------------------------------------------------------- 1 | ptrToVal.MyInt: 10 2 | myIntVal: 10 -------------------------------------------------------------------------------- /compliance/tests/wrapper_slice_append/expected.log: -------------------------------------------------------------------------------- 1 | error 2 | astruct 3 | 4 | -------------------------------------------------------------------------------- /gs/internal/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "errors" 4 | ] 5 | } -------------------------------------------------------------------------------- /gs/math/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "math/bits" 4 | ] 5 | } -------------------------------------------------------------------------------- /gs/reflect/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "iter" 4 | ] 5 | } -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /compliance/tests/array_literal/expected.log: -------------------------------------------------------------------------------- 1 | 1 2 3 2 | hello world 3 | 0 10 0 30 0 -------------------------------------------------------------------------------- /compliance/tests/block_comments/expected.log: -------------------------------------------------------------------------------- 1 | testing block comments 2 | x = 42 3 | -------------------------------------------------------------------------------- /compliance/tests/comments_struct/expected.log: -------------------------------------------------------------------------------- 1 | IntField: 42 2 | StringField: hello -------------------------------------------------------------------------------- /compliance/tests/constants/expected.log: -------------------------------------------------------------------------------- 1 | 3.14 2 | false 3 | Hello, Constants! 4 | 4 -------------------------------------------------------------------------------- /compliance/tests/defer_async_method/expected.log: -------------------------------------------------------------------------------- 1 | main function 2 | Released test -------------------------------------------------------------------------------- /compliance/tests/for_loop_multi_assign_mismatch/expected.log: -------------------------------------------------------------------------------- 1 | value: 42 2 | done 3 | -------------------------------------------------------------------------------- /compliance/tests/for_post_multi_assign/expected.log: -------------------------------------------------------------------------------- 1 | 0 5 2 | 1 4 3 | 2 3 4 | done -------------------------------------------------------------------------------- /compliance/tests/goroutines_selector/expected.log: -------------------------------------------------------------------------------- 1 | Foo.Bar called 2 | main done 3 | -------------------------------------------------------------------------------- /compliance/tests/inline_function_type_cast/expected.log: -------------------------------------------------------------------------------- 1 | Hello, Inline World 2 | 12 -------------------------------------------------------------------------------- /compliance/tests/interface_type_reference/expected.log: -------------------------------------------------------------------------------- 1 | Stat call successful 2 | -------------------------------------------------------------------------------- /compliance/tests/named_slice_wrapper/expected.log: -------------------------------------------------------------------------------- 1 | Length: 2 2 | Slice length: 2 -------------------------------------------------------------------------------- /compliance/tests/package_import_context/packages: -------------------------------------------------------------------------------- 1 | # compile this test case 2 | . 3 | -------------------------------------------------------------------------------- /compliance/tests/package_import_go_scanner/expected.log: -------------------------------------------------------------------------------- 1 | ErrorList length: 1 2 | -------------------------------------------------------------------------------- /compliance/tests/package_import_runtime/packages: -------------------------------------------------------------------------------- 1 | # compile this test case 2 | . -------------------------------------------------------------------------------- /compliance/tests/pointers/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./pointers.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/simple_interface/expected.log: -------------------------------------------------------------------------------- 1 | pointer assertion result: true 2 | -------------------------------------------------------------------------------- /compliance/tests/string_index_array_access/expected.log: -------------------------------------------------------------------------------- 1 | Success: no duplicates 2 | -------------------------------------------------------------------------------- /compliance/tests/undefined_type_error/expected.log: -------------------------------------------------------------------------------- 1 | Formatter test completed 2 | -------------------------------------------------------------------------------- /compliance/tests/var_init_method_call/expected.log: -------------------------------------------------------------------------------- 1 | Base: 10 2 | Derived: 15 3 | -------------------------------------------------------------------------------- /gs/os/exec_nohandle.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | 3 | -------------------------------------------------------------------------------- /gs/os/wait_unimp.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | 3 | -------------------------------------------------------------------------------- /.prettierrc.yaml: -------------------------------------------------------------------------------- 1 | semi: false 2 | singleQuote: true 3 | experimentalTernaries: true 4 | -------------------------------------------------------------------------------- /compliance/tests/generic_string_constraint/expected.log: -------------------------------------------------------------------------------- 1 | hello 2 | world 3 | foo 4 | bar -------------------------------------------------------------------------------- /compliance/tests/go_type_assertion/expected.log: -------------------------------------------------------------------------------- 1 | main finished 2 | goroutine executed 3 | -------------------------------------------------------------------------------- /compliance/tests/goroutines/index.ts: -------------------------------------------------------------------------------- 1 | export { Message } from "./goroutines.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/if_type_assert/expected.log: -------------------------------------------------------------------------------- 1 | Expected: string 2 | got string: string 3 | -------------------------------------------------------------------------------- /compliance/tests/interface_method_comments/expected.log: -------------------------------------------------------------------------------- 1 | Test started 2 | Test finished -------------------------------------------------------------------------------- /compliance/tests/receiver_method/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./main.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/receiver_variable/expected.log: -------------------------------------------------------------------------------- 1 | Complex method completed, size: 16 2 | -------------------------------------------------------------------------------- /compliance/tests/slices_sortfunc/expected.log: -------------------------------------------------------------------------------- 1 | Alice 25 2 | Charlie 30 3 | Bob 35 4 | -------------------------------------------------------------------------------- /compliance/tests/struct_new/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./struct_new.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/varref_pointers/expected.log: -------------------------------------------------------------------------------- 1 | ***p3 before == 10 2 | ***p3 after == 12 -------------------------------------------------------------------------------- /compliance/tests/call_returned_function_async/expected.log: -------------------------------------------------------------------------------- 1 | Result 1: 8 2 | Result 2: 17 3 | -------------------------------------------------------------------------------- /compliance/tests/import_interface/expected.log: -------------------------------------------------------------------------------- 1 | Testing os.FileInfo interface preservation 2 | -------------------------------------------------------------------------------- /compliance/tests/interface_to_interface_type_assertion/expected.log: -------------------------------------------------------------------------------- 1 | Type assertion successful -------------------------------------------------------------------------------- /compliance/tests/make_selector_type/expected.log: -------------------------------------------------------------------------------- 1 | Created map: 1 2 | Content: hello world 3 | -------------------------------------------------------------------------------- /compliance/tests/method_binding/index.ts: -------------------------------------------------------------------------------- 1 | export { Counter } from "./method_binding.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/package_import/subpkg/index.ts: -------------------------------------------------------------------------------- 1 | export { Greet } from "./subpkg.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/recursive_type_definition/expected.log: -------------------------------------------------------------------------------- 1 | recursive type definition test 2 | -------------------------------------------------------------------------------- /compliance/tests/return_async_call/expected.log: -------------------------------------------------------------------------------- 1 | Result1: result 2 | Result2: async result 3 | -------------------------------------------------------------------------------- /compliance/tests/selector_expr_ok_variable/expected.log: -------------------------------------------------------------------------------- 1 | Type assertion successful: true 2 | -------------------------------------------------------------------------------- /compliance/tests/simple_pointer_assign/expected.log: -------------------------------------------------------------------------------- 1 | p1==p2: true 2 | *p1: 10 3 | *p2: 10 4 | -------------------------------------------------------------------------------- /compliance/tests/struct_literal_interface/expected.log: -------------------------------------------------------------------------------- 1 | Cases len: 1 2 | First case dir: 3 3 | -------------------------------------------------------------------------------- /compliance/tests/type_assertion_duplicate_vars/expected.log: -------------------------------------------------------------------------------- 1 | hasA: true 2 | hasB: false 3 | -------------------------------------------------------------------------------- /compliance/tests/type_missing_imports/expected.log: -------------------------------------------------------------------------------- 1 | Created storage with file: test.txt 2 | -------------------------------------------------------------------------------- /compliance/tests/type_separate_files/expected.log: -------------------------------------------------------------------------------- 1 | Created storage with file: test.txt 2 | -------------------------------------------------------------------------------- /compliance/tests/varref_struct/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./varref_struct.gs.js" 2 | -------------------------------------------------------------------------------- /example/simple/.rooignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | output 3 | go.mod 4 | go.sum 5 | yarn.lock 6 | -------------------------------------------------------------------------------- /gs/maps/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "iter", 4 | "unsafe" 5 | ] 6 | } -------------------------------------------------------------------------------- /compliance/tests/comments_struct/index.ts: -------------------------------------------------------------------------------- 1 | export { TestStruct } from "./comments_struct.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/embedded_interface_assertion/expected.log: -------------------------------------------------------------------------------- 1 | Embedded interface assertion successful -------------------------------------------------------------------------------- /compliance/tests/make_generic_type/expected.log: -------------------------------------------------------------------------------- 1 | Value exists: true 2 | String exists: true 3 | -------------------------------------------------------------------------------- /compliance/tests/method_call_slice_type/expected.log: -------------------------------------------------------------------------------- 1 | length: 2 2 | first: 10 3 | second: 20 4 | -------------------------------------------------------------------------------- /compliance/tests/path_error_constructor/expected.log: -------------------------------------------------------------------------------- 1 | readlink 2 | /some/path 3 | not a symlink 4 | -------------------------------------------------------------------------------- /compliance/tests/select_send_on_full_buffered_channel_with_default/expected.log: -------------------------------------------------------------------------------- 1 | Default case hit -------------------------------------------------------------------------------- /compliance/tests/simple_interface/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./simple_interface.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/slices_sortfunc/index.ts: -------------------------------------------------------------------------------- 1 | export { Person } from "./slices_sortfunc.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/slices_sortfunc_nil/expected.log: -------------------------------------------------------------------------------- 1 | fields before: null 2 | fields after: null 3 | -------------------------------------------------------------------------------- /compliance/tests/type_method_primitive/expected.log: -------------------------------------------------------------------------------- 1 | Direct call: 10 2 | Method ref call: 20 3 | -------------------------------------------------------------------------------- /example/simple/main.ts: -------------------------------------------------------------------------------- 1 | import { main } from '@goscript/example/main.gs.js' 2 | 3 | main() 4 | -------------------------------------------------------------------------------- /gs/path/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "errors", 4 | "unicode/utf8" 5 | ] 6 | } -------------------------------------------------------------------------------- /compliance/tests/copy_independence/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./copy_independence.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/generic_string_constraint/index.ts: -------------------------------------------------------------------------------- 1 | export type { StrOrBytes } from "./main.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/index_expr_type_assertion/expected.log: -------------------------------------------------------------------------------- 1 | slice[1] as int: 42 2 | m[key2] as int: 123 -------------------------------------------------------------------------------- /compliance/tests/make_generic_type/index.ts: -------------------------------------------------------------------------------- 1 | export type { Ints } from "./make_generic_type.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/multiple_return_values/expected.log: -------------------------------------------------------------------------------- 1 | 42 2 | hello 3 | true 4 | 42 5 | true 6 | hello -------------------------------------------------------------------------------- /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/expected.log: -------------------------------------------------------------------------------- 1 | 10 2 | 10 3 | 40 4 | 40 5 | 100 6 | 70 7 | 110 -------------------------------------------------------------------------------- /compliance/tests/redeclaration_assign/expected.log: -------------------------------------------------------------------------------- 1 | initial i: 0 2 | after assign i: 7 3 | err is true -------------------------------------------------------------------------------- /compliance/tests/variable_shadowing_scope/expected.log: -------------------------------------------------------------------------------- 1 | Got value: 42 2 | Completed successfully 3 | -------------------------------------------------------------------------------- /compliance/tests/varref_composite_lit/expected.log: -------------------------------------------------------------------------------- 1 | childInode.Value: 42 2 | childInode.getValue(): 42 -------------------------------------------------------------------------------- /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/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/constants/index.ts: -------------------------------------------------------------------------------- 1 | export { Greeting, Nothing, Pi, Truth } from "./constants.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/defer_async_method/index.ts: -------------------------------------------------------------------------------- 1 | export { AsyncResource } from "./defer_async_method.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/method_call_on_value_receiver/expected.log: -------------------------------------------------------------------------------- 1 | Method call on value: Expected: bar, Actual: bar -------------------------------------------------------------------------------- /compliance/tests/package_import_strings/expected.log: -------------------------------------------------------------------------------- 1 | Result: Hello World 2 | Direct: Direct make test 3 | -------------------------------------------------------------------------------- /compliance/tests/promise_return_type/index.ts: -------------------------------------------------------------------------------- 1 | export { AsyncData } from "./promise_return_type.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/simple/simple.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | println("Hello world!") 5 | } 6 | -------------------------------------------------------------------------------- /compliance/tests/struct_field_access/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./struct_field_access.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_private_field/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./struct_private_field.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/variadic_function_call/index.ts: -------------------------------------------------------------------------------- 1 | export { TestFS } from "./variadic_function_call.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/varref_composite_lit/index.ts: -------------------------------------------------------------------------------- 1 | export { MockInode } from "./varref_composite_lit.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/varref_deref_struct/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./varref_deref_struct.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/varref_pointers_number/expected.log: -------------------------------------------------------------------------------- 1 | p1==p2: true 2 | *p1==*p2: true 3 | pp1 deref: 10 4 | -------------------------------------------------------------------------------- /gs/time/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [], 3 | "asyncMethods": { 4 | "Sleep": true 5 | } 6 | } -------------------------------------------------------------------------------- /compliance/tests/embedded_interface_null_assertion/expected.log: -------------------------------------------------------------------------------- 1 | true 2 | true 3 | true 4 | 10 5 | 15 6 | true 7 | -------------------------------------------------------------------------------- /compliance/tests/method_async_call/index.ts: -------------------------------------------------------------------------------- 1 | export { FileTracker, Scanner } from "./method_async_call.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/method_async_dependency/index.ts: -------------------------------------------------------------------------------- 1 | export { Decoder } from "./method_async_dependency.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/method_receiver_shadowing/index.ts: -------------------------------------------------------------------------------- 1 | export { Thing } from "./method_receiver_shadowing.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/os_filemode_struct/expected.log: -------------------------------------------------------------------------------- 1 | File mode: 420 2 | File name: test.txt 3 | Mode type: 493 4 | -------------------------------------------------------------------------------- /compliance/tests/pointer_initialization/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./pointer_initialization.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/reflect_struct_field/expected.log: -------------------------------------------------------------------------------- 1 | StructField Name: TestField 2 | StructField Type: string 3 | -------------------------------------------------------------------------------- /compliance/tests/rune_const_import/subpkg/index.ts: -------------------------------------------------------------------------------- 1 | export { Newline, Separator, Space } from "./subpkg.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/rune_const_reference/subpkg/index.ts: -------------------------------------------------------------------------------- 1 | export { Newline, Separator } from "./subpkg.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/select_receive_on_closed_channel_no_default/expected.log: -------------------------------------------------------------------------------- 1 | Received zero value with ok==false: 0 -------------------------------------------------------------------------------- /compliance/tests/simple_deref_assignment/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./simple_deref_assignment.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/struct_pointer_marking/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./struct_pointer_marking.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/struct_value_init_clone/index.ts: -------------------------------------------------------------------------------- 1 | export { Point } from "./struct_value_init_clone.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/deps/github.com/aperturerobotics/util/broadcast/index.ts: -------------------------------------------------------------------------------- 1 | export { Broadcast } from "./broadcast.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/atomic_struct_field_init/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./atomic_struct_field_init.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/bitwise_and_not_assignment/expected.log: -------------------------------------------------------------------------------- 1 | Before: 9218868437227405000 2 | After: 0 3 | Result: 0 4 | -------------------------------------------------------------------------------- /compliance/tests/destructuring_assignment/expected.log: -------------------------------------------------------------------------------- 1 | x=10, y=20 2 | name=test, line=100, col=200 3 | a=10, b=20 4 | -------------------------------------------------------------------------------- /compliance/tests/generic_index_assignment/expected.log: -------------------------------------------------------------------------------- 1 | slice[0]: 1 2 | slice[1]: 42 3 | slice[2]: 3 4 | test finished -------------------------------------------------------------------------------- /compliance/tests/method_receiver_async_paren/index.ts: -------------------------------------------------------------------------------- 1 | export { Thing } from "./method_receiver_async_paren.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/method_receiver_await_paren/index.ts: -------------------------------------------------------------------------------- 1 | export { Thing } from "./method_receiver_await_paren.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/method_receiver_call_return/index.ts: -------------------------------------------------------------------------------- 1 | export { Thing } from "./method_receiver_call_return.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/method_receiver_paren_line/index.ts: -------------------------------------------------------------------------------- 1 | export { Thing } from "./method_receiver_paren_line.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/pointer_assignment_no_copy/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./pointer_assignment_no_copy.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/pointer_deref_multiassign/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./pointer_deref_multiassign.gs.js" 2 | -------------------------------------------------------------------------------- /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/protobuf_lite_ts/index.ts: -------------------------------------------------------------------------------- 1 | export { protobufPackage, ExampleMsg } from "./protobuf_lite_ts.pb.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/rune_const_reference/expected.log: -------------------------------------------------------------------------------- 1 | separator used in function: 48 2 | newline used in function: 11 3 | -------------------------------------------------------------------------------- /compliance/tests/selector_expr_ok_variable/index.ts: -------------------------------------------------------------------------------- 1 | export { Result } from "./selector_expr_ok_variable.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/struct_embedding_bytes_buffer/expected.log: -------------------------------------------------------------------------------- 1 | Content: Hello World 2 | Length: 11 3 | test finished 4 | -------------------------------------------------------------------------------- /compliance/tests/struct_private_field_ptr/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./struct_private_field_ptr.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/composite_literal_assignment/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./composite_literal_assignment.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/inline_function_type_cast/index.ts: -------------------------------------------------------------------------------- 1 | export type { Greeter } from "./inline_function_type_cast.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/interface_async_method_call/expected.log: -------------------------------------------------------------------------------- 1 | ChannelProcessor result: 52 2 | SimpleProcessor result: 115 3 | -------------------------------------------------------------------------------- /compliance/tests/interface_pointer_assignment/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./interface_pointer_assignment.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/method_receiver_with_call_expr/index.ts: -------------------------------------------------------------------------------- 1 | export { State } from "./method_receiver_with_call_expr.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/nil_pkg_pointer_dereference/index.ts: -------------------------------------------------------------------------------- 1 | export { TestStruct } from "./nil_pkg_pointer_dereference.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/octal_literals/expected.log: -------------------------------------------------------------------------------- 1 | perm1: 511 2 | perm2: 438 3 | perm3: 420 4 | perm4: 493 5 | test finished 6 | -------------------------------------------------------------------------------- /compliance/tests/package_import_encoding_json/index.ts: -------------------------------------------------------------------------------- 1 | export { Person } from "./package_import_encoding_json.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/pointer_struct_assign_clone/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./pointer_struct_assign_clone.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/reflect_implements/expected.log: -------------------------------------------------------------------------------- 1 | MyType implements Stringer: true 2 | *MyType implements Stringer: true 3 | -------------------------------------------------------------------------------- /compliance/tests/selector_expr_lhs_multi_assign/index.ts: -------------------------------------------------------------------------------- 1 | export { Point } from "./selector_expr_lhs_multi_assign.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/struct_field_access/expected.log: -------------------------------------------------------------------------------- 1 | MyInt: Expected: 42, Actual: 42 2 | MyString: Expected: foo, Actual: foo -------------------------------------------------------------------------------- /compliance/tests/filepath_walkfunc_call/expected.log: -------------------------------------------------------------------------------- 1 | Walking: /test/test.txt size: 50 2 | Walking: /test/test.txt size: 50 3 | -------------------------------------------------------------------------------- /compliance/tests/interface_method_comments/index.ts: -------------------------------------------------------------------------------- 1 | export type { MyInterface } from "./interface_method_comments.gs.js" 2 | -------------------------------------------------------------------------------- /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_value_receiver/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./method_call_on_value_receiver.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/package_import_context/expected.log: -------------------------------------------------------------------------------- 1 | myCh is not be readable yet 2 | read successfully 3 | test finished 4 | -------------------------------------------------------------------------------- /compliance/tests/pointer_initialization/expected.log: -------------------------------------------------------------------------------- 1 | Initial MyString (via pointer): Expected: hello world, Actual: hello world -------------------------------------------------------------------------------- /compliance/tests/struct_embedding_bytes_buffer/index.ts: -------------------------------------------------------------------------------- 1 | export { MyWriter } from "./struct_embedding_bytes_buffer.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/struct_type_assertion/expected.log: -------------------------------------------------------------------------------- 1 | Name: Alice Number: 8005553424 2 | Second type assertion failed as expected -------------------------------------------------------------------------------- /compliance/tests/value_type_copy_behavior/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct, NestedStruct } from "./value_type_copy_behavior.gs.js" 2 | -------------------------------------------------------------------------------- /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_infinite/expected.log: -------------------------------------------------------------------------------- 1 | Looping forever... 2 | Looping forever... 3 | Looping forever... 4 | Loop finished -------------------------------------------------------------------------------- /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_via_pointer/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./method_call_on_value_via_pointer.gs.js" 2 | -------------------------------------------------------------------------------- /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/pointer_circular_ref/index.ts: -------------------------------------------------------------------------------- 1 | export { Employee, Node, Person, TreeNode } from "./pointer_circular_ref.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/slices_grow/expected.log: -------------------------------------------------------------------------------- 1 | Before Grow: len= 3 cap= 3 2 | After Grow: len= 3 cap= 8 3 | slices.Grow test finished 4 | -------------------------------------------------------------------------------- /compliance/tests/struct_embedding/index.ts: -------------------------------------------------------------------------------- 1 | export { Address, Contact, Employee, Manager, Person } from "./struct_embedding.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/type_separate_files/memory.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type file struct { 4 | name string 5 | data []byte 6 | } 7 | -------------------------------------------------------------------------------- /example/simple/run.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -eo pipefail 3 | 4 | bash build.bash 5 | 6 | tsx --tsconfig ./tsconfig.json ./main.ts -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .#* 2 | node_modules 3 | *.swp 4 | .DS_Store 5 | vendor 6 | dist 7 | buildtarget 8 | .idea 9 | output 10 | out 11 | -------------------------------------------------------------------------------- /compliance/tests/async_call_in_return/expected.log: -------------------------------------------------------------------------------- 1 | getFromCache found: 42 2 | getFromCacheInline found: 42 3 | Not found as expected 4 | -------------------------------------------------------------------------------- /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/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/index_expr_destructuring/expected.log: -------------------------------------------------------------------------------- 1 | intArray[0]: 42 2 | stringSlice[1]: hello 3 | matrix[0][1]: 42 4 | intArray[1]: 24 -------------------------------------------------------------------------------- /compliance/tests/interface_type_assertion/expected.log: -------------------------------------------------------------------------------- 1 | Type assertion successful 2 | Type assertion failed 3 | type assertion success 10 -------------------------------------------------------------------------------- /compliance/tests/missing_package_methods_issue/expected.log: -------------------------------------------------------------------------------- 1 | Original: [1 2 3 4 5] 2 | After delete: [1 4 5] 3 | Index: 2, Found: true 4 | -------------------------------------------------------------------------------- /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/reserved_words/expected.log: -------------------------------------------------------------------------------- 1 | new: 42 2 | class: test 3 | typeof: true 4 | named return result: 100 5 | test finished 6 | -------------------------------------------------------------------------------- /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/type_conversion_interface_ptr_nil/index.ts: -------------------------------------------------------------------------------- 1 | export type { Stringer } from "./type_conversion_interface_ptr_nil.gs.js" 2 | -------------------------------------------------------------------------------- /gs/os/sticky_bsd.gs.ts: -------------------------------------------------------------------------------- 1 | import * as $ from "@goscript/builtin/index.js"; 2 | 3 | let supportsCreateWithStickyBit: boolean = false 4 | 5 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "dist", "**/*.test.ts", "compliance"] 4 | } -------------------------------------------------------------------------------- /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/method_call_on_pointer_receiver/expected.log: -------------------------------------------------------------------------------- 1 | Method call on pointer (structPointer): Expected: hello world, Actual: hello world -------------------------------------------------------------------------------- /example/simple/main_tools.go: -------------------------------------------------------------------------------- 1 | //go:build tools 2 | 3 | package main 4 | 5 | import _ "github.com/aperturerobotics/goscript/cmd/goscript" 6 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /compliance/deps/unicode/utf16/index.ts: -------------------------------------------------------------------------------- 1 | export { AppendRune, Decode, DecodeRune, Encode, EncodeRune, IsSurrogate, RuneLen } from "./utf16.gs.js" 2 | -------------------------------------------------------------------------------- /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/channel_receive_both_blank/expected.log: -------------------------------------------------------------------------------- 1 | received and discarded value and ok 2 | received from closed channel, both discarded 3 | -------------------------------------------------------------------------------- /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/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/type_conversion_interface_ptr_nil/expected.log: -------------------------------------------------------------------------------- 1 | Type: *main.Stringer 2 | Kind: 22 3 | Elem Type: main.Stringer 4 | Elem Kind: 20 5 | -------------------------------------------------------------------------------- /compliance/tests/variadic_interface_method/expected.log: -------------------------------------------------------------------------------- 1 | Result1: path/to/file 2 | Result2: single 3 | Result3: 4 | Result4: another/path/here 5 | -------------------------------------------------------------------------------- /gs/path/index.ts: -------------------------------------------------------------------------------- 1 | export { ErrBadPattern, Match } from './match.js' 2 | export { Base, Clean, Dir, Ext, IsAbs, Join, Split } from './path.js' 3 | -------------------------------------------------------------------------------- /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_js.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func testJSWasm() { 4 | println("JS/WASM specific code compiled - CORRECT") 5 | } 6 | -------------------------------------------------------------------------------- /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/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/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/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/slice_nil/expected.log: -------------------------------------------------------------------------------- 1 | s == nil: true 2 | s[0:0] == nil: true 3 | s[:0] == nil: true 4 | s[:] == nil: true 5 | slice_nil test passed 6 | -------------------------------------------------------------------------------- /gs/strings/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "errors", 4 | "io", 5 | "iter", 6 | "unicode", 7 | "unicode/utf8" 8 | ] 9 | } -------------------------------------------------------------------------------- /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/goroutines_selector/index.ts: -------------------------------------------------------------------------------- 1 | export { NewFoo } from "./goroutines_selector.gs.js" 2 | export { Foo } from "./goroutines_selector.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/import_type_methods/errlist/index.ts: -------------------------------------------------------------------------------- 1 | export { ErrorList_Add } from "./errlist.gs.js" 2 | export type { ErrorList } from "./errlist.gs.js" 3 | -------------------------------------------------------------------------------- /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/package_import_csync/expected.log: -------------------------------------------------------------------------------- 1 | All workers completed successfully 2 | Final counter value: 5 3 | success: csync.Mutex test completed 4 | -------------------------------------------------------------------------------- /compliance/tests/return_async_call/index.ts: -------------------------------------------------------------------------------- 1 | export { AnotherAsyncFunction, AsyncFunction, SyncWrapper, WrapperWithError } from "./return_async_call.gs.js" 2 | -------------------------------------------------------------------------------- /compliance/tests/selective_exports/index.ts: -------------------------------------------------------------------------------- 1 | export { ExportedFunc } from "./selective_exports.gs.js" 2 | export { ExportedFromUtils } from "./utils.gs.js" 3 | -------------------------------------------------------------------------------- /gs/internal/oserror/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | ErrClosed, 3 | ErrExist, 4 | ErrInvalid, 5 | ErrNotExist, 6 | ErrPermission, 7 | } from './errors.js' 8 | -------------------------------------------------------------------------------- /gs/io/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "errors", 4 | "internal/oserror", 5 | "path", 6 | "time", 7 | "unicode/utf8" 8 | ] 9 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/interface_multi_param_return/expected.log: -------------------------------------------------------------------------------- 1 | Processing successful 2 | Main: Success reported 3 | Processing successful 4 | Main: Success reported -------------------------------------------------------------------------------- /compliance/tests/reflect_implements/index.ts: -------------------------------------------------------------------------------- 1 | export { MyType } from "./reflect_implements.gs.js" 2 | export type { Stringer } from "./reflect_implements.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/reflect_typefor/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./reflect_typefor.gs.js" 2 | export type { MyInterface } from "./reflect_typefor.gs.js" 3 | -------------------------------------------------------------------------------- /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/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 -------------------------------------------------------------------------------- /example/simple/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@example/simple", 3 | "private": true, 4 | "devDependencies": { 5 | "typescript": "^5.4.2" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /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/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/interface_embedding/index.ts: -------------------------------------------------------------------------------- 1 | export { MockFile } from "./interface_embedding.gs.js" 2 | export type { File } from "./interface_embedding.gs.js" 3 | -------------------------------------------------------------------------------- /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/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_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/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/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/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/util_promise/index.ts: -------------------------------------------------------------------------------- 1 | export { NewPromise, NewPromiseWithResult } from "./util_promise.gs.js" 2 | export { PromiseType } from "./util_promise.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/var_init_method_call/index.ts: -------------------------------------------------------------------------------- 1 | export { Base, Derived, NewT } from "./var_init_method_call.gs.js" 2 | export { T } from "./var_init_method_call.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/deps/encoding/index.ts: -------------------------------------------------------------------------------- 1 | export type { BinaryAppender, BinaryMarshaler, BinaryUnmarshaler, TextAppender, TextMarshaler, TextUnmarshaler } from "./encoding.gs.js" 2 | -------------------------------------------------------------------------------- /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/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/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/pointer_circular_ref/expected.log: -------------------------------------------------------------------------------- 1 | Node 1 value: 1 2 | Node 2 value: 2 3 | Person name: John 4 | Employee ID: 123 5 | Pointer circular references work fine! 6 | -------------------------------------------------------------------------------- /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/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/type_method_primitive/index.ts: -------------------------------------------------------------------------------- 1 | export { MyInt_Double } from "./type_method_primitive.gs.js" 2 | export type { MyInt } from "./type_method_primitive.gs.js" 3 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /gs/bytes/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | "errors", 4 | "io", 5 | "iter", 6 | "unicode", 7 | "unicode/utf8", 8 | "unsafe" 9 | ] 10 | } -------------------------------------------------------------------------------- /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/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_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/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/method_call_slice_type/index.ts: -------------------------------------------------------------------------------- 1 | export { MySlice_Add } from "./method_call_slice_type.gs.js" 2 | export type { MySlice } from "./method_call_slice_type.gs.js" 3 | -------------------------------------------------------------------------------- /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/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/interface_subset_cast/expected.log: -------------------------------------------------------------------------------- 1 | i1.MyString1(): hello 2 | i1.MyString2(): world 3 | i2.MyString1(): hello 4 | Type assertion successful 5 | i3.MyString1(): hello 6 | -------------------------------------------------------------------------------- /compliance/tests/interface_subset_type_switch/expected.log: -------------------------------------------------------------------------------- 1 | MyInterface1: hello world 2 | MyInterface1: hello world 3 | MyInterface1: hello world 4 | Matched MyInterface2 from i1: hello 5 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/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/interface_subset_cast/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./interface_subset_cast.gs.js" 2 | export type { MyInterface1, MyInterface2 } from "./interface_subset_cast.gs.js" 3 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "github.copilot-chat", 4 | "golang.go", 5 | "esbenp.prettier-vscode", 6 | "vitest.explorer" 7 | ] 8 | } -------------------------------------------------------------------------------- /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_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/import_type_methods/errlist/errlist.go: -------------------------------------------------------------------------------- 1 | package errlist 2 | 3 | type ErrorList []string 4 | 5 | func (p ErrorList) Add(msg string) ErrorList { 6 | return append(p, msg) 7 | } 8 | -------------------------------------------------------------------------------- /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/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_slice_wrapper/index.ts: -------------------------------------------------------------------------------- 1 | export { ByName_Len, ByName_Less, ByName_Swap } from "./named_slice_wrapper.gs.js" 2 | export type { ByName } from "./named_slice_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/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/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/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/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/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/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/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/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/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/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/wrapper_slice_append/errlist/index.ts: -------------------------------------------------------------------------------- 1 | export { ErrorList_Add } from "./errlist.gs.js" 2 | export { AStruct } from "./errlist.gs.js" 3 | export type { ErrorList } from "./errlist.gs.js" 4 | -------------------------------------------------------------------------------- /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/interface_subset_type_switch/index.ts: -------------------------------------------------------------------------------- 1 | export { MyStruct } from "./interface_subset_type_switch.gs.js" 2 | export type { MyInterface1, MyInterface2 } from "./interface_subset_type_switch.gs.js" 3 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/string_conversion/expected.log: -------------------------------------------------------------------------------- 1 | hello world 2 | A 3 | a 4 | € 5 | GoScript 6 | 7 | 你好世界 8 | 你好世界 9 | true 10 | mutable string 11 | Hello 12 | B 13 | interface test 14 | variable test 15 | A -------------------------------------------------------------------------------- /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/interface_async_method_call/index.ts: -------------------------------------------------------------------------------- 1 | export { ChannelProcessor, SimpleProcessor } from "./interface_async_method_call.gs.js" 2 | export type { AsyncProcessor } from "./interface_async_method_call.gs.js" 3 | -------------------------------------------------------------------------------- /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/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/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_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/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/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 === -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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/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/named_type_wrapper/index.ts: -------------------------------------------------------------------------------- 1 | export { MyFileMode_String } from "./named_type_wrapper.gs.js" 2 | export { FileStatus } from "./named_type_wrapper.gs.js" 3 | export type { MyFileMode } from "./named_type_wrapper.gs.js" 4 | -------------------------------------------------------------------------------- /compliance/tests/package_import_encoding_json/actual.log: -------------------------------------------------------------------------------- 1 | JSON result: Marshal: 2 | JSON result: Unmarshal map error: json: Unmarshal(nil) 3 | JSON result: Unmarshal struct error: json: Unmarshal(nil) 4 | encoding/json test finished 5 | -------------------------------------------------------------------------------- /compliance/tests/var_init_order/var_init_order.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var ( 4 | a = 10 5 | b = a + 5 6 | c = b * 2 7 | ) 8 | 9 | func main() { 10 | println("a:", a) 11 | println("b:", b) 12 | println("c:", c) 13 | } 14 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/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/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/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_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/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/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 | -------------------------------------------------------------------------------- /.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/ -------------------------------------------------------------------------------- /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/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_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/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_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/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/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/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 -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/reflect_typefor/expected.log: -------------------------------------------------------------------------------- 1 | TypeFor interface: interface { SomeMethod() } 2 | TypeFor struct: main.MyStruct 3 | TypeFor struct kind: true 4 | TypeFor int: int 5 | TypeFor int kind: true 6 | Pointer constant: true 7 | reflect_typefor test finished 8 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/type_declaration_receiver/index.ts: -------------------------------------------------------------------------------- 1 | export { CustomString_Length, CustomString_Upper, FileMode_Add, FileMode_IsZero, FileMode_String } from "./type_declaration_receiver.gs.js" 2 | export type { CustomString, FileMode } from "./type_declaration_receiver.gs.js" 3 | -------------------------------------------------------------------------------- /compliance/tests/wrapper_type_args/index.ts: -------------------------------------------------------------------------------- 1 | export { MyMode_IsExecutable, MyMode_String, 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 | -------------------------------------------------------------------------------- /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/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/package_import_encoding_json/expected.log: -------------------------------------------------------------------------------- 1 | JSON result: Marshal: {"name":"Alice","age":30,"active":true} 2 | JSON result: Unmarshal map: name=Carol, age=22, active=true 3 | JSON result: Unmarshal struct: Name=Bob, Age=25, Active=false 4 | encoding/json test finished 5 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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/switch_case_scope/switch_case_scope.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | x := 1 5 | 6 | switch x { 7 | case 1: 8 | y, z := 10, 20 9 | println(y + z) 10 | case 2: 11 | y, z := 30, 40 12 | println(y + z) 13 | } 14 | 15 | println("done") 16 | } 17 | -------------------------------------------------------------------------------- /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/star_compound_assign/star_compound_assign.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var x int = 2 5 | var p *int = &x 6 | 7 | *p += 3 8 | println(x) // Expected: 5 9 | 10 | *p &^= 1 11 | // 5 (0101) &^ 1 (0001) = 4 (0100) 12 | println(x) // Expected: 4 13 | } 14 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/function_returns_function/function_returns_function.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func getAdder(x int) func(int) int { 4 | return func(y int) int { 5 | return x + y 6 | } 7 | } 8 | 9 | func main() { 10 | adder := getAdder(5) 11 | result := adder(3) 12 | println("Result:", result) 13 | } 14 | -------------------------------------------------------------------------------- /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/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/deps/encoding/base64/index.ts: -------------------------------------------------------------------------------- 1 | export { CorruptInputError_Error, NewDecoder, NewEncoder, NewEncoding, NoPadding, RawStdEncoding, RawURLEncoding, StdEncoding, StdPadding, URLEncoding } from "./base64.gs.js" 2 | export { Encoding } from "./base64.gs.js" 3 | export type { CorruptInputError } from "./base64.gs.js" 4 | -------------------------------------------------------------------------------- /compliance/tests/wrapper_slice_append/errlist/errlist.go: -------------------------------------------------------------------------------- 1 | package errlist 2 | 3 | type ErrorList []string 4 | 5 | func (p *ErrorList) Add(msg string) { 6 | *p = append(*p, msg) 7 | } 8 | 9 | type AStruct struct { 10 | Msg string 11 | } 12 | 13 | func (a *AStruct) Set(msg string) { 14 | a.Msg = msg 15 | } 16 | -------------------------------------------------------------------------------- /compliance/tests/slices_grow/slices_grow.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "slices" 4 | 5 | func main() { 6 | s := []int{1, 2, 3} 7 | println("Before Grow: len=", len(s), "cap=", cap(s)) 8 | s = slices.Grow(s, 5) 9 | println("After Grow: len=", len(s), "cap=", cap(s)) 10 | println("slices.Grow test finished") 11 | } 12 | -------------------------------------------------------------------------------- /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/package_import_go_parser/expected.log: -------------------------------------------------------------------------------- 1 | Parse result: BasicLit: 42 2 | Parse result: BinaryExpr with operator: + 3 | Parse result: CallExpr: len 4 | Parse result: CompositeLit (composite literal) 5 | Parse result: Function: add 6 | Parse result: Function: main 7 | Parse result: Package: main 8 | go/parser test finished 9 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /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/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/simple_interface/simple_interface.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type MyStruct struct { 4 | Value int 5 | } 6 | 7 | func main() { 8 | original := MyStruct{Value: 30} 9 | pAlias := &original 10 | 11 | var jAlias interface{} = pAlias 12 | 13 | _, ok := jAlias.(*MyStruct) 14 | println("pointer assertion result:", ok) 15 | } 16 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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/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 -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /compliance/tests/struct_literal_interface/struct_literal_interface.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "reflect" 4 | 5 | func main() { 6 | // Test creating reflect.SelectCase struct literals 7 | cases := []reflect.SelectCase{ 8 | {Dir: reflect.SelectDefault}, 9 | } 10 | println("Cases len:", len(cases)) 11 | println("First case dir:", cases[0].Dir) 12 | } 13 | -------------------------------------------------------------------------------- /compliance/tests/import_type_methods/import_type_methods.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/aperturerobotics/goscript/compliance/tests/import_type_methods/errlist" 5 | ) 6 | 7 | type parser struct { 8 | errors errlist.ErrorList 9 | } 10 | 11 | func main() { 12 | var p parser 13 | p.errors = p.errors.Add("error") 14 | println(p.errors[0]) 15 | } 16 | -------------------------------------------------------------------------------- /compliance/tests/util_promise/expected.log: -------------------------------------------------------------------------------- 1 | Test 1: Basic Promise with string 2 | Result: hello world 3 | Test 2: Pre-resolved Promise with int 4 | Result: 42 5 | Test 3: Promise with error 6 | Error: context deadline exceeded 7 | Test 4: Cannot set result twice 8 | First set success: true 9 | Second set success: false 10 | Final result: 100 11 | All tests completed 12 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/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/reflect_struct_field/reflect_struct_field.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "reflect" 4 | 5 | func main() { 6 | // Test creating a StructField value 7 | field := reflect.StructField{ 8 | Name: "TestField", 9 | Type: reflect.TypeOf(""), 10 | } 11 | println("StructField Name:", field.Name) 12 | println("StructField Type:", field.Type.String()) 13 | } 14 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /compliance/tests/select_mixed_returns/expected.log: -------------------------------------------------------------------------------- 1 | Test 1: Non-returning case (ch2) 2 | Received from ch2: 42 3 | Processing ch2 value... 4 | Continuing execution after select 5 | Performing additional work... 6 | Final result: completed_normally 7 | 8 | Test 2: Returning case (ch1) 9 | Received from ch1: test_message 10 | Final result: ch1_result 11 | 12 | All tests completed 13 | -------------------------------------------------------------------------------- /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/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/method_call_slice_type/method_call_slice_type.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type MySlice []int 4 | 5 | func (s *MySlice) Add(val int) { 6 | *s = append(*s, val) 7 | } 8 | 9 | func main() { 10 | var myList MySlice 11 | myList.Add(10) 12 | myList.Add(20) 13 | println("length:", len(myList)) 14 | println("first:", myList[0]) 15 | println("second:", myList[1]) 16 | } 17 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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.9.3" 7 | resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.9.3.tgz#5b4f59e15310ab17a216f5d6cf53ee476ede670f" 8 | integrity sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw== 9 | -------------------------------------------------------------------------------- /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/for_range_channel/for_range_channel.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | c := make(chan int, 1) 5 | c <- 0 6 | close(c) 7 | 8 | for x := range c { 9 | println(x) 10 | } 11 | 12 | // test with = instead of := within the for range 13 | c = make(chan int, 1) 14 | c <- 1 15 | close(c) 16 | 17 | var y int 18 | for y = range c { 19 | println(y) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /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/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/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/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/import_type_methods/errlist/errlist.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on errlist/errlist.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js" 5 | 6 | export type ErrorList = $.Slice; 7 | 8 | export function ErrorList_Add(p: ErrorList, msg: string): ErrorList { 9 | return $.append(p, msg) 10 | } 11 | 12 | 13 | -------------------------------------------------------------------------------- /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/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/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/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/simple_pointer_assign/simple_pointer_assign.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | // Simple case that should work 5 | x := 10 6 | p1 := &x // p1 is *int, not varref'd 7 | p2 := p1 // p2 is *int, not varref'd, should copy p1 8 | 9 | println("p1==p2:", p1 == p2) // Should be true 10 | println("*p1:", *p1) // Should be 10 11 | println("*p2:", *p2) // Should be 10 12 | } 13 | -------------------------------------------------------------------------------- /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/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/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/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 | -------------------------------------------------------------------------------- /gs/context/meta.json: -------------------------------------------------------------------------------- 1 | { 2 | "asyncMethods": { 3 | "Background": false, 4 | "TODO": false, 5 | "WithCancel": false, 6 | "WithCancelCause": false, 7 | "WithDeadline": false, 8 | "WithDeadlineCause": false, 9 | "WithTimeout": false, 10 | "WithTimeoutCause": false, 11 | "WithValue": false, 12 | "WithoutCancel": false, 13 | "Cause": false, 14 | "AfterFunc": false 15 | } 16 | } -------------------------------------------------------------------------------- /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/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/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/slice_nil/slice_nil.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var s []int 5 | println("s == nil:", s == nil) 6 | 7 | // Slicing nil with valid bounds should work 8 | s2 := s[0:0] 9 | println("s[0:0] == nil:", s2 == nil) 10 | 11 | s3 := s[:0] 12 | println("s[:0] == nil:", s3 == nil) 13 | 14 | s4 := s[:] 15 | println("s[:] == nil:", s4 == nil) 16 | 17 | println("slice_nil test passed") 18 | } 19 | -------------------------------------------------------------------------------- /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/package_import_fmt/expected.log: -------------------------------------------------------------------------------- 1 | Hello World 2 | Welcome to Go 1.21 3 | This is println 4 | Sprint result: Sprint result 5 | Sprintf result: Number: 42, String: test 6 | Sprintln result:Sprintln result 7 | Error: error code: 404 8 | Boolean: true 9 | Integer: 123 10 | Float: 3.14159 11 | String: hello 12 | Type: int 13 | Value: [1 2 3] 14 | Width: ' hi' 15 | Precision: '3.14' 16 | Both: ' 3.14' 17 | test finished 18 | -------------------------------------------------------------------------------- /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/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/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/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/string_copy_to_array/string_copy_to_array.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var arr [10]byte 5 | decodeMapInitialize := "\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff" 6 | copy(arr[:], decodeMapInitialize) 7 | 8 | // Check that arr is initialized with 255 values 9 | for i := 0; i < len(arr); i++ { 10 | if arr[i] != 255 { 11 | panic("copy failed") 12 | } 13 | } 14 | println("Copy succeeded") 15 | } 16 | -------------------------------------------------------------------------------- /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/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/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/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/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/method_receiver_paren_line/method_receiver_paren_line.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Thing struct { 4 | value int 5 | } 6 | 7 | func getFunc() func(*Thing, int) { 8 | return func(t *Thing, x int) { 9 | t.value += x 10 | } 11 | } 12 | 13 | func (t *Thing) callIt(x int) { 14 | getFunc()(t, x) 15 | } 16 | 17 | func main() { 18 | thing := &Thing{value: 10} 19 | thing.callIt(32) 20 | println("Result:", thing.value) 21 | } 22 | -------------------------------------------------------------------------------- /compliance/tests/method_receiver_shadowing/method_receiver_shadowing.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Thing struct { 4 | value int 5 | } 6 | 7 | func getValue() func(*Thing) int { 8 | return func(t *Thing) int { 9 | return t.value 10 | } 11 | } 12 | 13 | func (t *Thing) callFunc() int { 14 | return getValue()(t) 15 | } 16 | 17 | func main() { 18 | t := &Thing{value: 42} 19 | result := t.callFunc() 20 | println("Result:", result) 21 | } 22 | -------------------------------------------------------------------------------- /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/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/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/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/var_init_method_call/var_init_method_call.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | val int 5 | } 6 | 7 | func NewT(v int) *T { 8 | return &T{val: v} 9 | } 10 | 11 | func (t *T) WithDelta(delta int) *T { 12 | return &T{val: t.val + delta} 13 | } 14 | 15 | var ( 16 | Base = NewT(10) 17 | Derived = Base.WithDelta(5) 18 | ) 19 | 20 | func main() { 21 | println("Base:", Base.val) 22 | println("Derived:", Derived.val) 23 | } 24 | -------------------------------------------------------------------------------- /compliance/tests/var_init_order/var_init_order.gs.ts: -------------------------------------------------------------------------------- 1 | // Generated file based on var_init_order.go 2 | // Updated when compliance tests are re-run, DO NOT EDIT! 3 | 4 | import * as $ from "@goscript/builtin/index.js" 5 | 6 | let a: number = 10 7 | 8 | let b: number = a + 5 9 | 10 | let c: number = b * 2 11 | 12 | export async function main(): Promise { 13 | console.log("a:", a) 14 | console.log("b:", b) 15 | console.log("c:", c) 16 | } 17 | 18 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /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/syscall/index.ts: -------------------------------------------------------------------------------- 1 | // Re-export all types 2 | export * from './types.js' 3 | 4 | // Re-export all constants 5 | export * from './constants.js' 6 | 7 | // Re-export environment functions 8 | export * from './env.js' 9 | 10 | // Re-export file system structures and functions 11 | export * from './fs.js' 12 | 13 | // Re-export error constants 14 | export * from './errors.js' 15 | 16 | // Re-export RawConn implementation 17 | export * from './rawconn.js' 18 | -------------------------------------------------------------------------------- /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 | } 20 | -------------------------------------------------------------------------------- /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/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/deps/go/scanner/index.ts: -------------------------------------------------------------------------------- 1 | export { ErrorList_Add, ErrorList_Err, ErrorList_Error, ErrorList_Len, ErrorList_Less, ErrorList_RemoveMultiples, ErrorList_Reset, ErrorList_Sort, ErrorList_Swap, PrintError } from "./errors.gs.js" 2 | export { Error } from "./errors.gs.js" 3 | export type { ErrorList } from "./errors.gs.js" 4 | export { ScanComments } from "./scanner.gs.js" 5 | export { Scanner } from "./scanner.gs.js" 6 | export type { ErrorHandler, Mode } from "./scanner.gs.js" 7 | -------------------------------------------------------------------------------- /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/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/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/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/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/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/method_receiver_call_return/method_receiver_call_return.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Thing struct { 4 | value int 5 | } 6 | 7 | func getFunc() func(*Thing, int) int { 8 | return func(t *Thing, x int) int { 9 | return t.value + x 10 | } 11 | } 12 | 13 | func (t *Thing) callIt(x int) int { 14 | return getFunc()(t, x) 15 | } 16 | 17 | func main() { 18 | thing := &Thing{value: 10} 19 | result := thing.callIt(32) 20 | println("Result:", result) 21 | } 22 | -------------------------------------------------------------------------------- /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/slices_sortfunc_nil/slices_sortfunc_nil.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "slices" 4 | 5 | type field struct { 6 | name string 7 | } 8 | 9 | func main() { 10 | var fields []field 11 | println("fields before:", fields) 12 | 13 | slices.SortFunc(fields, func(a, b field) int { 14 | if a.name < b.name { 15 | return -1 16 | } 17 | if a.name > b.name { 18 | return 1 19 | } 20 | return 0 21 | }) 22 | 23 | println("fields after:", fields) 24 | } 25 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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_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/package_var_async_method/package_var_async_method.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "sync" 5 | ) 6 | 7 | var cache sync.Map 8 | 9 | // This function calls an async method on a package-level variable 10 | func getValueFromCache(key string) (interface{}, bool) { 11 | return cache.Load(key) 12 | } 13 | 14 | func main() { 15 | cache.Store("hello", "world") 16 | 17 | val, ok := getValueFromCache("hello") 18 | if ok { 19 | println("Found:", val.(string)) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /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/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/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/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/struct_embedding_bytes_buffer/struct_embedding_bytes_buffer.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "bytes" 4 | 5 | type MyWriter struct { 6 | bytes.Buffer // Embedded Buffer 7 | count int 8 | } 9 | 10 | func main() { 11 | var w MyWriter 12 | 13 | // Call promoted method WriteString from bytes.Buffer 14 | w.WriteString("Hello ") 15 | w.WriteString("World") 16 | 17 | println("Content:", w.String()) 18 | println("Length:", w.Len()) 19 | 20 | println("test finished") 21 | } 22 | -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /compliance/tests/string_index_array_access/string_index_array_access.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | encoder := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" 5 | 6 | var decodeMap [256]byte 7 | for i := range decodeMap { 8 | decodeMap[i] = 255 9 | } 10 | 11 | for i := 0; i < len(encoder); i++ { 12 | if decodeMap[encoder[i]] != 255 { 13 | panic("duplicate symbol") 14 | } 15 | decodeMap[encoder[i]] = byte(i) 16 | } 17 | 18 | println("Success: no duplicates") 19 | } 20 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/type_method_primitive/type_method_primitive.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Test that primitive type aliases with methods work correctly 4 | type MyInt int 5 | 6 | func (m MyInt) Double() int { 7 | return int(m) * 2 8 | } 9 | 10 | func main() { 11 | // Test direct method call on type conversion 12 | result := MyInt(5).Double() 13 | println("Direct call:", result) 14 | 15 | // Test storing method reference (this is the failing case) 16 | fn := MyInt(10).Double 17 | println("Method ref call:", fn()) 18 | } 19 | -------------------------------------------------------------------------------- /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/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/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 | -------------------------------------------------------------------------------- /gs/sort/index.ts: -------------------------------------------------------------------------------- 1 | export { 2 | Find, 3 | Search, 4 | SearchFloat64s, 5 | SearchInts, 6 | SearchStrings, 7 | } from './search.gs.js' 8 | export { Slice, SliceIsSorted, SliceStable } from './slice.gs.js' 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.js' 24 | export type { Interface } from './sort.gs.js' 25 | -------------------------------------------------------------------------------- /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/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/package_import_go_scanner/package_import_go_scanner.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "go/scanner" 6 | "go/token" 7 | ) 8 | 9 | func main() { 10 | // Use scanner package functionality that should generate imports 11 | var errorList scanner.ErrorList 12 | 13 | // This should require importing both scanner and token packages 14 | pos := token.Position{Filename: "test.go", Line: 1, Column: 1} 15 | errorList.Add(pos, "test error") 16 | 17 | fmt.Printf("ErrorList length: %d\n", len(errorList)) 18 | } 19 | -------------------------------------------------------------------------------- /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/wrapper_slice_append/wrapper_slice_append.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/aperturerobotics/goscript/compliance/tests/wrapper_slice_append/errlist" 5 | ) 6 | 7 | type parser struct { 8 | errors errlist.ErrorList 9 | astruct errlist.AStruct 10 | } 11 | 12 | func main() { 13 | var p parser 14 | // this Add method does not work: 15 | p.errors.Add("error") 16 | println(p.errors[0]) 17 | 18 | // but it does work for a struct type: 19 | p.astruct.Set("astruct") 20 | println(p.astruct.Msg) 21 | } 22 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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 | --------------------------------------------------------------------------------