├── .github └── workflows │ └── t1.yml ├── 3rdparty ├── cltc │ ├── AUTHORS │ ├── CMakeLists.txt │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── COPYING │ ├── README.md │ ├── src │ │ ├── CMakeLists.txt │ │ ├── array.c │ │ ├── collectc │ │ ├── collectionc.pc.in │ │ ├── common.c │ │ ├── deque.c │ │ ├── hashset.c │ │ ├── hashtable.c │ │ ├── include │ │ │ ├── array.h │ │ │ ├── common.h │ │ │ ├── deque.h │ │ │ ├── hashset.h │ │ │ ├── hashtable.h │ │ │ ├── list.h │ │ │ ├── pqueue.h │ │ │ ├── queue.h │ │ │ ├── ring_buffer.h │ │ │ ├── slist.h │ │ │ ├── stack.h │ │ │ ├── treeset.h │ │ │ └── treetable.h │ │ ├── list.c │ │ ├── pqueue.c │ │ ├── queue.c │ │ ├── ring_buffer.c │ │ ├── slist.c │ │ ├── stack.c │ │ ├── treeset.c │ │ └── treetable.c │ └── test │ │ ├── CMakeLists.txt │ │ ├── arrayTest.cpp │ │ ├── array_test.c │ │ ├── dequeTest.cpp │ │ ├── deque_test.c │ │ ├── hashsetTest.cpp │ │ ├── hashset_test.c │ │ ├── hashtableTest.cpp │ │ ├── hashtable_test.c │ │ ├── listTest.cpp │ │ ├── list_test.c │ │ ├── pqueueTest.cpp │ │ ├── pqueue_test.c │ │ ├── queueTest.cpp │ │ ├── queue_test.c │ │ ├── rbufTest.cpp │ │ ├── rbuf_test.c │ │ ├── slistTest.cpp │ │ ├── slist_test.c │ │ ├── stackTest.cpp │ │ ├── stack_test.c │ │ ├── treesetTest.cpp │ │ ├── treeset_test.c │ │ ├── treetableTest.cpp │ │ └── treetable_test.c ├── keep └── tcc │ ├── stdalign.h │ └── stdatomic.h ├── CMakeLists.txt ├── Makefile.handby ├── byg4 ├── Calc.g4 ├── Makefile ├── main1.go ├── parser │ ├── Calc.interp │ ├── Calc.tokens │ ├── CalcLexer.interp │ ├── CalcLexer.tokens │ ├── calc_base_listener.go │ ├── calc_lexer.go │ ├── calc_listener.go │ └── calc_parser.go └── readme.md ├── bygocc └── dust.bnf ├── byir ├── .gitignore ├── LICENSE ├── README.md ├── builtin.go ├── builtin_println.go ├── const.go ├── go.mod ├── go.sum ├── instr.go ├── main.go ├── testdata │ ├── append │ │ └── append.go │ ├── closure │ │ └── main.go │ ├── complex │ │ └── main.go │ ├── cos │ │ └── main.go │ ├── floatparse │ │ └── main.go │ ├── index │ │ └── main.go │ ├── interfaces │ │ └── main.go │ ├── m │ │ └── m.go │ ├── os │ │ └── main.go │ ├── recursivetype │ │ ├── fn.go │ │ └── recursivetype.go │ ├── scopes │ │ └── main.go │ ├── sha1 │ │ ├── main.go │ │ └── sha1 │ │ │ ├── sha1.go │ │ │ └── sha1block.go │ ├── slice-print │ │ └── main.go │ ├── slicelit │ │ └── main.go │ ├── slicing │ │ └── slicing.go │ ├── str │ │ └── main.go │ ├── strcmp │ │ └── main.go │ ├── strphi │ │ └── strphi.go │ ├── unop │ │ └── main.go │ └── unsafe │ │ └── main.go └── types.go ├── bysrc ├── CMakeLists.txt ├── astutil.go ├── backups │ ├── compilernim.go │ └── cparser.go ├── build.go ├── builtins.go ├── compiler2c.go ├── computil.go ├── cparser2.go ├── ctypes.go ├── dev.mk ├── expall.yml ├── libtcc.go ├── main1.go ├── mdcc │ ├── main3.go │ └── testc11atomic.h ├── parser.go ├── parseutil.go ├── readme.md ├── tpkgs │ ├── array1 │ │ └── t.go │ ├── array2 │ │ └── t.go │ ├── array3 │ │ └── t.go │ ├── array4 │ │ └── t.go │ ├── assign1 │ │ └── t.go │ ├── assign2 │ │ └── t.go │ ├── assign3 │ │ └── t.go │ ├── binop1 │ │ └── t.go │ ├── builtin1 │ │ └── t.go │ ├── builtin2 │ │ └── t.go │ ├── catch1 │ │ └── t.go │ ├── catch2 │ │ └── t.go │ ├── cgo1 │ │ ├── t.go │ │ └── t2.go │ ├── cgo2 │ │ └── t.go │ ├── cgo3 │ │ ├── t.go │ │ ├── t2.go │ │ └── t3.go │ ├── chan1 │ │ └── t.go │ ├── chan2 │ │ └── t.go │ ├── closure1 │ │ └── t.go │ ├── closure2 │ │ └── t.go │ ├── closure3 │ │ └── t.go │ ├── closure4 │ │ └── t.go │ ├── const1 │ │ └── t.go │ ├── defer1 │ │ └── t.go │ ├── error1 │ │ └── t.go │ ├── error2 │ │ └── t.go │ ├── foo1 │ │ └── foo.go │ ├── for1 │ │ └── for1.go │ ├── for2 │ │ └── for1.go │ ├── for3 │ │ └── for1.go │ ├── for4 │ │ └── t.go │ ├── forin1 │ │ └── t.go │ ├── forin2 │ │ └── t.go │ ├── forin3 │ │ └── t.go │ ├── forin4 │ │ └── t.go │ ├── functor1 │ │ └── t.go │ ├── gc1 │ │ └── t.go │ ├── globvar1 │ │ └── t.go │ ├── globvar2 │ │ └── t.go │ ├── gostmt1 │ │ └── t.go │ ├── hello │ │ └── hello.go │ ├── if1 │ │ └── t.go │ ├── iface1 │ │ └── t.go │ ├── iface2 │ │ └── t.go │ ├── iface3 │ │ └── t.go │ ├── import1 │ │ └── t.go │ ├── initfunc1 │ │ └── t.go │ ├── lib1 │ │ └── t.go │ ├── lib2 │ │ └── t.go │ ├── lib3 │ │ └── t.go │ ├── map1 │ │ └── t.go │ ├── map2 │ │ └── t.go │ ├── method1 │ │ └── t.go │ ├── multiret1 │ │ └── t.go │ ├── multiret2 │ │ └── t.go │ ├── multiret3 │ │ └── t.go │ ├── operator1 │ │ └── t.go │ ├── operator2 │ │ └── t.go │ ├── operator3 │ │ └── t.go │ ├── range1 │ │ └── t.go │ ├── range2 │ │ └── t.go │ ├── string1 │ │ └── t.go │ ├── string2 │ │ └── t.go │ ├── string3 │ │ └── t.go │ ├── string4 │ │ └── t.go │ ├── string5 │ │ └── t.go │ ├── strings1 │ │ └── t.go │ ├── struct1 │ │ └── t.go │ ├── struct2 │ │ └── t.go │ ├── switch1 │ │ └── t.go │ ├── switch2 │ │ └── t.go │ ├── switch3 │ │ └── t.go │ ├── tmpl │ │ └── t.go │ ├── tmpvar1 │ │ └── t.go │ ├── tmpvar2 │ │ └── t.go │ ├── tyalias1 │ │ └── t.go │ ├── tyassert1 │ │ └── t.go │ └── unsafe1 │ │ └── t.go ├── transform.go ├── typeutil.go ├── utests.sh └── vendor │ ├── github.com │ └── xlab │ │ └── c-for-go.bak │ │ ├── LICENSE │ │ ├── README.md │ │ ├── docs │ │ ├── overview.png │ │ └── sphere.png │ │ ├── generator │ │ ├── Makefile │ │ ├── gen_bindings.go │ │ ├── gen_callbacks.go │ │ ├── gen_common.go │ │ ├── gen_const.go │ │ ├── gen_declares.go │ │ ├── gen_files.go │ │ ├── gen_struct_helpers.go │ │ ├── gen_typedef.go │ │ ├── gen_union.go │ │ └── generator.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── main.go │ │ ├── parser │ │ ├── parser.go │ │ └── predefined.go │ │ ├── process.go │ │ └── translator │ │ ├── array_spec.go │ │ ├── ast_walker.go │ │ ├── helpers.go │ │ ├── model_declaration.go │ │ ├── model_enum.go │ │ ├── model_function.go │ │ ├── model_go_type.go │ │ ├── model_struct_union.go │ │ ├── model_type.go │ │ ├── rules.go │ │ ├── translator.go │ │ └── type_mapping.go │ ├── go │ ├── ast │ │ ├── ast.go │ │ ├── ast_test.go │ │ ├── commentmap.go │ │ ├── commentmap_test.go │ │ ├── example_test.go │ │ ├── filter.go │ │ ├── filter_test.go │ │ ├── import.go │ │ ├── print.go │ │ ├── print_test.go │ │ ├── resolve.go │ │ ├── scope.go │ │ └── walk.go │ ├── build │ │ ├── build.go │ │ ├── build_test.go │ │ ├── deps_test.go │ │ ├── doc.go │ │ ├── gc.go │ │ ├── gccgo.go │ │ ├── read.go │ │ ├── read_test.go │ │ ├── syslist.go │ │ ├── syslist_test.go │ │ ├── testdata │ │ │ ├── doc │ │ │ │ ├── a_test.go │ │ │ │ ├── b_test.go │ │ │ │ ├── c_test.go │ │ │ │ ├── d_test.go │ │ │ │ ├── e.go │ │ │ │ └── f.go │ │ │ ├── empty │ │ │ │ └── dummy │ │ │ ├── multi │ │ │ │ ├── file.go │ │ │ │ └── file_appengine.go │ │ │ ├── other │ │ │ │ ├── file │ │ │ │ │ └── file.go │ │ │ │ └── main.go │ │ │ └── withvendor │ │ │ │ └── src │ │ │ │ └── a │ │ │ │ ├── b │ │ │ │ └── b.go │ │ │ │ └── vendor │ │ │ │ └── c │ │ │ │ └── d │ │ │ │ └── d.go │ │ └── zcgo.go │ ├── constant │ │ ├── example_test.go │ │ ├── value.go │ │ └── value_test.go │ ├── doc │ │ ├── Makefile │ │ ├── comment.go │ │ ├── comment_test.go │ │ ├── doc.go │ │ ├── doc_test.go │ │ ├── example.go │ │ ├── example_test.go │ │ ├── exports.go │ │ ├── filter.go │ │ ├── headscan.go │ │ ├── reader.go │ │ ├── synopsis.go │ │ ├── synopsis_test.go │ │ └── testdata │ │ │ ├── a.0.golden │ │ │ ├── a.1.golden │ │ │ ├── a.2.golden │ │ │ ├── a0.go │ │ │ ├── a1.go │ │ │ ├── b.0.golden │ │ │ ├── b.1.golden │ │ │ ├── b.2.golden │ │ │ ├── b.go │ │ │ ├── benchmark.go │ │ │ ├── blank.0.golden │ │ │ ├── blank.1.golden │ │ │ ├── blank.2.golden │ │ │ ├── blank.go │ │ │ ├── bugpara.0.golden │ │ │ ├── bugpara.1.golden │ │ │ ├── bugpara.2.golden │ │ │ ├── bugpara.go │ │ │ ├── c.0.golden │ │ │ ├── c.1.golden │ │ │ ├── c.2.golden │ │ │ ├── c.go │ │ │ ├── d.0.golden │ │ │ ├── d.1.golden │ │ │ ├── d.2.golden │ │ │ ├── d1.go │ │ │ ├── d2.go │ │ │ ├── e.0.golden │ │ │ ├── e.1.golden │ │ │ ├── e.2.golden │ │ │ ├── e.go │ │ │ ├── error1.0.golden │ │ │ ├── error1.1.golden │ │ │ ├── error1.2.golden │ │ │ ├── error1.go │ │ │ ├── error2.0.golden │ │ │ ├── error2.1.golden │ │ │ ├── error2.2.golden │ │ │ ├── error2.go │ │ │ ├── example.go │ │ │ ├── f.0.golden │ │ │ ├── f.1.golden │ │ │ ├── f.2.golden │ │ │ ├── f.go │ │ │ ├── g.0.golden │ │ │ ├── g.1.golden │ │ │ ├── g.2.golden │ │ │ ├── g.go │ │ │ ├── issue12839.0.golden │ │ │ ├── issue12839.1.golden │ │ │ ├── issue12839.2.golden │ │ │ ├── issue12839.go │ │ │ ├── issue13742.0.golden │ │ │ ├── issue13742.1.golden │ │ │ ├── issue13742.2.golden │ │ │ ├── issue13742.go │ │ │ ├── issue16153.0.golden │ │ │ ├── issue16153.1.golden │ │ │ ├── issue16153.2.golden │ │ │ ├── issue16153.go │ │ │ ├── issue17788.0.golden │ │ │ ├── issue17788.1.golden │ │ │ ├── issue17788.2.golden │ │ │ ├── issue17788.go │ │ │ ├── issue22856.0.golden │ │ │ ├── issue22856.1.golden │ │ │ ├── issue22856.2.golden │ │ │ ├── issue22856.go │ │ │ ├── predeclared.0.golden │ │ │ ├── predeclared.1.golden │ │ │ ├── predeclared.2.golden │ │ │ ├── predeclared.go │ │ │ ├── template.txt │ │ │ ├── testing.0.golden │ │ │ ├── testing.1.golden │ │ │ ├── testing.2.golden │ │ │ └── testing.go │ ├── format │ │ ├── benchmark_test.go │ │ ├── example_test.go │ │ ├── format.go │ │ ├── format_test.go │ │ └── internal.go │ ├── importer │ │ ├── importer.go │ │ └── importer_test.go │ ├── internal │ │ ├── gccgoimporter │ │ │ ├── ar.go │ │ │ ├── gccgoinstallation.go │ │ │ ├── gccgoinstallation_test.go │ │ │ ├── importer.go │ │ │ ├── importer_test.go │ │ │ ├── parser.go │ │ │ ├── parser_test.go │ │ │ └── testdata │ │ │ │ ├── aliases.go │ │ │ │ ├── aliases.gox │ │ │ │ ├── complexnums.go │ │ │ │ ├── complexnums.gox │ │ │ │ ├── conversions.go │ │ │ │ ├── conversions.gox │ │ │ │ ├── escapeinfo.go │ │ │ │ ├── escapeinfo.gox │ │ │ │ ├── imports.go │ │ │ │ ├── imports.gox │ │ │ │ ├── issue27856.go │ │ │ │ ├── issue27856.gox │ │ │ │ ├── issue29198.go │ │ │ │ ├── issue29198.gox │ │ │ │ ├── issue30628.go │ │ │ │ ├── issue30628.gox │ │ │ │ ├── issue31540.go │ │ │ │ ├── issue31540.gox │ │ │ │ ├── libimportsar.a │ │ │ │ ├── nointerface.go │ │ │ │ ├── nointerface.gox │ │ │ │ ├── pointer.go │ │ │ │ ├── pointer.gox │ │ │ │ ├── time.gox │ │ │ │ ├── unicode.gox │ │ │ │ └── v1reflect.gox │ │ ├── gcimporter │ │ │ ├── bimport.go │ │ │ ├── exportdata.go │ │ │ ├── gcimporter.go │ │ │ ├── gcimporter_test.go │ │ │ ├── iimport.go │ │ │ └── testdata │ │ │ │ ├── a.go │ │ │ │ ├── b.go │ │ │ │ ├── exports.go │ │ │ │ ├── issue15920.go │ │ │ │ ├── issue20046.go │ │ │ │ ├── issue25301.go │ │ │ │ ├── issue25596.go │ │ │ │ ├── p.go │ │ │ │ └── versions │ │ │ │ ├── test.go │ │ │ │ ├── test_go1.11_0i.a │ │ │ │ ├── test_go1.11_6b.a │ │ │ │ ├── test_go1.11_999b.a │ │ │ │ ├── test_go1.11_999i.a │ │ │ │ ├── test_go1.7_0.a │ │ │ │ ├── test_go1.7_1.a │ │ │ │ ├── test_go1.8_4.a │ │ │ │ └── test_go1.8_5.a │ │ └── srcimporter │ │ │ ├── srcimporter.go │ │ │ ├── srcimporter_test.go │ │ │ └── testdata │ │ │ ├── issue20855 │ │ │ └── issue20855.go │ │ │ ├── issue23092 │ │ │ └── issue23092.go │ │ │ └── issue24392 │ │ │ └── issue24392.go │ ├── parser │ │ ├── error_test.go │ │ ├── example_test.go │ │ ├── interface.go │ │ ├── parser.go │ │ ├── parser_test.go │ │ ├── performance_test.go │ │ ├── short_test.go │ │ └── testdata │ │ │ ├── commas.src │ │ │ ├── issue11377.src │ │ │ ├── issue23434.src │ │ │ └── issue3106.src │ ├── printer │ │ ├── example_test.go │ │ ├── nodes.go │ │ ├── performance_test.go │ │ ├── printer.go │ │ ├── printer_test.go │ │ └── testdata │ │ │ ├── alignment.golden │ │ │ ├── alignment.input │ │ │ ├── comments.golden │ │ │ ├── comments.input │ │ │ ├── comments.x │ │ │ ├── comments2.golden │ │ │ ├── comments2.input │ │ │ ├── complit.input │ │ │ ├── complit.x │ │ │ ├── declarations.golden │ │ │ ├── declarations.input │ │ │ ├── empty.golden │ │ │ ├── empty.input │ │ │ ├── expressions.golden │ │ │ ├── expressions.input │ │ │ ├── expressions.raw │ │ │ ├── linebreaks.golden │ │ │ ├── linebreaks.input │ │ │ ├── parser.go │ │ │ ├── slow.golden │ │ │ ├── slow.input │ │ │ ├── statements.golden │ │ │ └── statements.input │ ├── scanner │ │ ├── errors.go │ │ ├── example_test.go │ │ ├── scanner.go │ │ └── scanner_test.go │ ├── token │ │ ├── example_test.go │ │ ├── position.go │ │ ├── position_test.go │ │ ├── serialize.go │ │ ├── serialize_test.go │ │ ├── token.go │ │ └── token_test.go │ └── types │ │ ├── api.go │ │ ├── api_test.go │ │ ├── assignments.go │ │ ├── builtins.go │ │ ├── builtins_test.go │ │ ├── call.go │ │ ├── check.go │ │ ├── check_test.go │ │ ├── conversions.go │ │ ├── decl.go │ │ ├── errors.go │ │ ├── eval.go │ │ ├── eval_test.go │ │ ├── example_test.go │ │ ├── expr.go │ │ ├── exprstring.go │ │ ├── exprstring_test.go │ │ ├── gccgosizes.go │ │ ├── gotype.go │ │ ├── hilbert_test.go │ │ ├── initorder.go │ │ ├── interfaces.go │ │ ├── issues_test.go │ │ ├── labels.go │ │ ├── lookup.go │ │ ├── methodset.go │ │ ├── myhack.go │ │ ├── object.go │ │ ├── object_test.go │ │ ├── objset.go │ │ ├── operand.go │ │ ├── package.go │ │ ├── predicates.go │ │ ├── resolver.go │ │ ├── resolver_test.go │ │ ├── return.go │ │ ├── scope.go │ │ ├── selection.go │ │ ├── self_test.go │ │ ├── sizes.go │ │ ├── sizes_test.go │ │ ├── stdlib_test.go │ │ ├── stmt.go │ │ ├── testdata │ │ ├── blank.src │ │ ├── builtins.src │ │ ├── const0.src │ │ ├── const1.src │ │ ├── constdecl.src │ │ ├── conversions.src │ │ ├── conversions2.src │ │ ├── cycles.src │ │ ├── cycles1.src │ │ ├── cycles2.src │ │ ├── cycles3.src │ │ ├── cycles4.src │ │ ├── cycles5.src │ │ ├── decls0.src │ │ ├── decls1.src │ │ ├── decls2a.src │ │ ├── decls2b.src │ │ ├── decls3.src │ │ ├── decls4.src │ │ ├── decls5.src │ │ ├── errors.src │ │ ├── expr0.src │ │ ├── expr1.src │ │ ├── expr2.src │ │ ├── expr3.src │ │ ├── gotos.src │ │ ├── importC.src │ │ ├── importdecl0a.src │ │ ├── importdecl0b.src │ │ ├── importdecl1a.src │ │ ├── importdecl1b.src │ │ ├── init0.src │ │ ├── init1.src │ │ ├── init2.src │ │ ├── issue23203a.src │ │ ├── issue23203b.src │ │ ├── issue25008a.src │ │ ├── issue25008b.src │ │ ├── issue26390.src │ │ ├── issue28251.src │ │ ├── issues.src │ │ ├── labels.src │ │ ├── literals.src │ │ ├── methodsets.src │ │ ├── shifts.src │ │ ├── stmt0.src │ │ ├── stmt1.src │ │ └── vardecl.src │ │ ├── token_test.go │ │ ├── type.go │ │ ├── typestring.go │ │ ├── typestring_test.go │ │ ├── typexpr.go │ │ └── universe.go │ ├── golang.org │ └── x │ │ └── tools │ │ └── go │ │ └── ast │ │ └── astutil │ │ ├── enclosing.go │ │ ├── enclosing_test.go │ │ ├── imports.go │ │ ├── imports_test.go │ │ ├── rewrite.go │ │ ├── rewrite_test.go │ │ └── util.go │ ├── internal │ ├── goroot │ │ ├── gc.go │ │ └── gccgo.go │ ├── goversion │ │ └── goversion.go │ ├── lazyregexp │ │ └── lazyre.go │ └── xcoff │ │ ├── ar.go │ │ ├── ar_test.go │ │ ├── file.go │ │ ├── file_test.go │ │ ├── testdata │ │ ├── bigar-empty │ │ ├── bigar-ppc64 │ │ ├── gcc-ppc32-aix-dwarf2-exec │ │ ├── gcc-ppc64-aix-dwarf2-exec │ │ ├── hello.c │ │ ├── printbye.c │ │ └── printhello.c │ │ └── xcoff.go │ └── xgopackages │ ├── golist.go │ └── packages.go ├── corona-c ├── Makefile ├── atomic.c ├── atomic.h ├── chan.c ├── chan.h ├── coro.c ├── coro.h ├── corona.c ├── corona.h ├── corona_util.c ├── corona_util.h ├── coronagc.c ├── coronagc.h ├── coronapriv.h ├── corowp.c ├── crnpub.h ├── datstu.c ├── datstu.h ├── functrace.c ├── futex.c ├── futex.h ├── hchan.c ├── hchan.h ├── hook.c ├── hook.h ├── hook2.c ├── hook2.h ├── hookbyplt.c ├── hookcb.c ├── hookcb.h ├── hselect.c ├── libev_verbose.h ├── main.c ├── netpoller.h ├── netpoller_epoll.c ├── netpoller_ev.c ├── netpoller_event.c ├── readme.md ├── rxilog.c ├── rxilog.h ├── szqueue.c ├── szqueue.h └── yieldtypes.h ├── corona-nim ├── .gdbinit ├── Makefile ├── ascproj.nim ├── coro.nim ├── corona.nim ├── corona.nim.cfg ├── corona.nimble ├── ffi.nim ├── ffi1.c ├── gochanapi.nim ├── gogoapi.nim ├── hook.nim ├── test.sh └── tests │ ├── boehwgc0.nim │ ├── chan0.nim │ ├── chan1.nim │ ├── common.nim │ ├── config.nims │ ├── except0.nim │ ├── fiber0.nim │ ├── manyroutines.nim │ ├── tcpcon0.nim │ ├── test1.nim.example │ └── usleep0.nim ├── cplus └── readme.md ├── cxrt.cmake ├── docs ├── closure_compat_rawfnptr.c ├── debug.md └── pass.md ├── golang ├── Go │ └── go_parser_base.go ├── GoLexer.g4 ├── GoParser.g4 ├── Makefile ├── README.md ├── examples │ ├── anonymousMethods.go │ ├── arrayDecls.go │ ├── arrayEllipsisDecls.go │ ├── bufChan.go │ ├── chan.go │ ├── constDecl.go │ ├── defers.go │ ├── example.go │ ├── forStmts.go │ ├── foreachStmts.go │ ├── function.go │ ├── gostmts.go │ ├── hardcodedPassword.go │ ├── ill_but_correct.go │ ├── interface_inheritance.go │ ├── interfaces.go │ ├── map_with_string.go │ ├── maps.go │ ├── method.go │ ├── multiple_type_decl.go │ ├── params.go │ ├── promoted.go │ ├── returnStmt.go │ ├── select.go │ ├── shortVarDecl.go │ ├── sliceDecls.go │ ├── strings.go │ ├── struct_promotion.go │ ├── struct_with_func_type.go │ ├── structs.go │ ├── switchesExpr.go │ ├── switchesType.go │ ├── typeAsserts.go │ ├── varDecl.go │ └── weakHash.go ├── main1.go └── pom.xml ├── include └── routine.cpp ├── misc ├── Makefile ├── cogc.c ├── cogc1.c ├── corona-impl-in-nim-native.nim └── dpelf.c ├── readme.md ├── scripts ├── build-bysrc-linux.sh ├── build-bysrc-macos.sh ├── build-bysrc.sh ├── build-libgc-8.0.4x.sh ├── date.sh ├── preinstall.sh └── pubcrn.sh ├── src ├── cppminrt.cpp ├── cxarray.c ├── cxhashtable.c ├── cxiface.c ├── cxmemory.c ├── cxqueue.c ├── cxrtbase.c ├── cxrtbase.h └── cxstring.c ├── tests └── simlink.c └── xgo ├── adt ├── adt.go ├── queue.go ├── queue_test.go ├── stack.go └── stack_test.go ├── builtin ├── argenv.go ├── array.go ├── array_test.go ├── builtin.go ├── builtin_test.go ├── closure.go ├── fiber.go ├── hamap.go ├── hamap_test.go ├── memory.go ├── primitive.go ├── reflect.go ├── string.go └── types.go ├── cjson └── cjson.go ├── curl ├── curl.go └── useragent.go ├── cutil └── cutil.go ├── dwarf ├── addr2line.c ├── addr2line.go ├── addr2line2.c ├── dwarf_tag_attr.go ├── dwconstnames.go ├── helper.go ├── libbfd.go ├── libdwarf.go └── libdwarf2.go ├── fmt └── format.go ├── math └── rand │ └── rand.go ├── misc.go ├── runtime ├── libc.go └── runtime.go ├── src ├── atomic │ └── atomic.go ├── chan1 │ └── chan.go ├── coro │ ├── coro.c │ ├── coro.go │ ├── coro.h │ └── coroapi.c ├── dl │ └── dl.go ├── epoll │ └── epoll.go ├── futex │ ├── futex.go │ ├── futex_test.v │ └── mutex.go ├── iohook │ ├── hook.c │ ├── hook.h │ ├── iohook.go │ ├── minlog.c │ ├── minlog.h │ └── yieldtypes.h ├── iopoller │ ├── libiopoller.h │ ├── netpoller.go │ └── netpoller_test.v ├── os │ ├── command.go │ ├── errno.go │ └── os.go ├── rand │ └── rand.go ├── rtcom │ ├── rtcom.c │ └── rtcom.go ├── sched │ └── sched.go ├── time │ └── time.go ├── unsafe │ └── unsafe.go └── vmm │ └── vmm.go ├── strings └── strings.go ├── xasm └── asm.go ├── xdl ├── dl.go └── ffi.go ├── xdummy └── dummy.go ├── xerrors └── errors.go ├── xgc └── bdwgc.go ├── xlog ├── backtrace.go ├── log.go └── log_test.go ├── xmath └── math.go ├── xnet ├── httpcli.go ├── httpcom.go ├── httpsrv.go ├── ifaces.go ├── socket.go ├── url_parser.c ├── url_parser.go ├── url_parser.h └── url_parser_test.go ├── xstrconv └── strconv.go ├── xstrings ├── builder.go └── strings.go └── xsync ├── atomic.go └── sync.go /3rdparty/cltc/AUTHORS: -------------------------------------------------------------------------------- 1 | Srđan Panić 2 | Igor Zakharov 3 | Kyle Sweeney 4 | Fábio Maia 5 | Ankur Huralikoppi 6 | Radu Brumariu 7 | xfilesee 8 | Joël Jungo 9 | Adam Canady 10 | Venkata Krishna Sundararajan 11 | Nimit Bhardwaj 12 | Stephen Feinstein 13 | Roger Kahn 14 | Buzz Bissinger 15 | George Plimpton 16 | Dan Gutman 17 | -------------------------------------------------------------------------------- /3rdparty/cltc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) 4 | 5 | enable_language(C) 6 | enable_language(CXX) 7 | 8 | set(CFLAGS "-Wall -Werror") 9 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CFLAGS}") 10 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CFLAGS}") 11 | enable_testing() 12 | 13 | add_subdirectory(src) 14 | add_subdirectory(test) 15 | -------------------------------------------------------------------------------- /3rdparty/cltc/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | 3 | project(collectc VERSION 0.0.1) 4 | 5 | file(GLOB source_files "*.c") 6 | file(GLOB header_files "include/*.h") 7 | 8 | add_library(${PROJECT_NAME} SHARED ${source_files}) 9 | add_library(${PROJECT_NAME}_static STATIC ${source_files}) 10 | include_directories("./include") 11 | 12 | set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${header_files}") 13 | set_target_properties(${PROJECT_NAME}_static PROPERTIES OUTPUT_NAME ${PROJECT_NAME}) 14 | 15 | target_link_libraries(${PROJECT_NAME}) 16 | 17 | set(${PROJECT_NAME}_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/include 18 | CACHE INTERNAL "${PROJECT_NAME}: Include directories" FORCE) 19 | 20 | include(FindPkgConfig QUIET) 21 | if(PKG_CONFIG_FOUND) 22 | configure_file("collectionc.pc.in" "collectionc.pc" @ONLY) 23 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/collectionc.pc" 24 | DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig") 25 | endif() 26 | 27 | install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_static 28 | ARCHIVE DESTINATION lib 29 | LIBRARY DESTINATION lib 30 | PUBLIC_HEADER DESTINATION include/${PROJECT_NAME} 31 | ) 32 | -------------------------------------------------------------------------------- /3rdparty/cltc/src/collectc: -------------------------------------------------------------------------------- 1 | include -------------------------------------------------------------------------------- /3rdparty/cltc/src/collectionc.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/lib 4 | includedir=${prefix}/include 5 | 6 | Name: @CMAKE_PROJECT_NAME@ 7 | Description: C data structures collection 8 | Version: @CMAKE_VERSION@ 9 | Libs: -L${libdir} -lcollectc 10 | Cflags: -I${includedir} -------------------------------------------------------------------------------- /3rdparty/cltc/src/include/ring_buffer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @Author: S. Sharma 3 | * @Date: 2019-03-07T10:32:52-06:00 4 | * @Email: silentcat@protonmail.com 5 | * @Last modified by: silentcat 6 | * @Last modified time: 2019-03-09T15:14:36-06:00 7 | */ 8 | 9 | #ifndef COLLECTIONS_C_RBUF_H 10 | #define COLLECTIONS_C_RBUF_H 11 | 12 | #include "common.h" 13 | #include 14 | 15 | #define DEFAULT_RBUF_CAPACITY 10 16 | 17 | typedef struct ring_buffer_conf RbufConf; 18 | typedef struct ring_buffer Rbuf; 19 | 20 | enum cc_stat rbuf_new (Rbuf **rbuf); 21 | void rbuf_conf_init (RbufConf *rconf); 22 | enum cc_stat rbuf_conf_new (RbufConf *rconf, Rbuf **rbuf); 23 | void rbuf_enqueue (Rbuf *rbuf, uint64_t item); 24 | enum cc_stat rbuf_dequeue (Rbuf *rbuf, uint64_t *out); 25 | bool rbuf_is_empty (Rbuf *rbuf); 26 | size_t rbuf_size (Rbuf *rbuf); 27 | void rbuf_destroy (Rbuf *rbuf); 28 | uint64_t rbuf_peek (Rbuf *rbuf, int index); 29 | 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /3rdparty/cltc/test/hashsetTest.cpp: -------------------------------------------------------------------------------- 1 | #include "CppUTest/TestHarness_c.h" 2 | #include "CppUTest/CommandLineTestRunner.h" 3 | 4 | TEST_GROUP_C_WRAPPER(HashSetTests) 5 | { 6 | TEST_GROUP_C_SETUP_WRAPPER(HashSetTests); 7 | TEST_GROUP_C_TEARDOWN_WRAPPER(HashSetTests); 8 | }; 9 | 10 | TEST_GROUP_C_WRAPPER(HashSetTestsConf) 11 | { 12 | TEST_GROUP_C_SETUP_WRAPPER(HashSetTestsConf); 13 | TEST_GROUP_C_TEARDOWN_WRAPPER(HashSetTestsConf); 14 | }; 15 | 16 | TEST_C_WRAPPER(HashSetTestsConf, HashSetNew); 17 | TEST_C_WRAPPER(HashSetTests, HashSetAdd); 18 | TEST_C_WRAPPER(HashSetTests, HashSetRemove); 19 | TEST_C_WRAPPER(HashSetTests, HashSetRemoveAll); 20 | TEST_C_WRAPPER(HashSetTests, HashSetIterNext); 21 | TEST_C_WRAPPER(HashSetTests, HashSetIterRemove); 22 | 23 | int main(int argc, char **argv) { 24 | return RUN_ALL_TESTS(argc, argv); 25 | } 26 | -------------------------------------------------------------------------------- /3rdparty/cltc/test/pqueueTest.cpp: -------------------------------------------------------------------------------- 1 | #include "CppUTest/TestHarness_c.h" 2 | #include "CppUTest/CommandLineTestRunner.h" 3 | 4 | TEST_GROUP_C_WRAPPER(PQueueTestsWithDefaults) 5 | { 6 | TEST_GROUP_C_SETUP_WRAPPER(PQueueTestsWithDefaults); 7 | TEST_GROUP_C_TEARDOWN_WRAPPER(PQueueTestsWithDefaults); 8 | }; 9 | 10 | TEST_C_WRAPPER(PQueueTestsWithDefaults, PqueuePush); 11 | TEST_C_WRAPPER(PQueueTestsWithDefaults, PqueuePop); 12 | 13 | int main(int argc, char **argv) { 14 | return RUN_ALL_TESTS(argc, argv); 15 | } 16 | -------------------------------------------------------------------------------- /3rdparty/cltc/test/queueTest.cpp: -------------------------------------------------------------------------------- 1 | #include "CppUTest/TestHarness_c.h" 2 | #include "CppUTest/CommandLineTestRunner.h" 3 | 4 | TEST_GROUP_C_WRAPPER(QueueTestsWithDefaults) 5 | { 6 | TEST_GROUP_C_SETUP_WRAPPER(QueueTestsWithDefaults); 7 | TEST_GROUP_C_TEARDOWN_WRAPPER(QueueTestsWithDefaults); 8 | }; 9 | 10 | TEST_C_WRAPPER(QueueTestsWithDefaults, QueueEnqueue); 11 | TEST_C_WRAPPER(QueueTestsWithDefaults, QueuePoll); 12 | TEST_C_WRAPPER(QueueTestsWithDefaults, QueueIter); 13 | TEST_C_WRAPPER(QueueTestsWithDefaults, QueueZipIterNext); 14 | 15 | int main(int argc, char **argv) { 16 | return RUN_ALL_TESTS(argc, argv); 17 | } 18 | -------------------------------------------------------------------------------- /3rdparty/cltc/test/rbufTest.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @Author: S. Sharma 3 | * @Date: 2019-03-07T21:58:26-06:00 4 | * @Email: silentcat@protonmail.com 5 | * @Last modified by: silentcat 6 | * @Last modified time: 2019-03-09T15:13:05-06:00 7 | */ 8 | 9 | #include "CppUTest/TestHarness_c.h" 10 | #include "CppUTest/CommandLineTestRunner.h" 11 | 12 | TEST_GROUP_C_WRAPPER(RbufTest) 13 | { 14 | TEST_GROUP_C_SETUP_WRAPPER(RbufTest); 15 | TEST_GROUP_C_TEARDOWN_WRAPPER(RbufTest); 16 | }; 17 | 18 | TEST_C_WRAPPER(RbufTest, RbufEnqueue); 19 | TEST_C_WRAPPER(RbufTest, RbufDequeue); 20 | TEST_C_WRAPPER(RbufTest, RbufEnqueuePastCapacity); 21 | 22 | int main(int argc, char **argv) { 23 | return RUN_ALL_TESTS(argc, argv); 24 | } 25 | -------------------------------------------------------------------------------- /3rdparty/cltc/test/stackTest.cpp: -------------------------------------------------------------------------------- 1 | #include "CppUTest/TestHarness_c.h" 2 | #include "CppUTest/CommandLineTestRunner.h" 3 | 4 | TEST_GROUP_C_WRAPPER(StackTestsWithDefaults) 5 | { 6 | TEST_GROUP_C_SETUP_WRAPPER(StackTestsWithDefaults); 7 | TEST_GROUP_C_TEARDOWN_WRAPPER(StackTestsWithDefaults); 8 | }; 9 | 10 | TEST_C_WRAPPER(StackTestsWithDefaults, StackPush); 11 | TEST_C_WRAPPER(StackTestsWithDefaults, StackPop); 12 | 13 | int main(int argc, char **argv) { 14 | return RUN_ALL_TESTS(argc, argv); 15 | } 16 | -------------------------------------------------------------------------------- /3rdparty/cltc/test/treesetTest.cpp: -------------------------------------------------------------------------------- 1 | #include "CppUTest/TestHarness_c.h" 2 | #include "CppUTest/CommandLineTestRunner.h" 3 | 4 | TEST_GROUP_C_WRAPPER(TreeSetTestsWithDefaults) 5 | { 6 | TEST_GROUP_C_SETUP_WRAPPER(TreeSetTestsWithDefaults); 7 | TEST_GROUP_C_TEARDOWN_WRAPPER(TreeSetTestsWithDefaults); 8 | }; 9 | 10 | TEST_C_WRAPPER(TreeSetTestsWithDefaults, TreeSetAdd); 11 | TEST_C_WRAPPER(TreeSetTestsWithDefaults, TreeSetRemove); 12 | TEST_C_WRAPPER(TreeSetTestsWithDefaults, TreeSetRemoveAll); 13 | TEST_C_WRAPPER(TreeSetTestsWithDefaults, TreeSetSetSize); 14 | TEST_C_WRAPPER(TreeSetTestsWithDefaults, TreeSetIterNext); 15 | TEST_C_WRAPPER(TreeSetTestsWithDefaults, TreeSetIterRemove); 16 | 17 | int main(int argc, char **argv){ 18 | return RUN_ALL_TESTS(argc, argv); 19 | } 20 | -------------------------------------------------------------------------------- /3rdparty/keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitech/cygo/00df926d11520643c19f0cf867d9a0870b72374b/3rdparty/keep -------------------------------------------------------------------------------- /3rdparty/tcc/stdalign.h: -------------------------------------------------------------------------------- 1 | #ifndef _STDALIGN_H 2 | #define _STDALIGN_H 3 | 4 | #if __STDC_VERSION__ < 201112L && (defined(__GNUC__) || defined(__TINYC__)) 5 | # define _Alignas(t) __attribute__((__aligned__(t))) 6 | # define _Alignof(t) __alignof__(t) 7 | #endif 8 | 9 | #define alignas _Alignas 10 | #define alignof _Alignof 11 | 12 | #define __alignas_is_defined 1 13 | #define __alignof_is_defined 1 14 | 15 | #endif /* _STDALIGN_H */ 16 | 17 | -------------------------------------------------------------------------------- /3rdparty/tcc/stdatomic.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitech/cygo/00df926d11520643c19f0cf867d9a0870b72374b/3rdparty/tcc/stdatomic.h -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | project(cxrt) 3 | cmake_minimum_required(VERSION 3.0) 4 | 5 | if("${CMAKE_VERBOSE_MAKEFILE}" STREQUAL "FALSE") 6 | set(CMAKE_VERBOSE_MAKEFILE on) 7 | endif() 8 | 9 | include(cxrt.cmake) 10 | 11 | add_executable(simlnk tests/simlink.c) 12 | target_link_libraries(simlnk cxrt) 13 | 14 | add_executable(corona corona-c/main.c) 15 | set_target_properties(corona PROPERTIES COMPILE_FLAGS ${corona_c_flags}) 16 | target_link_libraries(corona -L. crn -L./bdwgc/.libs -L./cltc/lib gc collectc event event_pthreads pthread dl) 17 | 18 | # target_compile_options(corona PRIVATE ) 19 | 20 | -------------------------------------------------------------------------------- /Makefile.handby: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | dmb: # cor 5 | gcc -g -O0 -std=c11 -D_GNU_SOURCE -o cxrtbase.o -c include/cxrtbase.c -I./include 6 | gcc -g -O0 -std=c11 -o foo.o -c bysrc/opkgs/foo.c -I./include 7 | g++ -g -O0 -std=c++11 -o dm0 foo.o cxrtbase.o routine.o \ 8 | -L./libgo -llibgo -lgc -lcord -lgccpp -ldl -lpthread 9 | 10 | cor: 11 | # cmake -DCMAKE_BUILD_TYPE=debug -DBUILD_DYNAMIC=on . 12 | g++ -g -O0 -std=c++11 -o routine.o -c include/routine.cpp -I./libgo/libgo 13 | 14 | run: 15 | LD_LIBRARY_PATH=./libgo ./dm0 16 | 17 | clean: 18 | rm -f *.o 19 | 20 | -------------------------------------------------------------------------------- /byg4/Calc.g4: -------------------------------------------------------------------------------- 1 | 2 | 3 | // Calc.g4 4 | grammar Calc; 5 | 6 | // Tokens 7 | MUL: '*'; 8 | DIV: '/'; 9 | ADD: '+'; 10 | SUB: '-'; 11 | NUMBER: [0-9]+; 12 | WHITESPACE: [ \r\n\t]+ -> skip; 13 | 14 | // Rules 15 | start : expression EOF; 16 | 17 | expression 18 | : expression op=('*'|'/') expression # MulDiv 19 | | expression op=('+'|'-') expression # AddSub 20 | | NUMBER # Number 21 | ; 22 | -------------------------------------------------------------------------------- /byg4/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | #antlr4 -long-messages Calc.g4 3 | antlr4 -long-messages -Dlanguage=Go -o parser Calc.g4 4 | -------------------------------------------------------------------------------- /byg4/main1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/antlr/antlr4/runtime/Go/antlr" 4 | import "cxrt/byg4/parser" 5 | import "fmt" 6 | 7 | func main() { 8 | // Setup the input 9 | is := antlr.NewInputStream("1 + 2 * 3") 10 | 11 | // Create the Lexer 12 | lexer := parser.NewCalcLexer(is) 13 | 14 | // Read all tokens 15 | for { 16 | t := lexer.NextToken() 17 | if t.GetTokenType() == antlr.TokenEOF { 18 | break 19 | } 20 | fmt.Printf("%s (%q)\n", 21 | lexer.SymbolicNames[t.GetTokenType()], t.GetText()) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /byg4/parser/Calc.interp: -------------------------------------------------------------------------------- 1 | token literal names: 2 | null 3 | '*' 4 | '/' 5 | '+' 6 | '-' 7 | null 8 | null 9 | 10 | token symbolic names: 11 | null 12 | MUL 13 | DIV 14 | ADD 15 | SUB 16 | NUMBER 17 | WHITESPACE 18 | 19 | rule names: 20 | start 21 | expression 22 | 23 | 24 | atn: 25 | [3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 8, 24, 4, 2, 9, 2, 4, 3, 9, 3, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 19, 10, 3, 12, 3, 14, 3, 22, 11, 3, 3, 3, 2, 3, 4, 4, 2, 4, 2, 4, 3, 2, 3, 4, 3, 2, 5, 6, 2, 23, 2, 6, 3, 2, 2, 2, 4, 9, 3, 2, 2, 2, 6, 7, 5, 4, 3, 2, 7, 8, 7, 2, 2, 3, 8, 3, 3, 2, 2, 2, 9, 10, 8, 3, 1, 2, 10, 11, 7, 7, 2, 2, 11, 20, 3, 2, 2, 2, 12, 13, 12, 5, 2, 2, 13, 14, 9, 2, 2, 2, 14, 19, 5, 4, 3, 6, 15, 16, 12, 4, 2, 2, 16, 17, 9, 3, 2, 2, 17, 19, 5, 4, 3, 5, 18, 12, 3, 2, 2, 2, 18, 15, 3, 2, 2, 2, 19, 22, 3, 2, 2, 2, 20, 18, 3, 2, 2, 2, 20, 21, 3, 2, 2, 2, 21, 5, 3, 2, 2, 2, 22, 20, 3, 2, 2, 2, 4, 18, 20] -------------------------------------------------------------------------------- /byg4/parser/Calc.tokens: -------------------------------------------------------------------------------- 1 | MUL=1 2 | DIV=2 3 | ADD=3 4 | SUB=4 5 | NUMBER=5 6 | WHITESPACE=6 7 | '*'=1 8 | '/'=2 9 | '+'=3 10 | '-'=4 11 | -------------------------------------------------------------------------------- /byg4/parser/CalcLexer.tokens: -------------------------------------------------------------------------------- 1 | MUL=1 2 | DIV=2 3 | ADD=3 4 | SUB=4 5 | NUMBER=5 6 | WHITESPACE=6 7 | '*'=1 8 | '/'=2 9 | '+'=3 10 | '-'=4 11 | -------------------------------------------------------------------------------- /byg4/parser/calc_listener.go: -------------------------------------------------------------------------------- 1 | // Code generated from Calc.g4 by ANTLR 4.7.2. DO NOT EDIT. 2 | 3 | package parser // Calc 4 | 5 | import "github.com/antlr/antlr4/runtime/Go/antlr" 6 | 7 | // CalcListener is a complete listener for a parse tree produced by CalcParser. 8 | type CalcListener interface { 9 | antlr.ParseTreeListener 10 | 11 | // EnterStart is called when entering the start production. 12 | EnterStart(c *StartContext) 13 | 14 | // EnterNumber is called when entering the Number production. 15 | EnterNumber(c *NumberContext) 16 | 17 | // EnterMulDiv is called when entering the MulDiv production. 18 | EnterMulDiv(c *MulDivContext) 19 | 20 | // EnterAddSub is called when entering the AddSub production. 21 | EnterAddSub(c *AddSubContext) 22 | 23 | // ExitStart is called when exiting the start production. 24 | ExitStart(c *StartContext) 25 | 26 | // ExitNumber is called when exiting the Number production. 27 | ExitNumber(c *NumberContext) 28 | 29 | // ExitMulDiv is called when exiting the MulDiv production. 30 | ExitMulDiv(c *MulDivContext) 31 | 32 | // ExitAddSub is called when exiting the AddSub production. 33 | ExitAddSub(c *AddSubContext) 34 | } 35 | -------------------------------------------------------------------------------- /byg4/readme.md: -------------------------------------------------------------------------------- 1 | https://blog.gopheracademy.com/advent-2017/parsing-with-antlr4-and-go/ 2 | 3 | https://github.com/antlr/grammars-v4/ 4 | 5 | -------------------------------------------------------------------------------- /byir/.gitignore: -------------------------------------------------------------------------------- 1 | a.out 2 | -------------------------------------------------------------------------------- /byir/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2019 Peter Waller 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /byir/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/pwaller/go2ll 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/llir/llvm v0.3.0-pre6.0.20190209230502-10a64dac8a1a 7 | golang.org/x/tools v0.0.0-20190208222737-3744606dbb67 8 | ) 9 | 10 | replace github.com/llir/llvm => ./llvm 11 | -------------------------------------------------------------------------------- /byir/testdata/append/append.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | ints() 5 | structs() 6 | } 7 | 8 | func ints() { 9 | var x []int 10 | println(x) 11 | x = append(x, 1) 12 | println(x, x[0]) 13 | x = append(x, 2) 14 | println(x, x[0], x[1]) 15 | x = append(x, 123456) 16 | println(x, x[0], x[1], x[2]) 17 | 18 | x = append(x, 99, 98, 87) 19 | 20 | intsDumpSlice(x) 21 | } 22 | 23 | func structs() { 24 | type foo struct { 25 | x, y int 26 | } 27 | var s []foo 28 | s = append(s, foo{1, 2}) 29 | s = append(s, foo{3, 4}) 30 | println(s[0].x, s[0].y) 31 | println(s[1].x, s[1].y) 32 | } 33 | 34 | func intsDumpSlice(x []int) { 35 | for i, v := range x { 36 | println(i, v) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /byir/testdata/closure/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | val := true 5 | f := func(b bool) bool { 6 | println("f():", b) 7 | return b && val 8 | } 9 | val = false 10 | if f(true) { 11 | println("main(): true") 12 | } else { 13 | println("main(): false") 14 | } 15 | 16 | makeFunc(true)() 17 | makeFunc(false)() 18 | } 19 | 20 | func g() { 21 | println("g()") 22 | } 23 | 24 | func makeFunc(cond bool) func() { 25 | var x int 26 | f := func() { 27 | println("f() closure:", x) 28 | } 29 | x = 42 30 | 31 | var ret func() 32 | if cond { 33 | ret = f 34 | } else { 35 | ret = g 36 | } 37 | return ret 38 | } 39 | -------------------------------------------------------------------------------- /byir/testdata/complex/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | x := 2 + 1i 5 | println(x) 6 | } 7 | -------------------------------------------------------------------------------- /byir/testdata/cos/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "math" 4 | 5 | func main() { 6 | // var x float64 = 1.2 7 | // println(x) 8 | println(math.Cos(1.2)) 9 | } 10 | -------------------------------------------------------------------------------- /byir/testdata/floatparse/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "strconv" 4 | 5 | func main() { 6 | var y float64 7 | for i := 0; i < 100000000; i++ { 8 | x, _ := strconv.ParseFloat("2.34567", 64) 9 | y += x 10 | x, _ = strconv.ParseFloat("12.34567", 64) 11 | y += x 12 | x, _ = strconv.ParseFloat("1.34567", 64) 13 | y += x 14 | x, _ = strconv.ParseFloat("12.4567", 64) 15 | y += x 16 | } 17 | 18 | println("hello world", int(y)) 19 | } 20 | -------------------------------------------------------------------------------- /byir/testdata/index/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | for i, v := range [...]int{42, 2, 3, 4, 5} { 5 | println(i, v) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /byir/testdata/interfaces/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type concreteFoo int 4 | 5 | func (f *concreteFoo) Foo() { 6 | println(f) 7 | } 8 | 9 | func main() { 10 | var x concreteFoo = 2 11 | f(&x) 12 | } 13 | 14 | func f(fooer interface{ Foo() }) { 15 | fooer.Foo() 16 | } 17 | -------------------------------------------------------------------------------- /byir/testdata/m/m.go: -------------------------------------------------------------------------------- 1 | package m 2 | 3 | import "github.com/pwaller/go2ll/testdata/m/a" 4 | 5 | type F struct{ x int } 6 | 7 | func (f *F) set(x int) { 8 | f.x = x 9 | } 10 | 11 | func M() { 12 | a.A() 13 | var f F 14 | f.set(1) 15 | println(f.x) 16 | } 17 | -------------------------------------------------------------------------------- /byir/testdata/os/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "os" 4 | 5 | func main() { 6 | os.Stdout.Write([]byte("hi")) 7 | } -------------------------------------------------------------------------------- /byir/testdata/recursivetype/fn.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type foo func() foo 4 | 5 | func g() foo { 6 | return func() foo { 7 | return nil 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /byir/testdata/recursivetype/recursivetype.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | Left, Right *T 5 | } 6 | 7 | // type M map[string]M 8 | 9 | func main() { 10 | var t T 11 | println(t.Left, t.Right) 12 | } 13 | -------------------------------------------------------------------------------- /byir/testdata/scopes/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | v := 1 5 | switch v { 6 | case 1: 7 | type u struct{ i int64 } 8 | var vu u 9 | println(vu.i) 10 | case 2: 11 | type u struct{ i float64 } 12 | var vu u 13 | println(vu.i) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /byir/testdata/sha1/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/pwaller/go2ll/testdata/sha1/sha1" 5 | ) 6 | 7 | func main() { 8 | d := sha1.New() 9 | input := []byte("Hello world") 10 | for i := 0; i < 100000000; i++ { 11 | d.Write(input) 12 | } 13 | println(encodeToString(d.Sum(nil))) 14 | } 15 | 16 | func encode(dst, src []byte) int { 17 | for i, v := range src { 18 | dst[i*2] = hextable[v>>4] 19 | dst[i*2+1] = hextable[v&0x0f] 20 | } 21 | 22 | return len(src) * 2 23 | } 24 | 25 | const hextable = "0123456789abcdef" 26 | 27 | func encodeToString(src []byte) string { 28 | dst := make([]byte, encodedLen(len(src))) 29 | encode(dst, src) 30 | return string(dst) 31 | } 32 | 33 | func encodedLen(n int) int { return n * 2 } 34 | -------------------------------------------------------------------------------- /byir/testdata/slice-print/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | slice := []int{1, 2, 3, 4} 5 | println(slice) 6 | } 7 | -------------------------------------------------------------------------------- /byir/testdata/slicelit/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var powtab = []int{1, 2, 3, 4} 4 | 5 | func main() { 6 | println(powtab[0], powtab[1]) 7 | } 8 | -------------------------------------------------------------------------------- /byir/testdata/str/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := "foobar" 5 | b := "baz" 6 | println(a + b) 7 | } 8 | -------------------------------------------------------------------------------- /byir/testdata/strcmp/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | // print(true) 5 | // print(false) 6 | println("entry") 7 | a := "a" 8 | b := "b" 9 | println(a == b) 10 | println(a != b) 11 | println(a < b) 12 | println(a > b) 13 | println(a <= b) 14 | println(a >= b) 15 | println(a == a) 16 | println(a != a) 17 | println(a < a) 18 | println(a > a) 19 | println(a <= a) 20 | println(a >= a) 21 | println("exit") 22 | } 23 | -------------------------------------------------------------------------------- /byir/testdata/strphi/strphi.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | env := "foo,bar,baz" 5 | for env != "" { 6 | i := -1 7 | var field string 8 | field, env = env[:i], env[i+1:] 9 | println(env, field) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /byir/testdata/unop/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | for a := 0; a < 16; a++ { 5 | println(a, ^a) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /byir/testdata/unsafe/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "unsafe" 4 | 5 | func main() { 6 | var b byte 7 | bp1 := add1(&b) 8 | println(&b, bp1) 9 | // from 10 | } 11 | 12 | func add1(p *byte) *byte { 13 | return (*byte)(unsafe.Pointer(uintptr(unsafe.Pointer(p)) + 1)) 14 | } 15 | 16 | func fromFutexWakeup() { 17 | *(*int32)(unsafe.Pointer(uintptr(0x1006))) = 0x1006 18 | } 19 | 20 | func abort() 21 | -------------------------------------------------------------------------------- /bysrc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | project(cxrt) 3 | cmake_minimum_required(VERSION 3.0) 4 | 5 | if("${CMAKE_VERBOSE_MAKEFILE}" STREQUAL "FALSE") 6 | set(CMAKE_VERBOSE_MAKEFILE on) 7 | endif() 8 | 9 | include(../cxrt.cmake) 10 | 11 | add_executable(genoe opkgs/foo.c) 12 | include_directories("/usr/lib/libffi-3.2.1/include") 13 | target_link_libraries(genoe -L. crn -lcurl -ldwarf -lelf ${cxrt_ldflags}) 14 | 15 | # add_executable(co1 co1.c ../corona-c/coro.c) 16 | # target_link_libraries(co1 -L../bdwgc/.libs gc pthread) 17 | # set_target_properties(co1 PROPERTIES COMPILE_FLAGS ${corona_c_flags}) 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /bysrc/builtins.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // prefered use ../xgo/builtin package as builtin feature 4 | 5 | var builtinfns = map[string]int{ 6 | "println": 1, "sleep": 1, "gettid": 1, "panic": 1, "panicln": 1, 7 | } 8 | -------------------------------------------------------------------------------- /bysrc/dev.mk: -------------------------------------------------------------------------------- 1 | # -DIOHOOK_XLIB 2 | # -lX11 3 | all: 4 | gcc -g -O0 -fPIC -std=gnu99 -DCORO_ASM -D_GNU_SOURCE -DGC_THREADS -DNRDEBUG -DIOHOOK_XLIB -lavcodec -lavdevice -lavutil -lX11 -lgc -ldl -latomic -lpthread opkgs/foo.c 5 | ls -lh a.out 6 | -------------------------------------------------------------------------------- /bysrc/expall.yml: -------------------------------------------------------------------------------- 1 | 2 | TRANSLATOR: 3 | ConstRules: 4 | defines: expand 5 | enum: expand 6 | Rules: 7 | global: 8 | - {action: accept, from: ""} 9 | const: 10 | - {action: accept, from: ""} 11 | function: 12 | - {action: accept, from: ""} 13 | type: 14 | - {action: accept, from: ""} 15 | -------------------------------------------------------------------------------- /bysrc/mdcc/testc11atomic.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTC11ATOMIC_H 2 | #define TESTC11ATOMIC_H 3 | 4 | #include 5 | // modernc.org/cc not support 6 | // #include 7 | #include 8 | 9 | __thread int foovar1 = 0; 10 | 11 | #endif /* TESTC11ATOMIC_H */ 12 | -------------------------------------------------------------------------------- /bysrc/tpkgs/array1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = []int{1, 2, 3} 5 | println(v) 6 | 7 | var n1 = len(v) 8 | println(n1) 9 | 10 | var n2 = cap(v) 11 | println(n2) 12 | 13 | v2 := v[1:2] 14 | println(v2) 15 | 16 | n3 := len(v2) 17 | println(n3) 18 | 19 | v[1] = 5 20 | 21 | e1 := v[1] 22 | println(e1) 23 | 24 | v = nil 25 | } 26 | -------------------------------------------------------------------------------- /bysrc/tpkgs/array2/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = []string{"abc", "def"} 5 | println(v) 6 | 7 | ch := v[1][2] 8 | println(ch) 9 | if ch != 'f' { 10 | println("err", ch) 11 | } 12 | 13 | v[1][2] = 'g' 14 | ch2 := v[1][2] 15 | println(ch2) 16 | 17 | v = nil 18 | } 19 | -------------------------------------------------------------------------------- /bysrc/tpkgs/array3/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = 5 5 | println(v) 6 | 7 | a1 := [...]int{1, 2, 3, 4, 5} 8 | println(a1) 9 | println(len(a1)) 10 | println(cap(a1)) 11 | } 12 | -------------------------------------------------------------------------------- /bysrc/tpkgs/array4/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = 5 5 | println(v) 6 | 7 | v2 := []int{1, 2, 3} 8 | v2 = append(v2, 4) 9 | println(v2) 10 | println(len(v2), 4) 11 | 12 | v2 = append(v2, 5, 6, 7, 8) 13 | println(len(v2), 8) 14 | 15 | } 16 | -------------------------------------------------------------------------------- /bysrc/tpkgs/assign1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = 5 5 | println(v) 6 | } 7 | -------------------------------------------------------------------------------- /bysrc/tpkgs/assign2/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v int 5 | println(v) 6 | } 7 | -------------------------------------------------------------------------------- /bysrc/tpkgs/assign3/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = 5 5 | println(v) 6 | 7 | var s string 8 | println(s) 9 | println(len(s)) 10 | } 11 | -------------------------------------------------------------------------------- /bysrc/tpkgs/binop1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = 5 5 | var x = 6 6 | var r = v * x 7 | println(v) 8 | } 9 | -------------------------------------------------------------------------------- /bysrc/tpkgs/builtin1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var i uintptr 5 | var v voidptr 6 | var vvp2 voidptr = nil 7 | var cstr byteptr 8 | var vusz usize 9 | var vu64 u64 10 | var vi64 i64 11 | var vf64 f64 12 | var vf32 f32 13 | 14 | } 15 | -------------------------------------------------------------------------------- /bysrc/tpkgs/builtin2/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | sz := /*builtin.*/ sizeof(int) 5 | if false { 6 | /*builtin.*/ assert(1 == 2) 7 | } 8 | sz2 := alignof(int) 9 | println(sz, sz2) 10 | } 11 | -------------------------------------------------------------------------------- /bysrc/tpkgs/catch1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var Err1 error 4 | 5 | func foo() (int, string) { 6 | if true { 7 | return 1, "true" 8 | } else { 9 | return 0, "false" 10 | } 11 | } 12 | 13 | func main() { 14 | var v = 5 15 | println(v) 16 | 17 | /* 18 | catch { 19 | case Err1: 20 | } 21 | */ 22 | } 23 | -------------------------------------------------------------------------------- /bysrc/tpkgs/catch2/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func foo1() error { 4 | return nil 5 | } 6 | func foo2() (int, error) { 7 | foo1() 8 | return 0, nil 9 | } 10 | func main() { 11 | var err1 error 12 | 13 | foo1() 14 | println(111) 15 | foo2() 16 | println(222) 17 | 18 | catch{ 19 | case nil : 20 | case err1: 21 | default: 22 | println(err) 23 | if true { 24 | continue 25 | }else{ 26 | break 27 | } 28 | } 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /bysrc/tpkgs/cgo1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | /* 4 | #cgo LDFLAGS: -lcurl 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | */ 11 | import "C" 12 | 13 | /* 14 | hehehehhe 15 | */ 16 | 17 | // aaaaaa 18 | func main() { 19 | var v = 5 20 | println(v) 21 | C.sleep(1) 22 | var fd int = int(C.socket(C.AF_INET, C.SOCK_STREAM, 0)) 23 | println(fd) 24 | // println(C.errno) 25 | var pid int = int(C.getpid()) 26 | println(pid) 27 | 28 | t2foo0() // from ./t2.go 29 | } 30 | -------------------------------------------------------------------------------- /bysrc/tpkgs/cgo1/t2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | /* 4 | #include 5 | 6 | void t2foo0_() { 7 | } 8 | */ 9 | import "C" 10 | 11 | func t2foo0() { 12 | C.t2foo0_() 13 | } 14 | -------------------------------------------------------------------------------- /bysrc/tpkgs/cgo2/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | /* 4 | */ 5 | import "C" 6 | 7 | type foost struct { 8 | a int 9 | b bool 10 | } 11 | 12 | type cint = C.int 13 | type cuint = C.uint 14 | 15 | type cint1 C.int 16 | type cuint1 C.uint 17 | 18 | func main() { 19 | var v = 5 20 | println(v) 21 | 22 | i1 := cint(0) 23 | 24 | } 25 | -------------------------------------------------------------------------------- /bysrc/tpkgs/cgo3/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | /* 4 | #cgo LDFLAGS: -lcurl 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | */ 11 | import "C" 12 | 13 | /* 14 | hehehehhe 15 | */ 16 | 17 | // aaaaaa 18 | func main() { 19 | var v = 5 20 | println(v) 21 | C.sleep(1) 22 | fd := C.socket(C.AF_INET, C.SOCK_STREAM, 0) 23 | println(fd) 24 | // println(C.errno) 25 | pid := C.getpid() 26 | println(pid) 27 | 28 | } 29 | -------------------------------------------------------------------------------- /bysrc/tpkgs/cgo3/t2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | /* 4 | #include 5 | */ 6 | import "C" 7 | 8 | func mytime() C.time_t { 9 | tm := C.time(nil) 10 | return tm 11 | } 12 | -------------------------------------------------------------------------------- /bysrc/tpkgs/cgo3/t3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func foo123() { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /bysrc/tpkgs/chan1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func node0(no int, c chan int) { 4 | println("node0", no) 5 | c <- no 6 | } 7 | 8 | func node1(no int, c chan int) { 9 | println("node1", no) 10 | rno := <-c 11 | println("node1 done", no, rno) 12 | } 13 | 14 | func main() { 15 | var c = make(chan int, 5) 16 | go node0(51, c) 17 | go node1(81, c) 18 | sleep(5) 19 | } 20 | -------------------------------------------------------------------------------- /bysrc/tpkgs/chan2/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type foo struct { 4 | x int 5 | y int 6 | } 7 | 8 | func main() { 9 | var v = 5 10 | println(v) 11 | 12 | var c1 chan *foo 13 | if false { 14 | v1 := <-c1 15 | } 16 | if false { 17 | c1 <- nil 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /bysrc/tpkgs/closure1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = 5 5 | println(v) 6 | 7 | f1 := func() {} 8 | f2 := func(a int, b bool) {} 9 | f3 := func() bool { return true } 10 | } 11 | -------------------------------------------------------------------------------- /bysrc/tpkgs/closure2/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func foo() { 4 | 5 | } 6 | 7 | type bar struct { 8 | b1 int 9 | b2 bool 10 | } 11 | 12 | func useclos(fff func()) { 13 | fff() 14 | println(999) 15 | } 16 | 17 | func main() { 18 | var v = 5 19 | println(v) 20 | 21 | s1 := "hehehe" 22 | fv1 := 1.23 23 | stv1 := &bar{} 24 | 25 | f1 := func() { 26 | println("closvar", v) 27 | println(s1) 28 | println(fv1) 29 | println(stv1) 30 | v += 1 31 | } 32 | 33 | f1() 34 | 35 | f2 := f1 36 | f2() 37 | 38 | useclos(f2) 39 | println("clos add var", v) 40 | 41 | // f2 := foo 42 | // f2() 43 | } 44 | -------------------------------------------------------------------------------- /bysrc/tpkgs/closure3/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func foo() { 4 | 5 | } 6 | 7 | type bar struct { 8 | b1 int 9 | b2 bool 10 | } 11 | 12 | func main() { 13 | var v = 5 14 | println(v) 15 | 16 | s1 := "hehehe" 17 | fv1 := 1.23 18 | stv1 := &bar{} 19 | 20 | f1 := func() { 21 | println(v) 22 | println(s1) 23 | println(fv1) 24 | println(stv1) 25 | 26 | cv1 := false 27 | println(cv1) 28 | } 29 | 30 | f1() 31 | 32 | // f2 := foo 33 | // f2() 34 | } 35 | -------------------------------------------------------------------------------- /bysrc/tpkgs/closure4/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = 5 5 | println(v) 6 | 7 | func() {}() 8 | func(a int, b bool) {}(1, 2) 9 | f3 := func() bool { return true }() 10 | } 11 | -------------------------------------------------------------------------------- /bysrc/tpkgs/const1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const ( 4 | mutexLocked = 1 << iota // mutex is locked 5 | mutexWoken 6 | mutexStarving 7 | mutexWaiterShift = iota 8 | mutexWaiterShift2 9 | mutexWaiterShift3 10 | ) 11 | 12 | const ( 13 | gs1 = "abc" 14 | gs2 = "efg" 15 | ) 16 | 17 | var g1 = 1 18 | var b1 = true 19 | 20 | func main() { 21 | var v = 5 22 | println(v) 23 | } 24 | -------------------------------------------------------------------------------- /bysrc/tpkgs/defer1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func foo() { 4 | 5 | } 6 | func foo2() { 7 | 8 | } 9 | func foo3() { 10 | } 11 | 12 | func main() { 13 | defer foo() 14 | var v = 5 15 | println(v) 16 | defer foo2() 17 | if false { 18 | v = 6 19 | return 20 | } 21 | defer foo3() 22 | return 23 | } 24 | -------------------------------------------------------------------------------- /bysrc/tpkgs/error1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "errors" 4 | 5 | func main() { 6 | var v = 5 7 | println(v) 8 | var err error 9 | err = errors.New("hehehe") 10 | println(err.Error()) 11 | } 12 | -------------------------------------------------------------------------------- /bysrc/tpkgs/error2/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func foo() (int, error) { 4 | return 0, nil 5 | } 6 | 7 | func foo2() (int, error) { 8 | var err error 9 | errreturn(err, 1, err) 10 | return 11 | } 12 | 13 | func foo3() (string, error) { 14 | var err error 15 | errreturn(err, "abc", err) 16 | return 17 | } 18 | 19 | func foo4() error { 20 | var err error 21 | errreturn(err, err) 22 | return 23 | } 24 | 25 | func main() { 26 | foo() 27 | 28 | v1, err1 := foo() 29 | errreturn(err1) 30 | 31 | v2, err2 := foo() 32 | 33 | switch { 34 | case 1 == 2: 35 | case 3 == 4: 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /bysrc/tpkgs/foo1/foo.go: -------------------------------------------------------------------------------- 1 | package foo 2 | 3 | func bar() int { 4 | sleep(1) 5 | // fmt.Println(time.Now()) 6 | foo() 7 | go foo() 8 | go foo2(1, 2) 9 | return 0 10 | } 11 | 12 | func foo() { 13 | println("foo called") 14 | } 15 | 16 | func foo1() string { 17 | return "" 18 | } 19 | 20 | func foo2(a int, b int) { 21 | println("foo2 called", a) 22 | } 23 | 24 | type color struct { 25 | r byte 26 | g byte 27 | b byte 28 | a byte 29 | } 30 | 31 | func main() { 32 | c := &color{} 33 | println(c) 34 | 35 | println(5) 36 | 37 | println("aaa", 123, gettid()) 38 | 39 | bar() 40 | sleep(5) 41 | } 42 | -------------------------------------------------------------------------------- /bysrc/tpkgs/for1/for1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func routine1(sleepsec int) { 4 | for i := 0; i < 5; i++ { 5 | println("", sleepsec, i) 6 | sleep(sleepsec) 7 | } 8 | } 9 | 10 | func main() { 11 | routine1(3) 12 | } 13 | -------------------------------------------------------------------------------- /bysrc/tpkgs/for2/for1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func routine1(sleepsec int) { 4 | for { 5 | println("", sleepsec, 0) 6 | sleep(sleepsec) 7 | break 8 | } 9 | } 10 | 11 | func main() { 12 | routine1(3) 13 | } 14 | -------------------------------------------------------------------------------- /bysrc/tpkgs/for3/for1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func routine1(sleepsec int) { 4 | var i = 0 5 | for i = 0; i < 5; i++ { 6 | println("", sleepsec, i) 7 | sleep(sleepsec) 8 | } 9 | for i := 0; i < 3; i++ { 10 | println("", sleepsec, i) 11 | } 12 | } 13 | 14 | func main() { 15 | routine1(3) 16 | } 17 | -------------------------------------------------------------------------------- /bysrc/tpkgs/for4/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = 5 5 | println(v) 6 | 7 | arr := []int{1, 2, 3} 8 | for range arr { 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /bysrc/tpkgs/forin1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = 5 5 | println(v) 6 | arr := []int{1, 2, 3} 7 | //* 8 | for in arr { 9 | // println(i,e) 10 | } 11 | //*/ 12 | } 13 | -------------------------------------------------------------------------------- /bysrc/tpkgs/forin2/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = 5 5 | println(v) 6 | arr := []int{1, 2, 3} 7 | //* 8 | for idx, elm in arr { 9 | println(idx,elm) 10 | } 11 | for elm in arr { 12 | 13 | } 14 | //*/ 15 | /* 16 | for idx, elem := range arr { 17 | println(idx, elem) 18 | } 19 | */ 20 | } 21 | -------------------------------------------------------------------------------- /bysrc/tpkgs/forin3/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = 5 5 | println(v) 6 | arr := map[int]int{1:1, 2:2, 3:3} 7 | //* 8 | for idx, elm in arr { 9 | println(idx,elm) 10 | } 11 | for elm in arr { 12 | 13 | } 14 | for in arr { 15 | 16 | } 17 | //*/ 18 | /* 19 | for idx, elem := range arr { 20 | println(idx, elem) 21 | } 22 | */ 23 | } 24 | -------------------------------------------------------------------------------- /bysrc/tpkgs/forin4/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = 5 5 | println(v) 6 | //* 7 | for a in 0..6 { 8 | println(a) 9 | } 10 | for a in v..8 { 11 | println(a) 12 | } 13 | 14 | // TODO compiler 15 | // for in v..8 { 16 | // println(a) 17 | //} 18 | 19 | //*/ 20 | } 21 | -------------------------------------------------------------------------------- /bysrc/tpkgs/functor1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func foo1(f1 func()) { 4 | 5 | } 6 | func foo2(f1 func(int)) { 7 | 8 | } 9 | func foo3() func() { 10 | return nil 11 | } 12 | func foo4() func(int) { 13 | return nil 14 | } 15 | func foo5() func(int) string { 16 | return nil 17 | } 18 | 19 | /* 20 | func foo6() func(int) (string, float32) { 21 | return nil 22 | } 23 | */ 24 | 25 | type bar1 struct { 26 | f1 func() 27 | f2 func(int) 28 | f3 func(string) 29 | f4 func() int 30 | f5 func() []string 31 | } 32 | 33 | func main() { 34 | var v = 5 35 | println(v) 36 | 37 | b1 := &bar1{} 38 | // b1.f1() // TODO compiler 39 | f1 := b1.f1 40 | f1() 41 | f2 := b1.f2 42 | f2(0) 43 | } 44 | -------------------------------------------------------------------------------- /bysrc/tpkgs/gc1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "unsafe" 4 | 5 | func myfinal(ptr unsafe.Pointer) { 6 | println(ptr) 7 | } 8 | func dosomealloc(a int) { 9 | s := "abc" 10 | for i := 0; i < 9; i++ { 11 | s = s + "efghijklmn" 12 | cxrt_set_finalizer(s, myfinal) 13 | sleep(1) 14 | } 15 | println(len(s), a) 16 | } 17 | 18 | func main() { 19 | var v = 5 20 | println(v) 21 | 22 | for i := 0; i < 12345; i++ { 23 | go dosomealloc(i) 24 | sleep(1) 25 | } 26 | sleep(5) 27 | } 28 | -------------------------------------------------------------------------------- /bysrc/tpkgs/globvar1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var v1 = 1 4 | var v2 = 1.2 5 | var v3 = "abc" 6 | 7 | var v4 int = 2 8 | var v5 float32 = 2.3 9 | var v6 string = "efg" 10 | 11 | func main() { 12 | var v = 5 13 | println(v) 14 | 15 | println(v2) 16 | println(v6) 17 | } 18 | -------------------------------------------------------------------------------- /bysrc/tpkgs/globvar2/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var arr1 = []int{1, 2, 3} 4 | var arr2 = []string{"abc", "def"} 5 | 6 | func main() { 7 | var v = 5 8 | println(v) 9 | } 10 | -------------------------------------------------------------------------------- /bysrc/tpkgs/gostmt1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func bar() int { 4 | sleep(1) 5 | // fmt.Println(time.Now()) 6 | foo() 7 | go foo() 8 | go foo2(1, 2) 9 | return 0 10 | } 11 | 12 | func foo() { 13 | println("foo called") 14 | } 15 | 16 | func foo1() string { 17 | return "" 18 | } 19 | 20 | func foo2(a int, b int) { 21 | println("foo2 called", a) 22 | } 23 | 24 | func main() { 25 | 26 | println(5) 27 | 28 | println("aaa", 123, cxgettid()) 29 | 30 | bar() 31 | sleep(5) 32 | } 33 | -------------------------------------------------------------------------------- /bysrc/tpkgs/hello/hello.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | go hello0() 5 | } 6 | 7 | func hello0() { 8 | 9 | } 10 | 11 | func hello1() { 12 | c := make(chan int, 3) 13 | c <- 1 14 | } 15 | 16 | type atree struct { 17 | a int 18 | b string 19 | } 20 | 21 | func hello2() { 22 | // v := &atree{} 23 | // v1 := atree{} 24 | // println(v, v1) 25 | } 26 | 27 | var gv123 int = 1 28 | 29 | func init() { 30 | gv123 = 2 31 | } 32 | 33 | func init() { 34 | gv123 = 3 35 | } 36 | -------------------------------------------------------------------------------- /bysrc/tpkgs/if1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = 5 5 | if v == 5 { 6 | println(v) 7 | } else if v == 6 { 8 | println(6) 9 | } else { 10 | println(3) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /bysrc/tpkgs/iface1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func foo(x interface{}) { 4 | println(x) 5 | } 6 | 7 | func foo2(x interface{}) interface{} { 8 | var v interface{} = 5 9 | return v 10 | } 11 | 12 | type bar struct { 13 | f1 int 14 | f2 string 15 | f3 interface{} 16 | f4 interface{} 17 | f5 interface{} 18 | } 19 | 20 | func main() { 21 | var v = 5 22 | println(v) 23 | 24 | var vx1 interface{} = 5 25 | println(vx1) 26 | pvx1 := vx1.(int) 27 | println(pvx1) 28 | 29 | var vx2 interface{} = "abc" 30 | println(vx2) 31 | 32 | var vx3 interface{} = 1.2345 33 | println(vx3) 34 | 35 | vx4 := foo2(vx3) 36 | println(vx4) 37 | 38 | b1 := &bar{} 39 | println(b1) 40 | b1.f1 = 123 41 | b1.f2 = "abc" 42 | b1.f3 = 8 43 | b1.f4 = vx4 44 | 45 | b1.f5 = []string{"abc", "efg"} 46 | } 47 | -------------------------------------------------------------------------------- /bysrc/tpkgs/iface2/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type foo1 interface { 4 | Name(bool) string 5 | Age() int 6 | } 7 | 8 | type foo2 interface { 9 | Weight(int) int 10 | Sex() int 11 | } 12 | 13 | type foo3 interface { 14 | country() string 15 | city(float32) string 16 | m1() 17 | } 18 | 19 | func main() { 20 | var v = 5 21 | println(v) 22 | } 23 | -------------------------------------------------------------------------------- /bysrc/tpkgs/iface3/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type foo1 interface { 4 | Name(bool) string 5 | Age() int 6 | } 7 | 8 | type foo1impl struct { 9 | } 10 | 11 | func (this *foo1impl) Name(a bool) string { 12 | return "bob" 13 | } 14 | func (this *foo1impl) Age() int { 15 | return 5 16 | } 17 | 18 | func getfoo1() foo1 { 19 | f1 := &foo1impl{} 20 | return f1 21 | } 22 | 23 | func main() { 24 | var v = 5 25 | println(v) 26 | 27 | var f1 foo1 28 | f1 = getfoo1() 29 | f1.Age() 30 | f1.Name(true) 31 | } 32 | -------------------------------------------------------------------------------- /bysrc/tpkgs/import1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "cxrt/bysrc/tpkgs/lib1" 4 | import "cxrt/bysrc/tpkgs/lib2" 5 | import lib3a "cxrt/bysrc/tpkgs/lib3" 6 | 7 | func main() { 8 | var v = 5 9 | println(v) 10 | 11 | lib1.Keep() 12 | lib2.Keep() 13 | lib3a.Keep() 14 | } 15 | -------------------------------------------------------------------------------- /bysrc/tpkgs/initfunc1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func init() { 4 | println(3) 5 | } 6 | func init() { 7 | println(4) 8 | } 9 | func init() { 10 | println(5) 11 | } 12 | 13 | func main() { 14 | var v = 5 15 | println(v) 16 | } 17 | -------------------------------------------------------------------------------- /bysrc/tpkgs/lib1/t.go: -------------------------------------------------------------------------------- 1 | package lib1 2 | 3 | func main123() { 4 | var v = 5 5 | println(v) 6 | } 7 | 8 | func Keep() { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /bysrc/tpkgs/lib2/t.go: -------------------------------------------------------------------------------- 1 | package lib2 2 | 3 | func main123() { 4 | var v = 5 5 | println(v) 6 | } 7 | 8 | func Keep() { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /bysrc/tpkgs/lib3/t.go: -------------------------------------------------------------------------------- 1 | package lib3 2 | 3 | func main123() { 4 | var v = 5 5 | println(v) 6 | } 7 | 8 | func Keep() { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /bysrc/tpkgs/map1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var m1 = map[string]int{"abc": 1, "efg": 2} 5 | println(m1) 6 | } 7 | -------------------------------------------------------------------------------- /bysrc/tpkgs/map2/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var m1 = map[string]int{"abc": 1, "efg": 2} 5 | m1["k1"] = 3 6 | 7 | var k2 = "k2" 8 | m1[k2] = 4 9 | 10 | println(m1) 11 | 12 | mc1 := len(m1) 13 | println(mc1) 14 | // mc2 := cap(m1) 15 | // mc3 := cap(m1) 16 | // println(mc1, mc2, mc3) 17 | 18 | delete(m1, "k1") 19 | m4 := len(m1) 20 | println(m4) 21 | } 22 | -------------------------------------------------------------------------------- /bysrc/tpkgs/method1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type foo struct { 4 | a int 5 | } 6 | 7 | func (this *foo) bar1() { 8 | 9 | } 10 | 11 | func (this *foo) bar2() { 12 | 13 | } 14 | 15 | func (this *foo) bar3() int { 16 | return 5 17 | } 18 | 19 | func (this *foo) bar4(a int) int { 20 | return 5 21 | } 22 | 23 | func bar0() { 24 | 25 | } 26 | 27 | func main() { 28 | fo := &foo{} 29 | println(fo) 30 | fo.bar1() 31 | v := fo.bar3() 32 | println(v) 33 | fo.bar4(6) 34 | } 35 | -------------------------------------------------------------------------------- /bysrc/tpkgs/multiret1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func foo1() (int, string) { 4 | return 5, "abc" 5 | } 6 | 7 | func foo2() (int, error) { 8 | var err error 9 | return 5, err 10 | } 11 | 12 | func main() { 13 | var v = 5 14 | println(v) 15 | 16 | v1, s1 := foo1() 17 | } 18 | -------------------------------------------------------------------------------- /bysrc/tpkgs/multiret2/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func foo1() (iv int, sv string) { 4 | if true { 5 | iv = 3 6 | } 7 | 8 | if false { 9 | return 10 | } 11 | 12 | return 5, "abc" 13 | } 14 | 15 | func foo2() (int, error) { 16 | var err error 17 | return 5, err 18 | } 19 | 20 | func main() { 21 | var v = 5 22 | println(v) 23 | 24 | v1, s1 := foo1() 25 | println(v1, s1) 26 | } 27 | -------------------------------------------------------------------------------- /bysrc/tpkgs/multiret3/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func foo1() (int, string) { 4 | return 5, "abc" 5 | } 6 | 7 | func foo2() (int, error) { 8 | var err error 9 | return 5, err 10 | } 11 | 12 | func main() { 13 | var v = 5 14 | println(v) 15 | 16 | v1, s1 := foo1() 17 | v1, s1 = foo1() 18 | } 19 | -------------------------------------------------------------------------------- /bysrc/tpkgs/operator1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = 5 5 | println(v) 6 | v = v + 1 7 | println(v) 8 | } 9 | -------------------------------------------------------------------------------- /bysrc/tpkgs/operator2/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = 5 5 | println(v) 6 | 7 | v += 5 + 6 + 7 8 | println(v) 9 | 10 | v -= 5 + 6 + 7 11 | println(v) 12 | 13 | v *= 5 + 6 + 7 14 | println(v) 15 | 16 | v /= 5 + 6 + 7 17 | println(v) 18 | 19 | v &= 5 + 6 + 7 20 | println(v) 21 | 22 | v |= 5 + 6 + 7 23 | println(v) 24 | 25 | v ^= 5 + 6 + 7 26 | println(v) 27 | 28 | v <<= 5 + 6 + 7 29 | println(v) 30 | 31 | v >>= 5 + 6 + 7 32 | println(v) 33 | 34 | // v &^= 5 + 6 + 7 35 | // println(v) 36 | } 37 | -------------------------------------------------------------------------------- /bysrc/tpkgs/operator3/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = 5 5 | println(v) 6 | 7 | s := "abc" 8 | println(s) 9 | 10 | s += "efg" + "123" + "xyz" + "foo" 11 | println(s) 12 | 13 | s2 := "你好" 14 | s2 += "世界" 15 | println(s2) 16 | 17 | s2 = s2 + "bar" 18 | println(s2) 19 | } 20 | -------------------------------------------------------------------------------- /bysrc/tpkgs/range1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | str := "abcdefg" 5 | for idx, ch := range str { 6 | println(idx, ch) 7 | } 8 | for _, ch := range str { 9 | println(ch) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /bysrc/tpkgs/range2/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | v := []int{1, 2, 3, 4, 5} 5 | println(v) 6 | println(len(v)) 7 | // sleep(5) 8 | for idx, elem := range v { 9 | println(idx, elem) 10 | } 11 | 12 | { 13 | v := []string{"abc", "def", "ghi"} 14 | println(v) 15 | for idx, elem := range v { 16 | println(idx, elem) 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /bysrc/tpkgs/string1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = "abc" 5 | println(v) 6 | v = v + "def" 7 | println(v) 8 | var slen = len(v) 9 | println(slen, len(v)) 10 | 11 | v1 := v[:3] 12 | println(len(v1)) 13 | 14 | v2 := v[2:] 15 | println(len(v2)) 16 | 17 | v3 := v[2:3] 18 | println(len(v3)) 19 | 20 | v4 := v[3:3] 21 | println(len(v4)) 22 | 23 | // v5 := v[3:2] 24 | // println(len(v5)) 25 | 26 | b1 := v1 == v2 27 | println(b1) 28 | 29 | b2 := v1 != v2 30 | println(b2) 31 | 32 | b3 := !b2 33 | println(b3) 34 | } 35 | -------------------------------------------------------------------------------- /bysrc/tpkgs/string2/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = 5 5 | println(v) 6 | 7 | s1 := "" 8 | s1 = s1 + string('f') 9 | s1 = s1 + string('g') 10 | println(s1) 11 | } 12 | -------------------------------------------------------------------------------- /bysrc/tpkgs/string3/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func hasSuffix(s string, sfx string) bool { 4 | start := len(s) - len(sfx) 5 | if len(s) >= len(sfx) && s[start:] == sfx { 6 | return true 7 | } 8 | return false 9 | } 10 | 11 | func main() { 12 | s := "abcdefg" 13 | s1 := s[4:] 14 | println(s1) 15 | 16 | has1 := hasSuffix(s, "efg") 17 | println(has1) 18 | 19 | has2 := hasSuffix(s, "hhe") 20 | println(has2) 21 | 22 | has3 := hasSuffix(s, "") 23 | println(has3) 24 | } 25 | -------------------------------------------------------------------------------- /bysrc/tpkgs/string4/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = 5 5 | println(v) 6 | 7 | s := "abc" 8 | println(s) 9 | barr := []byte(s) 10 | println(barr) 11 | 12 | s2 := string(barr) 13 | println(s2) 14 | } 15 | -------------------------------------------------------------------------------- /bysrc/tpkgs/string5/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "unsafe" 4 | 5 | type Builder struct { 6 | // addr *Builder // of receiver, to detect copies by value 7 | buf []byte 8 | } 9 | 10 | // String returns the accumulated string. 11 | func (b *Builder) String() string { 12 | p := unsafe.Pointer(&b.buf) 13 | sp := (*string)(p) 14 | s := *sp 15 | // return *(*string)(unsafe.Pointer(&b.buf)) 16 | return s 17 | } 18 | func (b *Builder) String2() string { 19 | return *(*string)(unsafe.Pointer(&b.buf)) 20 | } 21 | 22 | func main() { 23 | var v = 5 24 | println(v) 25 | } 26 | -------------------------------------------------------------------------------- /bysrc/tpkgs/strings1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "congo/strings" 4 | 5 | func main() { 6 | var v = 5 7 | println(v) 8 | 9 | s1 := " abc" 10 | s2 := strings.TrimSpace(s1) 11 | println(s2) 12 | 13 | s3 := "fOo123" 14 | println(strings.HasPrefix(s3, "foo")) 15 | println(strings.HasPrefix(s3, "foo3")) 16 | println(strings.HasSuffix(s3, "123")) 17 | println(strings.HasSuffix(s3, "a123")) 18 | 19 | println(strings.Title(s3)) 20 | println(strings.Upper(s3)) 21 | println(strings.Lower(s3)) 22 | 23 | println(strings.Contains(s3, "foo")) 24 | println(strings.Contains(s3, "fOo")) 25 | println(strings.Contains(s3, "o123")) 26 | } 27 | -------------------------------------------------------------------------------- /bysrc/tpkgs/struct1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type foo struct { 4 | f1 int 5 | f2 string 6 | f3 []int16 7 | } 8 | 9 | func main() { 10 | var v = 5 11 | println(v) 12 | 13 | var fa foo 14 | println(fa) 15 | var fb *foo 16 | println(fb) 17 | } 18 | -------------------------------------------------------------------------------- /bysrc/tpkgs/struct2/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type foo struct { 4 | f1 int 5 | f2 string 6 | // f3 []int16 7 | } 8 | 9 | func main() { 10 | var v = 5 11 | println(v) 12 | 13 | f1 := &foo{1, "abc"} 14 | 15 | println(f1.f2) 16 | 17 | f2 := &foo{f2: "efg", f1: 5} 18 | println(f2.f2) 19 | } 20 | -------------------------------------------------------------------------------- /bysrc/tpkgs/switch1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = 5 5 | switch v { 6 | case 1: 7 | println(1) 8 | case 2: 9 | println(2) 10 | default: 11 | println(42) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /bysrc/tpkgs/switch2/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = 5 5 | println(v) 6 | var v2 = 3 7 | 8 | switch { 9 | case v > 1, v > 2: 10 | v2 = 5 11 | v2 = 6 12 | case v < 1, v < 0: 13 | v2 = 7 14 | v2 = 8 15 | // fallthrough // TODO 16 | case v == 123: 17 | v2 = 123 18 | 19 | } 20 | println(v2) 21 | } 22 | -------------------------------------------------------------------------------- /bysrc/tpkgs/switch3/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const ( 4 | C1 = 1 5 | C2 = 2 6 | C3 = 3 7 | C4 = 4 8 | ) 9 | 10 | func main() { 11 | var v = 5 12 | var v2 = 6 13 | switch i := 0; v { 14 | case C1: 15 | switch v2 { 16 | case C1: 17 | case C2: 18 | break 19 | default: 20 | } 21 | println(1) 22 | case C2: 23 | if 1 == 1 { 24 | break 25 | } 26 | println(2) 27 | case C3, C4: 28 | println(3, 4) 29 | if 1 == 2 { 30 | fallthrough 31 | } 32 | default: 33 | println(42) 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /bysrc/tpkgs/tmpl/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var v = 5 5 | println(v) 6 | } 7 | -------------------------------------------------------------------------------- /bysrc/tpkgs/tmpvar1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func abc(nums []int) int { 4 | return 123 5 | } 6 | 7 | func efg(nums map[int]int) { 8 | 9 | } 10 | 11 | func main() { 12 | var v = 5 13 | println(v) 14 | v2 := abc([]int{1, 2, 3}) 15 | efg(map[int]int{1: 1, 2: 2, 3: 3}) 16 | } 17 | -------------------------------------------------------------------------------- /bysrc/tpkgs/tmpvar2/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type point struct { 4 | x int 5 | y int 6 | } 7 | 8 | func main() { 9 | var v = 5 10 | println(v) 11 | 12 | p1 := &point{} 13 | } 14 | -------------------------------------------------------------------------------- /bysrc/tpkgs/tyalias1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | /* 4 | */ 5 | import "C" 6 | import "unsafe" 7 | 8 | type sttype struct { 9 | f1 int 10 | } 11 | 12 | type abtype1 = int 13 | 14 | type abtype2 int 15 | 16 | type abtype3 *int 17 | 18 | type mypointer = unsafe.Pointer 19 | 20 | func mynewtcm() mypointer 21 | 22 | func main() { 23 | var v = 5 24 | println(v) 25 | var p1 unsafe.Pointer 26 | println(p1) 27 | 28 | sz := unsafe.Sizeof(v) 29 | println(sz) 30 | 31 | vptr := unsafe.Pointer(&v) 32 | println(vptr) 33 | 34 | // var vx mypointer = mynewtcm() 35 | // println(vx) 36 | 37 | // var ptr2 pointer 38 | } 39 | -------------------------------------------------------------------------------- /bysrc/tpkgs/tyassert1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type myerror struct { 4 | } 5 | 6 | func (err *myerror) Error() string { 7 | return "myerrored" 8 | } 9 | 10 | func main() { 11 | var err error 12 | err = &myerror{} 13 | 14 | err2 := err.(*myerror) 15 | println(err2.Error()) 16 | 17 | // err2, ok := err.(*myerror) 18 | } 19 | -------------------------------------------------------------------------------- /bysrc/tpkgs/unsafe1/t.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "unsafe" 4 | 5 | func foo() unsafe.Pointer { 6 | return nil 7 | } 8 | 9 | func foo2(ptr unsafe.Pointer) unsafe.Pointer { 10 | return ptr 11 | } 12 | 13 | func foo3(ptr unsafe.Pointer) unsafe.Pointer { 14 | ptr = (uintptr)(5) 15 | return ptr 16 | } 17 | 18 | func main() { 19 | var v = 5 20 | println(v) 21 | unsafe.Sizeof(v) 22 | unsafe.Alignof(v) 23 | // unsafe.Offsetof(v) 24 | } 25 | -------------------------------------------------------------------------------- /bysrc/utests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | files=$(ls -d tpkgs/* | grep -v ".go") 4 | 5 | totcnt=0 6 | for pkg in $files; do 7 | totcnt=$(($totcnt + 1)) 8 | done 9 | cnter=0 10 | for pkg in $files; do 11 | cnter=$(($cnter + 1)) 12 | echo "[$cnter/$totcnt] $PWD ./bysrc ./$pkg" 13 | ./bysrc ./$pkg/ 14 | #make 15 | ret=$? 16 | if [[ $ret != 0 ]]; then 17 | echo "$PWD $pkg error" 18 | # break; 19 | fi 20 | done 21 | -------------------------------------------------------------------------------- /bysrc/vendor/github.com/xlab/c-for-go.bak/docs/overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitech/cygo/00df926d11520643c19f0cf867d9a0870b72374b/bysrc/vendor/github.com/xlab/c-for-go.bak/docs/overview.png -------------------------------------------------------------------------------- /bysrc/vendor/github.com/xlab/c-for-go.bak/docs/sphere.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitech/cygo/00df926d11520643c19f0cf867d9a0870b72374b/bysrc/vendor/github.com/xlab/c-for-go.bak/docs/sphere.png -------------------------------------------------------------------------------- /bysrc/vendor/github.com/xlab/c-for-go.bak/generator/Makefile: -------------------------------------------------------------------------------- 1 | clean: 2 | rm -f test/foo.go test/cgo_helpers.go test/cgo_helpers.c test/cgo_helpers.h 3 | -------------------------------------------------------------------------------- /bysrc/vendor/github.com/xlab/c-for-go.bak/generator/gen_union.go: -------------------------------------------------------------------------------- 1 | package generator 2 | 3 | import "io" 4 | 5 | func (gen *Generator) WriteUnions(wr io.Writer) int { 6 | return 0 7 | } 8 | -------------------------------------------------------------------------------- /bysrc/vendor/github.com/xlab/c-for-go.bak/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/xlab/c-for-go 2 | 3 | go 1.14 4 | 5 | require ( 6 | github.com/stretchr/testify v1.6.1 // indirect 7 | github.com/tj/go-spin v1.1.0 8 | github.com/xlab/pkgconfig v0.0.0-20170226114623-cea12a0fd245 9 | golang.org/x/tools v0.0.0-20200711155855-7342f9734a7d 10 | gopkg.in/yaml.v2 v2.3.0 11 | modernc.org/cc v1.0.0 12 | modernc.org/golex v1.0.0 // indirect 13 | modernc.org/mathutil v1.1.1 // indirect 14 | modernc.org/strutil v1.1.0 // indirect 15 | modernc.org/xc v1.0.0 16 | ) 17 | -------------------------------------------------------------------------------- /bysrc/vendor/go/build/gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gc 6 | 7 | package build 8 | 9 | import ( 10 | "path/filepath" 11 | "runtime" 12 | ) 13 | 14 | // getToolDir returns the default value of ToolDir. 15 | func getToolDir() string { 16 | return filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH) 17 | } 18 | -------------------------------------------------------------------------------- /bysrc/vendor/go/build/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | package build 8 | 9 | import "runtime" 10 | 11 | // getToolDir returns the default value of ToolDir. 12 | func getToolDir() string { 13 | return envOr("GCCGOTOOLDIR", runtime.GCCGOTOOLDIR) 14 | } 15 | -------------------------------------------------------------------------------- /bysrc/vendor/go/build/syslist.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package build 6 | 7 | const goosList = "aix android darwin dragonfly freebsd hurd illumos js linux nacl netbsd openbsd plan9 solaris windows zos " 8 | const goarchList = "386 amd64 amd64p32 arm armbe arm64 arm64be ppc64 ppc64le mips mipsle mips64 mips64le mips64p32 mips64p32le ppc riscv riscv64 s390 s390x sparc sparc64 wasm " 9 | -------------------------------------------------------------------------------- /bysrc/vendor/go/build/testdata/doc/a_test.go: -------------------------------------------------------------------------------- 1 | // Doc from xtests 2 | package doc_test 3 | -------------------------------------------------------------------------------- /bysrc/vendor/go/build/testdata/doc/b_test.go: -------------------------------------------------------------------------------- 1 | package doc_test 2 | -------------------------------------------------------------------------------- /bysrc/vendor/go/build/testdata/doc/c_test.go: -------------------------------------------------------------------------------- 1 | package doc 2 | -------------------------------------------------------------------------------- /bysrc/vendor/go/build/testdata/doc/d_test.go: -------------------------------------------------------------------------------- 1 | // Doc from regular tests. 2 | package doc 3 | -------------------------------------------------------------------------------- /bysrc/vendor/go/build/testdata/doc/e.go: -------------------------------------------------------------------------------- 1 | package doc 2 | -------------------------------------------------------------------------------- /bysrc/vendor/go/build/testdata/doc/f.go: -------------------------------------------------------------------------------- 1 | // Correct 2 | package doc 3 | -------------------------------------------------------------------------------- /bysrc/vendor/go/build/testdata/empty/dummy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitech/cygo/00df926d11520643c19f0cf867d9a0870b72374b/bysrc/vendor/go/build/testdata/empty/dummy -------------------------------------------------------------------------------- /bysrc/vendor/go/build/testdata/multi/file.go: -------------------------------------------------------------------------------- 1 | // Test data - not compiled. 2 | 3 | package main 4 | 5 | func main() {} 6 | -------------------------------------------------------------------------------- /bysrc/vendor/go/build/testdata/multi/file_appengine.go: -------------------------------------------------------------------------------- 1 | // Test data - not compiled. 2 | 3 | package test_package 4 | 5 | func init() {} 6 | -------------------------------------------------------------------------------- /bysrc/vendor/go/build/testdata/other/file/file.go: -------------------------------------------------------------------------------- 1 | // Test data - not compiled. 2 | 3 | package file 4 | 5 | func F() {} 6 | -------------------------------------------------------------------------------- /bysrc/vendor/go/build/testdata/other/main.go: -------------------------------------------------------------------------------- 1 | // Test data - not compiled. 2 | 3 | package main 4 | 5 | import ( 6 | "./file" 7 | ) 8 | 9 | func main() { 10 | file.F() 11 | } 12 | -------------------------------------------------------------------------------- /bysrc/vendor/go/build/testdata/withvendor/src/a/b/b.go: -------------------------------------------------------------------------------- 1 | package b 2 | 3 | import _ "c/d" 4 | -------------------------------------------------------------------------------- /bysrc/vendor/go/build/testdata/withvendor/src/a/vendor/c/d/d.go: -------------------------------------------------------------------------------- 1 | package d 2 | -------------------------------------------------------------------------------- /bysrc/vendor/go/build/zcgo.go: -------------------------------------------------------------------------------- 1 | // Code generated by go tool dist; DO NOT EDIT. 2 | 3 | package build 4 | 5 | const defaultCGO_ENABLED = "" 6 | 7 | var cgoEnabled = map[string]bool{ 8 | "aix/ppc64": true, 9 | "android/386": true, 10 | "android/amd64": true, 11 | "android/arm": true, 12 | "android/arm64": true, 13 | "darwin/amd64": true, 14 | "darwin/arm": true, 15 | "darwin/arm64": true, 16 | "dragonfly/amd64": true, 17 | "freebsd/386": true, 18 | "freebsd/amd64": true, 19 | "freebsd/arm": true, 20 | "illumos/amd64": true, 21 | "linux/386": true, 22 | "linux/amd64": true, 23 | "linux/arm": true, 24 | "linux/arm64": true, 25 | "linux/mips": true, 26 | "linux/mips64": true, 27 | "linux/mips64le": true, 28 | "linux/mipsle": true, 29 | "linux/ppc64le": true, 30 | "linux/riscv64": true, 31 | "linux/s390x": true, 32 | "linux/sparc64": true, 33 | "netbsd/386": true, 34 | "netbsd/amd64": true, 35 | "netbsd/arm": true, 36 | "netbsd/arm64": true, 37 | "openbsd/386": true, 38 | "openbsd/amd64": true, 39 | "openbsd/arm": true, 40 | "openbsd/arm64": true, 41 | "solaris/amd64": true, 42 | "windows/386": true, 43 | "windows/amd64": true, 44 | } 45 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2009 The Go Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | # Script to test heading detection heuristic 6 | headscan: headscan.go 7 | go build headscan.go 8 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/a.0.golden: -------------------------------------------------------------------------------- 1 | // comment 0 comment 1 2 | PACKAGE a 3 | 4 | IMPORTPATH 5 | testdata/a 6 | 7 | FILENAMES 8 | testdata/a0.go 9 | testdata/a1.go 10 | 11 | BUGS .Bugs is now deprecated, please use .Notes instead 12 | bug0 13 | 14 | bug1 15 | 16 | 17 | BUGS 18 | BUG(uid) bug0 19 | 20 | BUG(uid) bug1 21 | 22 | 23 | NOTES 24 | NOTE(uid) 25 | 26 | NOTE(foo) 1 of 4 - this is the first line of note 1 27 | - note 1 continues on this 2nd line 28 | - note 1 continues on this 3rd line 29 | 30 | NOTE(foo) 2 of 4 31 | 32 | NOTE(bar) 3 of 4 33 | 34 | NOTE(bar) 4 of 4 35 | - this is the last line of note 4 36 | 37 | NOTE(bam) This note which contains a (parenthesized) subphrase 38 | must appear in its entirety. 39 | 40 | NOTE(xxx) The ':' after the marker and uid is optional. 41 | 42 | 43 | SECBUGS 44 | SECBUG(uid) sec hole 0 45 | need to fix asap 46 | 47 | 48 | TODOS 49 | TODO(uid) todo0 50 | 51 | TODO(uid) todo1 52 | 53 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/a.1.golden: -------------------------------------------------------------------------------- 1 | // comment 0 comment 1 2 | PACKAGE a 3 | 4 | IMPORTPATH 5 | testdata/a 6 | 7 | FILENAMES 8 | testdata/a0.go 9 | testdata/a1.go 10 | 11 | BUGS .Bugs is now deprecated, please use .Notes instead 12 | bug0 13 | 14 | bug1 15 | 16 | 17 | BUGS 18 | BUG(uid) bug0 19 | 20 | BUG(uid) bug1 21 | 22 | 23 | NOTES 24 | NOTE(uid) 25 | 26 | NOTE(foo) 1 of 4 - this is the first line of note 1 27 | - note 1 continues on this 2nd line 28 | - note 1 continues on this 3rd line 29 | 30 | NOTE(foo) 2 of 4 31 | 32 | NOTE(bar) 3 of 4 33 | 34 | NOTE(bar) 4 of 4 35 | - this is the last line of note 4 36 | 37 | NOTE(bam) This note which contains a (parenthesized) subphrase 38 | must appear in its entirety. 39 | 40 | NOTE(xxx) The ':' after the marker and uid is optional. 41 | 42 | 43 | SECBUGS 44 | SECBUG(uid) sec hole 0 45 | need to fix asap 46 | 47 | 48 | TODOS 49 | TODO(uid) todo0 50 | 51 | TODO(uid) todo1 52 | 53 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/a.2.golden: -------------------------------------------------------------------------------- 1 | // comment 0 comment 1 2 | PACKAGE a 3 | 4 | IMPORTPATH 5 | testdata/a 6 | 7 | FILENAMES 8 | testdata/a0.go 9 | testdata/a1.go 10 | 11 | BUGS .Bugs is now deprecated, please use .Notes instead 12 | bug0 13 | 14 | bug1 15 | 16 | 17 | BUGS 18 | BUG(uid) bug0 19 | 20 | BUG(uid) bug1 21 | 22 | 23 | NOTES 24 | NOTE(uid) 25 | 26 | NOTE(foo) 1 of 4 - this is the first line of note 1 27 | - note 1 continues on this 2nd line 28 | - note 1 continues on this 3rd line 29 | 30 | NOTE(foo) 2 of 4 31 | 32 | NOTE(bar) 3 of 4 33 | 34 | NOTE(bar) 4 of 4 35 | - this is the last line of note 4 36 | 37 | NOTE(bam) This note which contains a (parenthesized) subphrase 38 | must appear in its entirety. 39 | 40 | NOTE(xxx) The ':' after the marker and uid is optional. 41 | 42 | 43 | SECBUGS 44 | SECBUG(uid) sec hole 0 45 | need to fix asap 46 | 47 | 48 | TODOS 49 | TODO(uid) todo0 50 | 51 | TODO(uid) todo1 52 | 53 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/a1.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // comment 1 6 | package a 7 | 8 | //BUG(uid): bug1 9 | 10 | //TODO(uid): todo1 11 | 12 | //TODO(): ignored 13 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/b.0.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE b 3 | 4 | IMPORTPATH 5 | testdata/b 6 | 7 | IMPORTS 8 | a 9 | 10 | FILENAMES 11 | testdata/b.go 12 | 13 | CONSTANTS 14 | // 15 | const ( 16 | C1 notExported = iota 17 | C2 18 | 19 | C4 20 | C5 21 | ) 22 | 23 | // 24 | const C notExported = 0 25 | 26 | // 27 | const Pi = 3.14 // Pi 28 | 29 | 30 | VARIABLES 31 | // 32 | var ( 33 | U1, U2, U4, U5 notExported 34 | 35 | U7 notExported = 7 36 | ) 37 | 38 | // 39 | var MaxInt int // MaxInt 40 | 41 | // 42 | var V notExported 43 | 44 | // 45 | var V1, V2, V4, V5 notExported 46 | 47 | 48 | FUNCTIONS 49 | // 50 | func F(x int) int 51 | 52 | // 53 | func F1() notExported 54 | 55 | // Always under the package functions list. 56 | func NotAFactory() int 57 | 58 | // Associated with uint type if AllDecls is set. 59 | func UintFactory() uint 60 | 61 | 62 | TYPES 63 | // 64 | type T struct{} // T 65 | 66 | // 67 | var V T // v 68 | 69 | // 70 | func (x *T) M() 71 | 72 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/b.2.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE b 3 | 4 | IMPORTPATH 5 | testdata/b 6 | 7 | IMPORTS 8 | a 9 | 10 | FILENAMES 11 | testdata/b.go 12 | 13 | CONSTANTS 14 | // 15 | const ( 16 | C1 notExported = iota 17 | C2 18 | 19 | C4 20 | C5 21 | ) 22 | 23 | // 24 | const C notExported = 0 25 | 26 | // 27 | const Pi = 3.14 // Pi 28 | 29 | 30 | VARIABLES 31 | // 32 | var ( 33 | U1, U2, U4, U5 notExported 34 | 35 | U7 notExported = 7 36 | ) 37 | 38 | // 39 | var MaxInt int // MaxInt 40 | 41 | // 42 | var V notExported 43 | 44 | // 45 | var V1, V2, V4, V5 notExported 46 | 47 | 48 | FUNCTIONS 49 | // 50 | func F(x int) int 51 | 52 | // 53 | func F1() notExported 54 | 55 | // Always under the package functions list. 56 | func NotAFactory() int 57 | 58 | // Associated with uint type if AllDecls is set. 59 | func UintFactory() uint 60 | 61 | 62 | TYPES 63 | // 64 | type T struct{} // T 65 | 66 | // 67 | var V T // v 68 | 69 | // 70 | func (x *T) M() 71 | 72 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/blank.0.golden: -------------------------------------------------------------------------------- 1 | // Package blank is a go/doc test for the handling of _. See issue ... 2 | PACKAGE blank 3 | 4 | IMPORTPATH 5 | testdata/blank 6 | 7 | IMPORTS 8 | os 9 | 10 | FILENAMES 11 | testdata/blank.go 12 | 13 | CONSTANTS 14 | // T constants counting from unexported constants. 15 | const ( 16 | C1 T 17 | C2 18 | 19 | C3 20 | 21 | C4 int 22 | ) 23 | 24 | // Constants with a single type that is not propagated. 25 | const ( 26 | Default = 0644 27 | Useless = 0312 28 | WideOpen = 0777 29 | ) 30 | 31 | // Constants with an imported type that is propagated. 32 | const ( 33 | M1 os.FileMode 34 | M2 35 | M3 36 | ) 37 | 38 | // Package constants. 39 | const ( 40 | I1 int 41 | I2 42 | ) 43 | 44 | 45 | TYPES 46 | // S has a padding field. 47 | type S struct { 48 | H uint32 49 | 50 | A uint8 51 | // contains filtered or unexported fields 52 | } 53 | 54 | // 55 | type T int 56 | 57 | // T constants counting from a blank constant. 58 | const ( 59 | T1 T 60 | T2 61 | ) 62 | 63 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/blank.2.golden: -------------------------------------------------------------------------------- 1 | // Package blank is a go/doc test for the handling of _. See issue ... 2 | PACKAGE blank 3 | 4 | IMPORTPATH 5 | testdata/blank 6 | 7 | IMPORTS 8 | os 9 | 10 | FILENAMES 11 | testdata/blank.go 12 | 13 | CONSTANTS 14 | // T constants counting from unexported constants. 15 | const ( 16 | C1 T 17 | C2 18 | 19 | C3 20 | 21 | C4 int 22 | ) 23 | 24 | // Constants with a single type that is not propagated. 25 | const ( 26 | Default = 0644 27 | Useless = 0312 28 | WideOpen = 0777 29 | ) 30 | 31 | // Constants with an imported type that is propagated. 32 | const ( 33 | M1 os.FileMode 34 | M2 35 | M3 36 | ) 37 | 38 | // Package constants. 39 | const ( 40 | I1 int 41 | I2 42 | ) 43 | 44 | 45 | TYPES 46 | // S has a padding field. 47 | type S struct { 48 | H uint32 49 | 50 | A uint8 51 | // contains filtered or unexported fields 52 | } 53 | 54 | // 55 | type T int 56 | 57 | // T constants counting from a blank constant. 58 | const ( 59 | T1 T 60 | T2 61 | ) 62 | 63 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/bugpara.0.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE bugpara 3 | 4 | IMPORTPATH 5 | testdata/bugpara 6 | 7 | FILENAMES 8 | testdata/bugpara.go 9 | 10 | BUGS .Bugs is now deprecated, please use .Notes instead 11 | Sometimes bugs have multiple paragraphs. 12 | 13 | Like this one. 14 | 15 | 16 | BUGS 17 | BUG(rsc) Sometimes bugs have multiple paragraphs. 18 | 19 | Like this one. 20 | 21 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/bugpara.1.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE bugpara 3 | 4 | IMPORTPATH 5 | testdata/bugpara 6 | 7 | FILENAMES 8 | testdata/bugpara.go 9 | 10 | BUGS .Bugs is now deprecated, please use .Notes instead 11 | Sometimes bugs have multiple paragraphs. 12 | 13 | Like this one. 14 | 15 | 16 | BUGS 17 | BUG(rsc) Sometimes bugs have multiple paragraphs. 18 | 19 | Like this one. 20 | 21 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/bugpara.2.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE bugpara 3 | 4 | IMPORTPATH 5 | testdata/bugpara 6 | 7 | FILENAMES 8 | testdata/bugpara.go 9 | 10 | BUGS .Bugs is now deprecated, please use .Notes instead 11 | Sometimes bugs have multiple paragraphs. 12 | 13 | Like this one. 14 | 15 | 16 | BUGS 17 | BUG(rsc) Sometimes bugs have multiple paragraphs. 18 | 19 | Like this one. 20 | 21 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/bugpara.go: -------------------------------------------------------------------------------- 1 | package bugpara 2 | 3 | // BUG(rsc): Sometimes bugs have multiple paragraphs. 4 | // 5 | // Like this one. 6 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/c.0.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE c 3 | 4 | IMPORTPATH 5 | testdata/c 6 | 7 | IMPORTS 8 | a 9 | 10 | FILENAMES 11 | testdata/c.go 12 | 13 | TYPES 14 | // A (should see this) 15 | type A struct{} 16 | 17 | // B (should see this) 18 | type B struct{} 19 | 20 | // C (should see this) 21 | type C struct{} 22 | 23 | // D (should see this) 24 | type D struct{} 25 | 26 | // E1 (should see this) 27 | type E1 struct{} 28 | 29 | // E (should see this for E2 and E3) 30 | type E2 struct{} 31 | 32 | // E (should see this for E2 and E3) 33 | type E3 struct{} 34 | 35 | // E4 (should see this) 36 | type E4 struct{} 37 | 38 | // 39 | type T1 struct{} 40 | 41 | // 42 | func (t1 *T1) M() 43 | 44 | // T2 must not show methods of local T1 45 | type T2 struct { 46 | a.T1 // not the same as locally declared T1 47 | } 48 | 49 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/c.1.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE c 3 | 4 | IMPORTPATH 5 | testdata/c 6 | 7 | IMPORTS 8 | a 9 | 10 | FILENAMES 11 | testdata/c.go 12 | 13 | TYPES 14 | // A (should see this) 15 | type A struct{} 16 | 17 | // B (should see this) 18 | type B struct{} 19 | 20 | // C (should see this) 21 | type C struct{} 22 | 23 | // D (should see this) 24 | type D struct{} 25 | 26 | // E1 (should see this) 27 | type E1 struct{} 28 | 29 | // E (should see this for E2 and E3) 30 | type E2 struct{} 31 | 32 | // E (should see this for E2 and E3) 33 | type E3 struct{} 34 | 35 | // E4 (should see this) 36 | type E4 struct{} 37 | 38 | // 39 | type T1 struct{} 40 | 41 | // 42 | func (t1 *T1) M() 43 | 44 | // T2 must not show methods of local T1 45 | type T2 struct { 46 | a.T1 // not the same as locally declared T1 47 | } 48 | 49 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/c.2.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE c 3 | 4 | IMPORTPATH 5 | testdata/c 6 | 7 | IMPORTS 8 | a 9 | 10 | FILENAMES 11 | testdata/c.go 12 | 13 | TYPES 14 | // A (should see this) 15 | type A struct{} 16 | 17 | // B (should see this) 18 | type B struct{} 19 | 20 | // C (should see this) 21 | type C struct{} 22 | 23 | // D (should see this) 24 | type D struct{} 25 | 26 | // E1 (should see this) 27 | type E1 struct{} 28 | 29 | // E (should see this for E2 and E3) 30 | type E2 struct{} 31 | 32 | // E (should see this for E2 and E3) 33 | type E3 struct{} 34 | 35 | // E4 (should see this) 36 | type E4 struct{} 37 | 38 | // 39 | type T1 struct{} 40 | 41 | // 42 | func (t1 *T1) M() 43 | 44 | // T2 must not show methods of local T1 45 | type T2 struct { 46 | a.T1 // not the same as locally declared T1 47 | } 48 | 49 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/d2.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Test cases for sort order of declarations. 6 | 7 | package d 8 | 9 | // C1 should be second. 10 | const C1 = 1 11 | 12 | // C0 should be first. 13 | const C0 = 0 14 | 15 | // V1 should be second. 16 | var V1 uint 17 | 18 | // V0 should be first. 19 | var V0 uintptr 20 | 21 | // CAx constants should appear after CBx constants. 22 | const ( 23 | CA2 = iota // before CA1 24 | CA1 // before CA0 25 | CA0 // at end 26 | ) 27 | 28 | // VAx variables should appear after VBx variables. 29 | var ( 30 | VA2 int // before VA1 31 | VA1 int // before VA0 32 | VA0 int // at end 33 | ) 34 | 35 | // T1 should be second. 36 | type T1 struct{} 37 | 38 | // T0 should be first. 39 | type T0 struct{} 40 | 41 | // F1 should be second. 42 | func F1() {} 43 | 44 | // F0 should be first. 45 | func F0() {} 46 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/error1.0.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE error1 3 | 4 | IMPORTPATH 5 | testdata/error1 6 | 7 | FILENAMES 8 | testdata/error1.go 9 | 10 | TYPES 11 | // 12 | type I0 interface { 13 | // When embedded, the predeclared error interface 14 | // must remain visible in interface types. 15 | error 16 | } 17 | 18 | // 19 | type S0 struct { 20 | // contains filtered or unexported fields 21 | } 22 | 23 | // 24 | type T0 struct { 25 | ExportedField interface { 26 | // error should be visible 27 | error 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/error1.1.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE error1 3 | 4 | IMPORTPATH 5 | testdata/error1 6 | 7 | FILENAMES 8 | testdata/error1.go 9 | 10 | TYPES 11 | // 12 | type I0 interface { 13 | // When embedded, the predeclared error interface 14 | // must remain visible in interface types. 15 | error 16 | } 17 | 18 | // 19 | type S0 struct { 20 | // In struct types, an embedded error must only be visible 21 | // if AllDecls is set. 22 | error 23 | } 24 | 25 | // 26 | type T0 struct { 27 | ExportedField interface { 28 | // error should be visible 29 | error 30 | } 31 | } 32 | 33 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/error1.2.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE error1 3 | 4 | IMPORTPATH 5 | testdata/error1 6 | 7 | FILENAMES 8 | testdata/error1.go 9 | 10 | TYPES 11 | // 12 | type I0 interface { 13 | // When embedded, the predeclared error interface 14 | // must remain visible in interface types. 15 | error 16 | } 17 | 18 | // 19 | type S0 struct { 20 | // contains filtered or unexported fields 21 | } 22 | 23 | // 24 | type T0 struct { 25 | ExportedField interface { 26 | // error should be visible 27 | error 28 | } 29 | } 30 | 31 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/error1.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package error1 6 | 7 | type I0 interface { 8 | // When embedded, the predeclared error interface 9 | // must remain visible in interface types. 10 | error 11 | } 12 | 13 | type T0 struct { 14 | ExportedField interface { 15 | // error should be visible 16 | error 17 | } 18 | } 19 | 20 | type S0 struct { 21 | // In struct types, an embedded error must only be visible 22 | // if AllDecls is set. 23 | error 24 | } 25 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/error2.0.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE error2 3 | 4 | IMPORTPATH 5 | testdata/error2 6 | 7 | FILENAMES 8 | testdata/error2.go 9 | 10 | TYPES 11 | // 12 | type I0 interface { 13 | // contains filtered or unexported methods 14 | } 15 | 16 | // 17 | type S0 struct { 18 | // contains filtered or unexported fields 19 | } 20 | 21 | // 22 | type T0 struct { 23 | ExportedField interface { 24 | // contains filtered or unexported methods 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/error2.1.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE error2 3 | 4 | IMPORTPATH 5 | testdata/error2 6 | 7 | FILENAMES 8 | testdata/error2.go 9 | 10 | TYPES 11 | // 12 | type I0 interface { 13 | // When embedded, the locally-declared error interface 14 | // is only visible if all declarations are shown. 15 | error 16 | } 17 | 18 | // 19 | type S0 struct { 20 | // In struct types, an embedded error must only be visible 21 | // if AllDecls is set. 22 | error 23 | } 24 | 25 | // 26 | type T0 struct { 27 | ExportedField interface { 28 | // error should not be visible 29 | error 30 | } 31 | } 32 | 33 | // This error declaration shadows the predeclared error type. 34 | type error interface { 35 | Error() string 36 | } 37 | 38 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/error2.2.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE error2 3 | 4 | IMPORTPATH 5 | testdata/error2 6 | 7 | FILENAMES 8 | testdata/error2.go 9 | 10 | TYPES 11 | // 12 | type I0 interface { 13 | // contains filtered or unexported methods 14 | } 15 | 16 | // 17 | type S0 struct { 18 | // contains filtered or unexported fields 19 | } 20 | 21 | // 22 | type T0 struct { 23 | ExportedField interface { 24 | // contains filtered or unexported methods 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/error2.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package error2 6 | 7 | type I0 interface { 8 | // When embedded, the locally-declared error interface 9 | // is only visible if all declarations are shown. 10 | error 11 | } 12 | 13 | type T0 struct { 14 | ExportedField interface { 15 | // error should not be visible 16 | error 17 | } 18 | } 19 | 20 | type S0 struct { 21 | // In struct types, an embedded error must only be visible 22 | // if AllDecls is set. 23 | error 24 | } 25 | 26 | // This error declaration shadows the predeclared error type. 27 | type error interface { 28 | Error() string 29 | } 30 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/f.0.golden: -------------------------------------------------------------------------------- 1 | // The package f is a go/doc test for functions and factory ... 2 | PACKAGE f 3 | 4 | IMPORTPATH 5 | testdata/f 6 | 7 | FILENAMES 8 | testdata/f.go 9 | 10 | FUNCTIONS 11 | // Exported must always be visible. Was issue 2824. 12 | func Exported() private 13 | 14 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/f.1.golden: -------------------------------------------------------------------------------- 1 | // The package f is a go/doc test for functions and factory ... 2 | PACKAGE f 3 | 4 | IMPORTPATH 5 | testdata/f 6 | 7 | FILENAMES 8 | testdata/f.go 9 | 10 | TYPES 11 | // 12 | type private struct{} 13 | 14 | // Exported must always be visible. Was issue 2824. 15 | func Exported() private 16 | 17 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/f.2.golden: -------------------------------------------------------------------------------- 1 | // The package f is a go/doc test for functions and factory ... 2 | PACKAGE f 3 | 4 | IMPORTPATH 5 | testdata/f 6 | 7 | FILENAMES 8 | testdata/f.go 9 | 10 | FUNCTIONS 11 | // Exported must always be visible. Was issue 2824. 12 | func Exported() private 13 | 14 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/f.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // The package f is a go/doc test for functions and factory methods. 6 | package f 7 | 8 | // ---------------------------------------------------------------------------- 9 | // Factory functions for non-exported types must not get lost. 10 | 11 | type private struct{} 12 | 13 | // Exported must always be visible. Was issue 2824. 14 | func Exported() private {} 15 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/g.0.golden: -------------------------------------------------------------------------------- 1 | // The package g is a go/doc test for mixed exported/unexported ... 2 | PACKAGE g 3 | 4 | IMPORTPATH 5 | testdata/g 6 | 7 | FILENAMES 8 | testdata/g.go 9 | 10 | CONSTANTS 11 | // 12 | const ( 13 | A, _ = iota, iota 14 | _, D 15 | E, _ 16 | G, H 17 | ) 18 | 19 | 20 | VARIABLES 21 | // 22 | var ( 23 | _, C2, _ = 1, 2, 3 24 | C4, _, C6 = 4, 5, 6 25 | _, C8, _ = 7, 8, 9 26 | ) 27 | 28 | // 29 | var ( 30 | _, X = f() 31 | ) 32 | 33 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/g.1.golden: -------------------------------------------------------------------------------- 1 | // The package g is a go/doc test for mixed exported/unexported ... 2 | PACKAGE g 3 | 4 | IMPORTPATH 5 | testdata/g 6 | 7 | FILENAMES 8 | testdata/g.go 9 | 10 | CONSTANTS 11 | // 12 | const ( 13 | A, b = iota, iota 14 | c, D 15 | E, f 16 | G, H 17 | ) 18 | 19 | 20 | VARIABLES 21 | // 22 | var ( 23 | c1, C2, c3 = 1, 2, 3 24 | C4, c5, C6 = 4, 5, 6 25 | c7, C8, c9 = 7, 8, 9 26 | xx, yy, zz = 0, 0, 0 // all unexported and hidden 27 | ) 28 | 29 | // 30 | var ( 31 | x, X = f() 32 | y, z = f() 33 | ) 34 | 35 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/g.2.golden: -------------------------------------------------------------------------------- 1 | // The package g is a go/doc test for mixed exported/unexported ... 2 | PACKAGE g 3 | 4 | IMPORTPATH 5 | testdata/g 6 | 7 | FILENAMES 8 | testdata/g.go 9 | 10 | CONSTANTS 11 | // 12 | const ( 13 | A, _ = iota, iota 14 | _, D 15 | E, _ 16 | G, H 17 | ) 18 | 19 | 20 | VARIABLES 21 | // 22 | var ( 23 | _, C2, _ = 1, 2, 3 24 | C4, _, C6 = 4, 5, 6 25 | _, C8, _ = 7, 8, 9 26 | ) 27 | 28 | // 29 | var ( 30 | _, X = f() 31 | ) 32 | 33 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/g.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // The package g is a go/doc test for mixed exported/unexported values. 6 | package g 7 | 8 | const ( 9 | A, b = iota, iota 10 | c, D 11 | E, f 12 | G, H 13 | ) 14 | 15 | var ( 16 | c1, C2, c3 = 1, 2, 3 17 | C4, c5, C6 = 4, 5, 6 18 | c7, C8, c9 = 7, 8, 9 19 | xx, yy, zz = 0, 0, 0 // all unexported and hidden 20 | ) 21 | 22 | var ( 23 | x, X = f() 24 | y, z = f() 25 | ) 26 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/issue13742.0.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE issue13742 3 | 4 | IMPORTPATH 5 | testdata/issue13742 6 | 7 | IMPORTS 8 | go/ast 9 | 10 | FILENAMES 11 | testdata/issue13742.go 12 | 13 | FUNCTIONS 14 | // Both F0 and G0 should appear as functions. 15 | func F0(Node) 16 | 17 | // Both F1 and G1 should appear as functions. 18 | func F1(ast.Node) 19 | 20 | // 21 | func G0() Node 22 | 23 | // 24 | func G1() ast.Node 25 | 26 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/issue13742.1.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE issue13742 3 | 4 | IMPORTPATH 5 | testdata/issue13742 6 | 7 | IMPORTS 8 | go/ast 9 | 10 | FILENAMES 11 | testdata/issue13742.go 12 | 13 | FUNCTIONS 14 | // Both F0 and G0 should appear as functions. 15 | func F0(Node) 16 | 17 | // Both F1 and G1 should appear as functions. 18 | func F1(ast.Node) 19 | 20 | // 21 | func G0() Node 22 | 23 | // 24 | func G1() ast.Node 25 | 26 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/issue13742.2.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE issue13742 3 | 4 | IMPORTPATH 5 | testdata/issue13742 6 | 7 | IMPORTS 8 | go/ast 9 | 10 | FILENAMES 11 | testdata/issue13742.go 12 | 13 | FUNCTIONS 14 | // Both F0 and G0 should appear as functions. 15 | func F0(Node) 16 | 17 | // Both F1 and G1 should appear as functions. 18 | func F1(ast.Node) 19 | 20 | // 21 | func G0() Node 22 | 23 | // 24 | func G1() ast.Node 25 | 26 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/issue13742.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package issue13742 6 | 7 | import ( 8 | "go/ast" 9 | . "go/ast" 10 | ) 11 | 12 | // Both F0 and G0 should appear as functions. 13 | func F0(Node) {} 14 | func G0() Node { return nil } 15 | 16 | // Both F1 and G1 should appear as functions. 17 | func F1(ast.Node) {} 18 | func G1() ast.Node { return nil } 19 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/issue16153.0.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE issue16153 3 | 4 | IMPORTPATH 5 | testdata/issue16153 6 | 7 | FILENAMES 8 | testdata/issue16153.go 9 | 10 | CONSTANTS 11 | // 12 | const ( 13 | X3 int64 = iota 14 | Y3 = 1 15 | ) 16 | 17 | // 18 | const ( 19 | X4 int64 = iota 20 | Y4 21 | ) 22 | 23 | // original test case 24 | const ( 25 | Y1 = 256 26 | ) 27 | 28 | // variations 29 | const ( 30 | Y2 uint8 31 | ) 32 | 33 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/issue16153.1.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE issue16153 3 | 4 | IMPORTPATH 5 | testdata/issue16153 6 | 7 | FILENAMES 8 | testdata/issue16153.go 9 | 10 | CONSTANTS 11 | // original test case 12 | const ( 13 | x1 uint8 = 255 14 | Y1 = 256 15 | ) 16 | 17 | // variations 18 | const ( 19 | x2 uint8 = 255 20 | Y2 21 | ) 22 | 23 | // 24 | const ( 25 | X3 int64 = iota 26 | Y3 = 1 27 | ) 28 | 29 | // 30 | const ( 31 | X4 int64 = iota 32 | Y4 33 | ) 34 | 35 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/issue16153.2.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE issue16153 3 | 4 | IMPORTPATH 5 | testdata/issue16153 6 | 7 | FILENAMES 8 | testdata/issue16153.go 9 | 10 | CONSTANTS 11 | // 12 | const ( 13 | X3 int64 = iota 14 | Y3 = 1 15 | ) 16 | 17 | // 18 | const ( 19 | X4 int64 = iota 20 | Y4 21 | ) 22 | 23 | // original test case 24 | const ( 25 | Y1 = 256 26 | ) 27 | 28 | // variations 29 | const ( 30 | Y2 uint8 31 | ) 32 | 33 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/issue16153.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package issue16153 6 | 7 | // original test case 8 | const ( 9 | x1 uint8 = 255 10 | Y1 = 256 11 | ) 12 | 13 | // variations 14 | const ( 15 | x2 uint8 = 255 16 | Y2 17 | ) 18 | 19 | const ( 20 | X3 int64 = iota 21 | Y3 = 1 22 | ) 23 | 24 | const ( 25 | X4 int64 = iota 26 | Y4 27 | ) 28 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/issue17788.0.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE issue17788 3 | 4 | IMPORTPATH 5 | testdata/issue17788 6 | 7 | FILENAMES 8 | testdata/issue17788.go 9 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/issue17788.1.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE issue17788 3 | 4 | IMPORTPATH 5 | testdata/issue17788 6 | 7 | FILENAMES 8 | testdata/issue17788.go 9 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/issue17788.2.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE issue17788 3 | 4 | IMPORTPATH 5 | testdata/issue17788 6 | 7 | FILENAMES 8 | testdata/issue17788.go 9 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/issue17788.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package issue17788 6 | 7 | func ( /* receiver type */ ) f0() { 8 | } 9 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/issue22856.0.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE issue22856 3 | 4 | IMPORTPATH 5 | testdata/issue22856 6 | 7 | FILENAMES 8 | testdata/issue22856.go 9 | 10 | FUNCTIONS 11 | // NewPointerSliceOfSlice is not a factory function because slices ... 12 | func NewPointerSliceOfSlice() [][]*T 13 | 14 | // NewSlice3 is not a factory function because 3 nested slices of ... 15 | func NewSlice3() [][][]T 16 | 17 | // NewSliceOfSlice is not a factory function because slices of a ... 18 | func NewSliceOfSlice() [][]T 19 | 20 | 21 | TYPES 22 | // 23 | type T struct{} 24 | 25 | // 26 | func New() T 27 | 28 | // 29 | func NewArray() [1]T 30 | 31 | // 32 | func NewPointer() *T 33 | 34 | // 35 | func NewPointerArray() [1]*T 36 | 37 | // 38 | func NewPointerOfPointer() **T 39 | 40 | // 41 | func NewPointerSlice() []*T 42 | 43 | // 44 | func NewSlice() []T 45 | 46 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/issue22856.1.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE issue22856 3 | 4 | IMPORTPATH 5 | testdata/issue22856 6 | 7 | FILENAMES 8 | testdata/issue22856.go 9 | 10 | FUNCTIONS 11 | // NewPointerSliceOfSlice is not a factory function because slices ... 12 | func NewPointerSliceOfSlice() [][]*T 13 | 14 | // NewSlice3 is not a factory function because 3 nested slices of ... 15 | func NewSlice3() [][][]T 16 | 17 | // NewSliceOfSlice is not a factory function because slices of a ... 18 | func NewSliceOfSlice() [][]T 19 | 20 | 21 | TYPES 22 | // 23 | type T struct{} 24 | 25 | // 26 | func New() T 27 | 28 | // 29 | func NewArray() [1]T 30 | 31 | // 32 | func NewPointer() *T 33 | 34 | // 35 | func NewPointerArray() [1]*T 36 | 37 | // 38 | func NewPointerOfPointer() **T 39 | 40 | // 41 | func NewPointerSlice() []*T 42 | 43 | // 44 | func NewSlice() []T 45 | 46 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/issue22856.2.golden: -------------------------------------------------------------------------------- 1 | // 2 | PACKAGE issue22856 3 | 4 | IMPORTPATH 5 | testdata/issue22856 6 | 7 | FILENAMES 8 | testdata/issue22856.go 9 | 10 | FUNCTIONS 11 | // NewPointerSliceOfSlice is not a factory function because slices ... 12 | func NewPointerSliceOfSlice() [][]*T 13 | 14 | // NewSlice3 is not a factory function because 3 nested slices of ... 15 | func NewSlice3() [][][]T 16 | 17 | // NewSliceOfSlice is not a factory function because slices of a ... 18 | func NewSliceOfSlice() [][]T 19 | 20 | 21 | TYPES 22 | // 23 | type T struct{} 24 | 25 | // 26 | func New() T 27 | 28 | // 29 | func NewArray() [1]T 30 | 31 | // 32 | func NewPointer() *T 33 | 34 | // 35 | func NewPointerArray() [1]*T 36 | 37 | // 38 | func NewPointerOfPointer() **T 39 | 40 | // 41 | func NewPointerSlice() []*T 42 | 43 | // 44 | func NewSlice() []T 45 | 46 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/predeclared.0.golden: -------------------------------------------------------------------------------- 1 | // Package predeclared is a go/doc test for handling of exported ... 2 | PACKAGE predeclared 3 | 4 | IMPORTPATH 5 | testdata/predeclared 6 | 7 | FILENAMES 8 | testdata/predeclared.go 9 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/predeclared.1.golden: -------------------------------------------------------------------------------- 1 | // Package predeclared is a go/doc test for handling of exported ... 2 | PACKAGE predeclared 3 | 4 | IMPORTPATH 5 | testdata/predeclared 6 | 7 | FILENAMES 8 | testdata/predeclared.go 9 | 10 | TYPES 11 | // 12 | type bool int 13 | 14 | // Must not be visible. 15 | func (b bool) String() string 16 | 17 | // 18 | type error struct{} 19 | 20 | // Must not be visible. 21 | func (e error) Error() string 22 | 23 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/predeclared.2.golden: -------------------------------------------------------------------------------- 1 | // Package predeclared is a go/doc test for handling of exported ... 2 | PACKAGE predeclared 3 | 4 | IMPORTPATH 5 | testdata/predeclared 6 | 7 | FILENAMES 8 | testdata/predeclared.go 9 | -------------------------------------------------------------------------------- /bysrc/vendor/go/doc/testdata/predeclared.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package predeclared is a go/doc test for handling of 6 | // exported methods on locally-defined predeclared types. 7 | // See issue 9860. 8 | package predeclared 9 | 10 | type error struct{} 11 | 12 | // Must not be visible. 13 | func (e error) Error() string { 14 | return "" 15 | } 16 | 17 | type bool int 18 | 19 | // Must not be visible. 20 | func (b bool) String() string { 21 | return "" 22 | } 23 | -------------------------------------------------------------------------------- /bysrc/vendor/go/format/example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package format_test 6 | 7 | import ( 8 | "bytes" 9 | "fmt" 10 | "go/format" 11 | "go/parser" 12 | "go/token" 13 | "log" 14 | ) 15 | 16 | func ExampleNode() { 17 | const expr = "(6+2*3)/4" 18 | 19 | // parser.ParseExpr parses the argument and returns the 20 | // corresponding ast.Node. 21 | node, err := parser.ParseExpr(expr) 22 | if err != nil { 23 | log.Fatal(err) 24 | } 25 | 26 | // Create a FileSet for node. Since the node does not come 27 | // from a real source file, fset will be empty. 28 | fset := token.NewFileSet() 29 | 30 | var buf bytes.Buffer 31 | err = format.Node(&buf, fset, node) 32 | if err != nil { 33 | log.Fatal(err) 34 | } 35 | 36 | fmt.Println(buf.String()) 37 | 38 | // Output: (6 + 2*3) / 4 39 | } 40 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/aliases.go: -------------------------------------------------------------------------------- 1 | package aliases 2 | 3 | type ( 4 | T0 [10]int 5 | T1 []byte 6 | T2 struct { 7 | x int 8 | } 9 | T3 interface { 10 | m() T2 11 | } 12 | T4 func(int, T0) chan T2 13 | ) 14 | 15 | // basic aliases 16 | type ( 17 | Ai = int 18 | A0 = T0 19 | A1 = T1 20 | A2 = T2 21 | A3 = T3 22 | A4 = T4 23 | 24 | A10 = [10]int 25 | A11 = []byte 26 | A12 = struct { 27 | x int 28 | } 29 | A13 = interface { 30 | m() A2 31 | } 32 | A14 = func(int, A0) chan A2 33 | ) 34 | 35 | // alias receiver types 36 | func (T0) m1() {} 37 | func (A0) m2() {} 38 | 39 | // alias receiver types (long type declaration chains) 40 | type ( 41 | V0 = V1 42 | V1 = (V2) 43 | V2 = (V3) 44 | V3 = T0 45 | ) 46 | 47 | func (V1) n() {} 48 | 49 | // cycles 50 | type C0 struct { 51 | f1 C1 52 | f2 C2 53 | } 54 | 55 | type ( 56 | C1 *C0 57 | C2 = C1 58 | ) 59 | 60 | type ( 61 | C5 struct { 62 | f *C6 63 | } 64 | C6 = C5 65 | ) 66 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/complexnums.go: -------------------------------------------------------------------------------- 1 | package complexnums 2 | 3 | const NN = -1 - 1i 4 | const NP = -1 + 1i 5 | const PN = 1 - 1i 6 | const PP = 1 + 1i 7 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/complexnums.gox: -------------------------------------------------------------------------------- 1 | v1; 2 | package complexnums; 3 | pkgpath complexnums; 4 | priority 1; 5 | const NN = -0.1E1-0.1E1i ; 6 | const NP = -0.1E1+0.1E1i ; 7 | const PN = 0.1E1-0.1E1i ; 8 | const PP = 0.1E1+0.1E1i ; 9 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/conversions.go: -------------------------------------------------------------------------------- 1 | package conversions 2 | 3 | type Units string 4 | 5 | const Bits = Units("bits") 6 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/conversions.gox: -------------------------------------------------------------------------------- 1 | v2; 2 | package conversions; 3 | prefix go; 4 | package conversions go.conversions go.conversions; 5 | const Bits > = convert(, "bits"); 6 | type ; 7 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/escapeinfo.go: -------------------------------------------------------------------------------- 1 | // Test case for escape info in export data. To compile and extract .gox file: 2 | // gccgo -fgo-optimize-allocs -c escapeinfo.go 3 | // objcopy -j .go_export escapeinfo.o escapeinfo.gox 4 | 5 | package escapeinfo 6 | 7 | type T struct{ data []byte } 8 | 9 | func NewT(data []byte) *T { 10 | return &T{data} 11 | } 12 | 13 | func (*T) Read(p []byte) {} 14 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/escapeinfo.gox: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitech/cygo/00df926d11520643c19f0cf867d9a0870b72374b/bysrc/vendor/go/internal/gccgoimporter/testdata/escapeinfo.gox -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/imports.go: -------------------------------------------------------------------------------- 1 | package imports 2 | 3 | import "fmt" 4 | 5 | var Hello = fmt.Sprintf("Hello, world") 6 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/imports.gox: -------------------------------------------------------------------------------- 1 | v1; 2 | package imports; 3 | pkgpath imports; 4 | priority 7; 5 | import fmt fmt "fmt"; 6 | init imports imports..import 7 math math..import 1 runtime runtime..import 1 strconv strconv..import 2 io io..import 3 reflect reflect..import 3 syscall syscall..import 3 time time..import 4 os os..import 5 fmt fmt..import 6; 7 | var Hello ; 8 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/issue27856.go: -------------------------------------------------------------------------------- 1 | package lib 2 | 3 | type M struct { 4 | E E 5 | } 6 | type F struct { 7 | _ *M 8 | } 9 | type E = F 10 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/issue27856.gox: -------------------------------------------------------------------------------- 1 | v2; 2 | package main; 3 | pkgpath main; 4 | import runtime runtime "runtime"; 5 | init runtime runtime..import sys runtime_internal_sys..import; 6 | init_graph 0 1; 7 | type ; }>>>; }>>>; 8 | type ; 9 | type ; 10 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/issue29198.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package server 6 | 7 | import ( 8 | "context" 9 | "errors" 10 | ) 11 | 12 | type A struct { 13 | x int 14 | } 15 | 16 | func (a *A) AMethod(y int) *Server { 17 | return nil 18 | } 19 | 20 | // FooServer is a server that provides Foo services 21 | type FooServer Server 22 | 23 | func (f *FooServer) WriteEvents(ctx context.Context, x int) error { 24 | return errors.New("hey!") 25 | } 26 | 27 | type Server struct { 28 | FooServer *FooServer 29 | user string 30 | ctx context.Context 31 | } 32 | 33 | func New(sctx context.Context, u string) (*Server, error) { 34 | s := &Server{user: u, ctx: sctx} 35 | s.FooServer = (*FooServer)(s) 36 | return s, nil 37 | } 38 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/issue30628.go: -------------------------------------------------------------------------------- 1 | package issue30628 2 | 3 | import ( 4 | "os" 5 | "sync" 6 | ) 7 | 8 | const numR = int32(os.O_TRUNC + 5) 9 | 10 | type Apple struct { 11 | hey sync.RWMutex 12 | x int 13 | RQ [numR]struct { 14 | Count uintptr 15 | NumBytes uintptr 16 | Last uintptr 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/issue31540.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package issue31540 6 | 7 | type Y struct { 8 | q int 9 | } 10 | 11 | type Z map[int]int 12 | 13 | type X = map[Y]Z 14 | 15 | type A1 = X 16 | 17 | type A2 = A1 18 | 19 | type S struct { 20 | b int 21 | A2 22 | } 23 | 24 | func Hallo() S { 25 | return S{} 26 | } 27 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/issue31540.gox: -------------------------------------------------------------------------------- 1 | v3; 2 | package issue31540 3 | pkgpath issue31540 4 | types 11 7 23 23 20 22 20 21 57 31 45 36 5 | type 1 "A1" = 6 | type 2 "A2" = 7 | type 3 "S" 8 | type 4 "X" = 9 | type 5 "Y" 10 | type 6 "Z" 11 | type 7 struct { .go.mapalias.b ; ? ; } 12 | type 8 map [] 13 | type 9 struct { .go.mapalias.q ; } 14 | type 10 map [] 15 | func Hallo () 16 | checksum C3FAF2524A90BC11225EE65D059BF27DFB69134B 17 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/libimportsar.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitech/cygo/00df926d11520643c19f0cf867d9a0870b72374b/bysrc/vendor/go/internal/gccgoimporter/testdata/libimportsar.a -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/nointerface.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package nointerface 6 | 7 | type I int 8 | 9 | //go:nointerface 10 | func (p *I) Get() int { return int(*p) } 11 | 12 | func (p *I) Set(v int) { *p = I(v) } 13 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/nointerface.gox: -------------------------------------------------------------------------------- 1 | v3; 2 | package nointerface 3 | pkgpath nointerface 4 | types 3 2 133 17 5 | type 1 "I" 6 | func /*nointerface*/ (p ) Get () 7 | func (p ) Set (v ) 8 | type 2 * 9 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/pointer.go: -------------------------------------------------------------------------------- 1 | package pointer 2 | 3 | type Int8Ptr *int8 4 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/pointer.gox: -------------------------------------------------------------------------------- 1 | v1; 2 | package pointer; 3 | pkgpath pointer; 4 | type >>; 5 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/time.gox: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitech/cygo/00df926d11520643c19f0cf867d9a0870b72374b/bysrc/vendor/go/internal/gccgoimporter/testdata/time.gox -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/unicode.gox: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitech/cygo/00df926d11520643c19f0cf867d9a0870b72374b/bysrc/vendor/go/internal/gccgoimporter/testdata/unicode.gox -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gccgoimporter/testdata/v1reflect.gox: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitech/cygo/00df926d11520643c19f0cf867d9a0870b72374b/bysrc/vendor/go/internal/gccgoimporter/testdata/v1reflect.gox -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gcimporter/testdata/a.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Input for TestIssue13566 6 | 7 | package a 8 | 9 | import "encoding/json" 10 | 11 | type A struct { 12 | a *A 13 | json json.RawMessage 14 | } 15 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gcimporter/testdata/b.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Input for TestIssue13566 6 | 7 | package b 8 | 9 | import "./a" 10 | 11 | type A a.A 12 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gcimporter/testdata/issue15920.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package p 6 | 7 | // The underlying type of Error is the underlying type of error. 8 | // Make sure we can import this again without problems. 9 | type Error error 10 | 11 | func F() Error { return nil } 12 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gcimporter/testdata/issue20046.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package p 6 | 7 | var V interface { 8 | M() 9 | } 10 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gcimporter/testdata/issue25301.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package issue25301 6 | 7 | type ( 8 | A = interface { 9 | M() 10 | } 11 | T interface { 12 | A 13 | } 14 | S struct{} 15 | ) 16 | 17 | func (S) M() { println("m") } 18 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gcimporter/testdata/issue25596.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package issue25596 6 | 7 | type E interface { 8 | M() T 9 | } 10 | 11 | type T interface { 12 | E 13 | } 14 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gcimporter/testdata/p.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Input for TestIssue15517 6 | 7 | package p 8 | 9 | const C = 0 10 | 11 | var V int 12 | 13 | func F() {} 14 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gcimporter/testdata/versions/test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // To create a test case for a new export format version, 6 | // build this package with the latest compiler and store 7 | // the resulting .a file appropriately named in the versions 8 | // directory. The VersionHandling test will pick it up. 9 | // 10 | // In the testdata/versions: 11 | // 12 | // go build -o test_go1.$X_$Y.a test.go 13 | // 14 | // with $X = Go version and $Y = export format version 15 | // (add 'b' or 'i' to distinguish between binary and 16 | // indexed format starting with 1.11 as long as both 17 | // formats are supported). 18 | // 19 | // Make sure this source is extended such that it exercises 20 | // whatever export format change has taken place. 21 | 22 | package test 23 | 24 | // Any release before and including Go 1.7 didn't encode 25 | // the package for a blank struct field. 26 | type BlankField struct { 27 | _ int 28 | } 29 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gcimporter/testdata/versions/test_go1.11_0i.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitech/cygo/00df926d11520643c19f0cf867d9a0870b72374b/bysrc/vendor/go/internal/gcimporter/testdata/versions/test_go1.11_0i.a -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gcimporter/testdata/versions/test_go1.11_6b.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitech/cygo/00df926d11520643c19f0cf867d9a0870b72374b/bysrc/vendor/go/internal/gcimporter/testdata/versions/test_go1.11_6b.a -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gcimporter/testdata/versions/test_go1.11_999i.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitech/cygo/00df926d11520643c19f0cf867d9a0870b72374b/bysrc/vendor/go/internal/gcimporter/testdata/versions/test_go1.11_999i.a -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gcimporter/testdata/versions/test_go1.7_0.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitech/cygo/00df926d11520643c19f0cf867d9a0870b72374b/bysrc/vendor/go/internal/gcimporter/testdata/versions/test_go1.7_0.a -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gcimporter/testdata/versions/test_go1.7_1.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitech/cygo/00df926d11520643c19f0cf867d9a0870b72374b/bysrc/vendor/go/internal/gcimporter/testdata/versions/test_go1.7_1.a -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gcimporter/testdata/versions/test_go1.8_4.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitech/cygo/00df926d11520643c19f0cf867d9a0870b72374b/bysrc/vendor/go/internal/gcimporter/testdata/versions/test_go1.8_4.a -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/gcimporter/testdata/versions/test_go1.8_5.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitech/cygo/00df926d11520643c19f0cf867d9a0870b72374b/bysrc/vendor/go/internal/gcimporter/testdata/versions/test_go1.8_5.a -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/srcimporter/testdata/issue20855/issue20855.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package issue20855 6 | 7 | func init() // "missing function body" is a soft error 8 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/srcimporter/testdata/issue23092/issue23092.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package issue23092 6 | -------------------------------------------------------------------------------- /bysrc/vendor/go/internal/srcimporter/testdata/issue24392/issue24392.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package issue24392 6 | -------------------------------------------------------------------------------- /bysrc/vendor/go/parser/example_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package parser_test 6 | 7 | import ( 8 | "fmt" 9 | "go/parser" 10 | "go/token" 11 | ) 12 | 13 | func ExampleParseFile() { 14 | fset := token.NewFileSet() // positions are relative to fset 15 | 16 | src := `package foo 17 | 18 | import ( 19 | "fmt" 20 | "time" 21 | ) 22 | 23 | func bar() { 24 | fmt.Println(time.Now()) 25 | }` 26 | 27 | // Parse src but stop after processing the imports. 28 | f, err := parser.ParseFile(fset, "", src, parser.ImportsOnly) 29 | if err != nil { 30 | fmt.Println(err) 31 | return 32 | } 33 | 34 | // Print the imports from the file's AST. 35 | for _, s := range f.Imports { 36 | fmt.Println(s.Path.Value) 37 | } 38 | 39 | // output: 40 | // 41 | // "fmt" 42 | // "time" 43 | } 44 | -------------------------------------------------------------------------------- /bysrc/vendor/go/parser/performance_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package parser 6 | 7 | import ( 8 | "go/token" 9 | "io/ioutil" 10 | "testing" 11 | ) 12 | 13 | var src = readFile("parser.go") 14 | 15 | func readFile(filename string) []byte { 16 | data, err := ioutil.ReadFile(filename) 17 | if err != nil { 18 | panic(err) 19 | } 20 | return data 21 | } 22 | 23 | func BenchmarkParse(b *testing.B) { 24 | b.SetBytes(int64(len(src))) 25 | for i := 0; i < b.N; i++ { 26 | if _, err := ParseFile(token.NewFileSet(), "", src, ParseComments); err != nil { 27 | b.Fatalf("benchmark failed due to parse error: %s", err) 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /bysrc/vendor/go/parser/testdata/commas.src: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Test case for error messages/parser synchronization 6 | // after missing commas. 7 | 8 | package p 9 | 10 | var _ = []int{ 11 | 0/* ERROR HERE "missing ','" */ 12 | } 13 | 14 | var _ = []int{ 15 | 0, 16 | 1, 17 | 2, 18 | 3/* ERROR HERE "missing ','" */ 19 | } 20 | -------------------------------------------------------------------------------- /bysrc/vendor/go/parser/testdata/issue11377.src: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Test case for issue 11377: Better synchronization of 6 | // parser after certain syntax errors. 7 | 8 | package p 9 | 10 | func bad1() { 11 | if f()) /* ERROR "expected ';', found '\)'" */ { 12 | return 13 | } 14 | } 15 | 16 | // There shouldn't be any errors down below. 17 | 18 | func F1() {} 19 | func F2() {} 20 | func F3() {} 21 | func F4() {} 22 | func F5() {} 23 | func F6() {} 24 | func F7() {} 25 | func F8() {} 26 | func F9() {} 27 | func F10() {} 28 | -------------------------------------------------------------------------------- /bysrc/vendor/go/parser/testdata/issue23434.src: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Test case for issue 23434: Better synchronization of 6 | // parser after missing type. There should be exactly 7 | // one error each time, with now follow errors. 8 | 9 | package p 10 | 11 | func g() { 12 | m := make(map[string]! /* ERROR "expected type, found '!'" */ ) 13 | for { 14 | x := 1 15 | print(x) 16 | } 17 | } 18 | 19 | func f() { 20 | m := make(map[string]) /* ERROR "expected type, found '\)'" */ 21 | for { 22 | x := 1 23 | print(x) 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /bysrc/vendor/go/parser/testdata/issue3106.src: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Test case for issue 3106: Better synchronization of 6 | // parser after certain syntax errors. 7 | 8 | package main 9 | 10 | func f() { 11 | var m Mutex 12 | c := MakeCond(&m) 13 | percent := 0 14 | const step = 10 15 | for i := 0; i < 5; i++ { 16 | go func() { 17 | for { 18 | // Emulates some useful work. 19 | time.Sleep(1e8) 20 | m.Lock() 21 | defer 22 | if /* ERROR "expected ';', found 'if'" */ percent == 100 { 23 | m.Unlock() 24 | break 25 | } 26 | percent++ 27 | if percent % step == 0 { 28 | //c.Signal() 29 | } 30 | m.Unlock() 31 | } 32 | }() 33 | } 34 | for { 35 | m.Lock() 36 | if percent == 0 || percent % step != 0 { 37 | c.Wait() 38 | } 39 | fmt.Print(",") 40 | if percent == 100 { 41 | m.Unlock() 42 | break 43 | } 44 | m.Unlock() 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /bysrc/vendor/go/printer/testdata/empty.golden: -------------------------------------------------------------------------------- 1 | // a comment at the beginning of the file 2 | 3 | package empty 4 | 5 | // a comment at the end of the file 6 | -------------------------------------------------------------------------------- /bysrc/vendor/go/printer/testdata/empty.input: -------------------------------------------------------------------------------- 1 | // a comment at the beginning of the file 2 | 3 | package empty 4 | 5 | // a comment at the end of the file 6 | -------------------------------------------------------------------------------- /bysrc/vendor/go/token/token_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package token 6 | 7 | import "testing" 8 | 9 | func TestIsIdentifier(t *testing.T) { 10 | tests := []struct { 11 | name string 12 | in string 13 | want bool 14 | }{ 15 | {"Empty", "", false}, 16 | {"Space", " ", false}, 17 | {"SpaceSuffix", "foo ", false}, 18 | {"Number", "123", false}, 19 | {"Keyword", "func", false}, 20 | 21 | {"LettersASCII", "foo", true}, 22 | {"MixedASCII", "_bar123", true}, 23 | {"UppercaseKeyword", "Func", true}, 24 | {"LettersUnicode", "fóö", true}, 25 | } 26 | for _, test := range tests { 27 | t.Run(test.name, func(t *testing.T) { 28 | if got := IsIdentifier(test.in); got != test.want { 29 | t.Fatalf("IsIdentifier(%q) = %t, want %v", test.in, got, test.want) 30 | } 31 | }) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /bysrc/vendor/go/types/objset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file implements objsets. 6 | // 7 | // An objset is similar to a Scope but objset elements 8 | // are identified by their unique id, instead of their 9 | // object name. 10 | 11 | package types 12 | 13 | // An objset is a set of objects identified by their unique id. 14 | // The zero value for objset is a ready-to-use empty objset. 15 | type objset map[string]Object // initialized lazily 16 | 17 | // insert attempts to insert an object obj into objset s. 18 | // If s already contains an alternative object alt with 19 | // the same name, insert leaves s unchanged and returns alt. 20 | // Otherwise it inserts obj and returns nil. 21 | func (s *objset) insert(obj Object) Object { 22 | id := obj.Id() 23 | if alt := (*s)[id]; alt != nil { 24 | return alt 25 | } 26 | if *s == nil { 27 | *s = make(map[string]Object) 28 | } 29 | (*s)[id] = obj 30 | return nil 31 | } 32 | -------------------------------------------------------------------------------- /bysrc/vendor/go/types/testdata/blank.src: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package _ /* ERROR invalid package name */ 6 | -------------------------------------------------------------------------------- /bysrc/vendor/go/types/testdata/cycles3.src: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package p 6 | 7 | import "unsafe" 8 | 9 | var ( 10 | _ A = A(nil).a().b().c().d().e().f() 11 | _ A = A(nil).b().c().d().e().f() 12 | _ A = A(nil).c().d().e().f() 13 | _ A = A(nil).d().e().f() 14 | _ A = A(nil).e().f() 15 | _ A = A(nil).f() 16 | _ A = A(nil) 17 | ) 18 | 19 | type ( 20 | A interface { 21 | a() B 22 | B 23 | } 24 | 25 | B interface { 26 | b() C 27 | C 28 | } 29 | 30 | C interface { 31 | c() D 32 | D 33 | } 34 | 35 | D interface { 36 | d() E 37 | E 38 | } 39 | 40 | E interface { 41 | e() F 42 | F 43 | } 44 | 45 | F interface { 46 | f() A 47 | } 48 | ) 49 | 50 | type ( 51 | U /* ERROR cycle */ interface { 52 | V 53 | } 54 | 55 | V interface { 56 | v() [unsafe.Sizeof(u)]int 57 | } 58 | ) 59 | 60 | var u U 61 | -------------------------------------------------------------------------------- /bysrc/vendor/go/types/testdata/decls5.src: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | // declarations of main 8 | const _, main /* ERROR "cannot declare main" */ , _ = 0, 1, 2 9 | type main /* ERROR "cannot declare main" */ struct{} 10 | var _, main /* ERROR "cannot declare main" */ int 11 | -------------------------------------------------------------------------------- /bysrc/vendor/go/types/testdata/importdecl1a.src: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Test case for issue 8969. 6 | 7 | package importdecl1 8 | 9 | import "go/ast" 10 | import . "unsafe" 11 | 12 | var _ Pointer // use dot-imported package unsafe 13 | 14 | // Test cases for issue 23914. 15 | 16 | type A interface { 17 | // Methods m1, m2 must be type-checked in this file scope 18 | // even when embedded in an interface in a different 19 | // file of the same package. 20 | m1() ast.Node 21 | m2() Pointer 22 | } 23 | -------------------------------------------------------------------------------- /bysrc/vendor/go/types/testdata/importdecl1b.src: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package importdecl1 6 | 7 | import . /* ERROR "imported but not used" */ "unsafe" 8 | 9 | type B interface { 10 | A 11 | } 12 | -------------------------------------------------------------------------------- /bysrc/vendor/go/types/testdata/issue23203a.src: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import "unsafe" 8 | 9 | type T struct{} 10 | 11 | func (T) m1() {} 12 | func (T) m2([unsafe.Sizeof(T.m1)]int) {} 13 | 14 | func main() {} 15 | -------------------------------------------------------------------------------- /bysrc/vendor/go/types/testdata/issue23203b.src: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import "unsafe" 8 | 9 | type T struct{} 10 | 11 | func (T) m2([unsafe.Sizeof(T.m1)]int) {} 12 | func (T) m1() {} 13 | 14 | func main() {} 15 | -------------------------------------------------------------------------------- /bysrc/vendor/go/types/testdata/issue25008a.src: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package p 6 | 7 | import "io" 8 | 9 | type A interface { 10 | io.Reader 11 | } 12 | 13 | func f(a A) { 14 | a.Read(nil) 15 | } 16 | -------------------------------------------------------------------------------- /bysrc/vendor/go/types/testdata/issue25008b.src: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package p 6 | 7 | type B interface { 8 | A 9 | } 10 | -------------------------------------------------------------------------------- /bysrc/vendor/go/types/testdata/issue26390.src: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package issue26390 6 | 7 | type A = T 8 | 9 | func (t *T) m() *A { return t } 10 | 11 | type T struct{} 12 | -------------------------------------------------------------------------------- /bysrc/vendor/golang.org/x/tools/go/ast/astutil/util.go: -------------------------------------------------------------------------------- 1 | package astutil 2 | 3 | import "go/ast" 4 | 5 | // Unparen returns e with any enclosing parentheses stripped. 6 | func Unparen(e ast.Expr) ast.Expr { 7 | for { 8 | p, ok := e.(*ast.ParenExpr) 9 | if !ok { 10 | return e 11 | } 12 | e = p.X 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /bysrc/vendor/internal/goroot/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | package goroot 8 | 9 | import ( 10 | "os" 11 | "path/filepath" 12 | ) 13 | 14 | // IsStandardPackage reports whether path is a standard package, 15 | // given goroot and compiler. 16 | func IsStandardPackage(goroot, compiler, path string) bool { 17 | switch compiler { 18 | case "gc": 19 | dir := filepath.Join(goroot, "src", path) 20 | _, err := os.Stat(dir) 21 | return err == nil 22 | case "gccgo": 23 | return stdpkg[path] 24 | default: 25 | panic("unknown compiler " + compiler) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /bysrc/vendor/internal/goversion/goversion.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package goversion 6 | 7 | // Version is the current Go 1.x version. During development cycles on 8 | // the master branch it changes to be the version of the next Go 1.x 9 | // release. 10 | // 11 | // When incrementing this, also add to the list at src/go/build/doc.go 12 | // (search for "onward"). 13 | const Version = 13 14 | -------------------------------------------------------------------------------- /bysrc/vendor/internal/xcoff/testdata/bigar-empty: -------------------------------------------------------------------------------- 1 | 2 | 0 0 0 0 0 0 -------------------------------------------------------------------------------- /bysrc/vendor/internal/xcoff/testdata/bigar-ppc64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitech/cygo/00df926d11520643c19f0cf867d9a0870b72374b/bysrc/vendor/internal/xcoff/testdata/bigar-ppc64 -------------------------------------------------------------------------------- /bysrc/vendor/internal/xcoff/testdata/gcc-ppc32-aix-dwarf2-exec: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitech/cygo/00df926d11520643c19f0cf867d9a0870b72374b/bysrc/vendor/internal/xcoff/testdata/gcc-ppc32-aix-dwarf2-exec -------------------------------------------------------------------------------- /bysrc/vendor/internal/xcoff/testdata/gcc-ppc64-aix-dwarf2-exec: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kitech/cygo/00df926d11520643c19f0cf867d9a0870b72374b/bysrc/vendor/internal/xcoff/testdata/gcc-ppc64-aix-dwarf2-exec -------------------------------------------------------------------------------- /bysrc/vendor/internal/xcoff/testdata/hello.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void 4 | main(int argc, char *argv[]) 5 | { 6 | printf("hello, world\n"); 7 | } 8 | -------------------------------------------------------------------------------- /bysrc/vendor/internal/xcoff/testdata/printbye.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void printbye(){ 4 | printf("Goodbye\n"); 5 | } 6 | -------------------------------------------------------------------------------- /bysrc/vendor/internal/xcoff/testdata/printhello.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | void printhello(){ 4 | printf("Helloworld\n"); 5 | } 6 | -------------------------------------------------------------------------------- /corona-c/corona.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _CORONA_H_ 3 | #define _CORONA_H_ 4 | 5 | 6 | typedef struct corona corona; 7 | 8 | corona* crn_get(); 9 | corona* crn_new(); 10 | void crn_init(corona* nr); 11 | void crn_destroy(corona* lnr); 12 | void crn_wait_init_done(corona* nr); 13 | corona* crn_init_and_wait_done(); 14 | // 在crn_init*之前调用,设置线程创建成功回调通知,做线程初始化 15 | void* crn_set_thread_createcb(void(*fn)(void*arg), void* arg); 16 | 17 | int crn_post(void(*fn)(void*arg), void*arg); 18 | void crn_sched(); 19 | int crn_num_fibers(); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /corona-c/coronagc.h: -------------------------------------------------------------------------------- 1 | #ifndef _NORO_GC_H_ 2 | #define _NORO_GC_H_ 3 | 4 | #define USE_BDWGC 5 | 6 | #ifdef USE_BDWGC 7 | 8 | #include 9 | extern void GC_push_all_eager(void*, void*); 10 | extern void GC_set_push_other_roots(void*); 11 | 12 | const char* crn_gc_event_name(GC_EventType evty); 13 | void crn_gc_set_nprocs(int n); 14 | 15 | void* crn_gc_malloc(size_t size); 16 | void* crn_gc_realloc(void* ptr, size_t size); 17 | void crn_gc_free(void* ptr); 18 | void crn_gc_free_uncollectable(void* ptr); 19 | void* crn_gc_calloc(size_t n, size_t size); 20 | void* crn_gc_malloc_uncollectable(size_t size); 21 | void crn_set_finalizer(void* ptr, void(*fn)(void* ptr)); 22 | void crn_call_with_alloc_lock(void*(*fnptr)(void* arg1), void* arg); 23 | 24 | #endif 25 | 26 | void* crn_raw_malloc(size_t size); 27 | /* void* crn_raw_realloc(void* ptr, size_t size); */ 28 | void crn_raw_free(void* ptr); 29 | /* void* crn_raw_calloc(size_t n, size_t size); */ 30 | 31 | #define crn_malloc_st(/*typedesc*/st) (st*)crn_gc_malloc(sizeof(st)) 32 | #define convto(/*typedesc*/ st, /*var*/ var) (st*)(var) 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /corona-c/crnpub.h: -------------------------------------------------------------------------------- 1 | #ifndef _CRN_PUB_H_ 2 | #define _CRN_PUB_H_ 3 | 4 | typedef struct corona corona; 5 | 6 | typedef struct crn_inner_stats { 7 | int mch_totcnt; 8 | int mch_actcnt; 9 | int fiber_totcnt; 10 | int fiber_actcnt; 11 | int fiber_totmem; 12 | int maxstksz; 13 | } crn_inner_stats; 14 | 15 | corona* crn_init_and_wait_done(); 16 | 17 | extern int crn_goid(); 18 | extern int crn_post(void(*fn)(void*arg), void*arg); 19 | extern void crn_sched(); 20 | 21 | extern void crn_lock_osthread(); 22 | extern void crn_get_stats(crn_inner_stats* st); 23 | 24 | #endif 25 | 26 | -------------------------------------------------------------------------------- /corona-c/hchan.h: -------------------------------------------------------------------------------- 1 | #ifndef _HCHAN_H_ 2 | #define _HCHAN_H_ 3 | 4 | #include 5 | // #include 6 | 7 | // typedef struct hchan hchan; 8 | 9 | typedef struct hchan { 10 | chan_t* c; 11 | int cap; 12 | pmutex_t lock; 13 | szqueue_t* recvq; // fiber* 14 | szqueue_t* sendq; // fiber* 15 | int closed; 16 | } hchan; 17 | 18 | typedef struct hcdata { 19 | int grid; 20 | int mcid; 21 | fiber* gr; 22 | void* sdelem; 23 | void** rvelem; 24 | int wokeby_grid; 25 | int wokeby_mcid; 26 | int wokecase; // caseSend/caseRecv 27 | fiber* wokeby; // 28 | void* wokehc; // hchan* 29 | } hcdata; 30 | 31 | int hchan_is_closed(hchan* hc); 32 | int hchan_cap(hchan* hc); 33 | int hchan_len(hchan* hc); 34 | 35 | hcdata* hcdata_new(fiber* gr); 36 | void hcdata_free(hcdata* d); 37 | 38 | typedef struct scase scase; 39 | scase* scase_new(hchan* hc, uint16_t kind, void* elem); 40 | void scase_free(scase* cas); 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /corona-c/hook2.h: -------------------------------------------------------------------------------- 1 | #ifndef HOOK2_H 2 | #define HOOK2_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | /* 9 | typedef int (*pcond_signal_t)(pthread_cond_t *cond); 10 | extern pcond_signal_t pcond_signal_f; 11 | */ 12 | 13 | typedef int (*pthread_create_t)(pthread_t *thread, const pthread_attr_t *attr, 14 | void *(*start_routine) (void *), void *arg); 15 | extern pthread_create_t pthread_create_f; 16 | 17 | typedef int (*getaddrinfo_t)(const char *node, const char *service, 18 | const struct addrinfo *hints, 19 | struct addrinfo **res); 20 | extern getaddrinfo_t getaddrinfo_f; 21 | 22 | 23 | #endif /* HOOK2_H */ 24 | -------------------------------------------------------------------------------- /corona-c/hookcb.h: -------------------------------------------------------------------------------- 1 | #ifndef _HOOK_CB_H_ 2 | #define _HOOK_CB_H_ 3 | 4 | #include 5 | 6 | #define FDISSOCKET 1 7 | #define FDISPIPE 2 8 | #define FDISFILE 3 9 | #define FDXLIB 4 10 | #define EVENTFD 5 11 | #define SIGNALFD 6 12 | #define TIMERFD 7 13 | 14 | typedef struct fdcontext fdcontext; 15 | typedef struct hookcb hookcb; 16 | 17 | int fdcontext_set_nonblocking(fdcontext*fdctx, bool isNonBlocking) ; 18 | bool fdcontext_is_socket(fdcontext*fdctx); 19 | bool fdcontext_is_tcpsocket(fdcontext*fdctx); 20 | bool fdcontext_is_file(fdcontext*fdctx); 21 | bool fdcontext_is_nonblocking(fdcontext*fdctx); 22 | bool fd_is_nonblocking(int fd); 23 | int hookcb_fd_set_nonblocking(int fd, bool isNonBlocking); 24 | int fdcontext_get_fdtype(fdcontext*fdctx); 25 | 26 | hookcb* hookcb_get(); 27 | void hookcb_oncreate(int fd, int fdty, bool isNonBlocking, int domain, int sockty, int protocol) ; 28 | void hookcb_onclose(int fd) ; 29 | void hookcb_ondup(int from, int to) ; 30 | void hookcb_setin_poll(int fd, bool set, bool isread); 31 | bool hookcb_getin_poll(int fd, bool isread); 32 | fdcontext* hookcb_get_fdcontext(int fd); 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /corona-c/netpoller.h: -------------------------------------------------------------------------------- 1 | #ifndef NETPOLLER_H 2 | #define NETPOLLER_H 3 | 4 | #define CXEV_IO (0x1<<5) 5 | #define CXEV_TIMER (0x1<<6) 6 | #define CXEV_DNS_RESOLV (0x1<<7) 7 | 8 | static const int CRN_SEC = 1; 9 | static const int CRN_MSEC = 1000; 10 | static const int CRN_USEC = 1000000; 11 | static const int CRN_NSEC = 1000000000; 12 | 13 | #endif /* NETPOLLER_H */ 14 | 15 | -------------------------------------------------------------------------------- /corona-c/szqueue.h: -------------------------------------------------------------------------------- 1 | #ifndef szqueue_h 2 | #define szqueue_h 3 | 4 | 5 | // Defines a circular buffer which acts as a FIFO queue. 6 | typedef struct szqueue_t 7 | { 8 | int size; 9 | int next; 10 | int capacity; 11 | void** data; 12 | } szqueue_t; 13 | 14 | // Allocates and returns a new queue. The capacity specifies the maximum 15 | // number of items that can be in the queue at one time. A capacity greater 16 | // than INT_MAX / sizeof(void*) is considered an error. Returns NULL if 17 | // initialization failed. 18 | szqueue_t* szqueue_init(size_t capacity); 19 | 20 | // Releases the queue resources. 21 | void szqueue_dispose(szqueue_t* queue); 22 | 23 | // Enqueues an item in the queue. Returns 0 if the add succeeded or -1 if it 24 | // failed. If -1 is returned, errno will be set. 25 | int szqueue_add(szqueue_t* queue, void* value); 26 | 27 | // Dequeues an item from the head of the queue. Returns NULL if the queue is 28 | // empty. 29 | void* szqueue_remove(szqueue_t* queue); 30 | 31 | // Returns, but does not remove, the head of the queue. Returns NULL if the 32 | // queue is empty. 33 | void* szqueue_peek(szqueue_t*); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /corona-nim/.gdbinit: -------------------------------------------------------------------------------- 1 | # note: ~/.gdbinit 2 | 3 | handle SIGXCPU SIG33 SIG35 SIGPWR nostop noprint 4 | set pagination off 5 | #set print thread-events off 6 | file ./corona 7 | r 8 | #thread apply all bt full 9 | thread apply all bt 10 | quit 11 | -------------------------------------------------------------------------------- /corona-nim/Makefile: -------------------------------------------------------------------------------- 1 | all: gr1 2 | 3 | gr0: 4 | nim --threads:on --listcmd c goro.nim 5 | 6 | gr1: 7 | #-d:noSignalHandler 8 | #--listcmd 9 | nim -d:noSignalHandler --stacktrace:on --excessiveStackTrace:off --threads:on --gc:boehm \ 10 | -p:${HOME}/.nimble/mulib c corona.nim 11 | 12 | dc: 13 | nim doc -p:~/.nimble/mulib/ corona.nim 14 | 15 | # some tricks 16 | # gdb: handle SIGXCPU SIG33 SIG35 SIGPWR nostop noprint 17 | # gdb: thread apply all bt 18 | -------------------------------------------------------------------------------- /corona-nim/corona.nim.cfg: -------------------------------------------------------------------------------- 1 | 2 | --gc:boehm 3 | --threads:on 4 | -------------------------------------------------------------------------------- /corona-nim/corona.nimble: -------------------------------------------------------------------------------- 1 | # Package 2 | 3 | version = "0.1.0" 4 | author = "egitop" 5 | description = "A new awesome nimble package" 6 | license = "GPL-3.0" 7 | srcDir = "src" 8 | installExt = @["nim"] 9 | bin = @["corona"] 10 | 11 | 12 | # Dependencies 13 | 14 | requires "nim >= 0.19.6" 15 | -------------------------------------------------------------------------------- /corona-nim/ffi1.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int ffi_get_default_abi() { return FFI_DEFAULT_ABI; } 4 | int ffi_type_size() { return sizeof(ffi_type); } 5 | int ffi_cif_size() { return sizeof(ffi_cif); } 6 | 7 | void dump_pointer_array(int n, void** ptr) { 8 | for (int i = 0;i < n; i ++) { 9 | printf("%p %d, = %p\n", ptr, i, ptr[i]); 10 | } 11 | } 12 | 13 | void**pointer_array_new(int n) { return (void**)calloc(1, sizeof(void*)*n); } 14 | void pointer_array_set(void**ptr, int idx, void*val) { ptr[idx] = val;} 15 | void* pointer_array_get(void**ptr, int idx) { return ptr[idx]; } 16 | void pointer_array_free(void*ptr) {free(ptr);} 17 | void** pointer_array_addr(void**ptr) { return &ptr[0]; } 18 | -------------------------------------------------------------------------------- /corona-nim/hook.nim: -------------------------------------------------------------------------------- 1 | {.compile:"../corona-c/hook.c"} 2 | {.compile:"../corona-c/hookcb.c"} 3 | {.passc:"-D_GNU_SOURCE".} 4 | #{.passc:"-DLIBGO_SYS_Linux".} 5 | {.passc:"-I../corona-c/cltc/include".} 6 | {.passl:"-L../corona-c/cltc/lib -lcollectc"} 7 | 8 | proc initHook() {.importc.} 9 | initHook() 10 | 11 | ### hooked transfer to nim scope 12 | 13 | -------------------------------------------------------------------------------- /corona-nim/test.sh: -------------------------------------------------------------------------------- 1 | # have .gdbinit, direct rand `gdb` or `gdb ./corona`, both ok 2 | 3 | set -x 4 | while true; do 5 | # ./goro1 6 | gdb ./corona 7 | ret=$? 8 | echo "ret=$ret" 9 | if [[ "$ret" != "0" ]]; then 10 | break 11 | fi 12 | #sleep 1 13 | done 14 | -------------------------------------------------------------------------------- /corona-nim/tests/config.nims: -------------------------------------------------------------------------------- 1 | switch("path", "$projectDir/../src") -------------------------------------------------------------------------------- /corona-nim/tests/except0.nim: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | proc test_exc0() = 4 | linfo "hehehehhe" 5 | raise newException(OSError, "test exc msg") 6 | 7 | proc test_exc1() = 8 | try: 9 | test_exc0() 10 | except: 11 | linfo getCurrentExceptionMsg() 12 | for i in 0..5: sleep(1000) 13 | return 14 | 15 | proc runtest_exc0(cnter: int) = 16 | crn_post(test_exc1, nil) 17 | return 18 | -------------------------------------------------------------------------------- /corona-nim/tests/fiber0.nim: -------------------------------------------------------------------------------- 1 | 2 | proc test_fiber0() = 3 | return 4 | 5 | proc test_fiber1(s:string) = 6 | return 7 | 8 | proc test_fiber2(s:cstring) = 9 | linfo(s) 10 | sleep(5000) 11 | return 12 | 13 | proc test_fiber3(v: float) = 14 | linfo("whttt") 15 | for i in 0..5: 16 | linfo(v, i) 17 | sleep(1000) 18 | sleep(2000) 19 | return 20 | 21 | proc runtest_fiber0(cnt:int) = 22 | linfo "hehehe" 23 | #gogo2 test_fiber() 24 | #gogo2 test_fiber1("abc") 25 | var cs : cstring = "abc" 26 | #gogo2 test_fiber2(cs) 27 | gogo2 test_fiber3(5.678) 28 | -------------------------------------------------------------------------------- /corona-nim/tests/manyroutines.nim: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | proc test_manyroutines1(arg:pointer) = 4 | var btime = nowt0() # times.now() 5 | var tno = cast[int](arg) 6 | linfo("before usleep", btime, tno) 7 | for i in 0..50: 8 | discard usleepc(rand(320)*10000) 9 | linfo("inloop usleep", i, tno) 10 | linfo("after usleep", nowt0()-btime, tno) 11 | return 12 | 13 | 14 | # 每个tick是500ms 15 | # 每tick启动1个,大概应该能够保持120个 16 | proc runtest_manyroutines_tick(cnt:int) = 17 | if cnt < 120: 18 | crn_post(test_manyroutines1, cast[pointer](cnt)) 19 | else: 20 | if cnt mod 2 == 1: 21 | crn_post(test_manyroutines1, cast[pointer](cnt)) 22 | 23 | -------------------------------------------------------------------------------- /corona-nim/tests/test1.nim.example: -------------------------------------------------------------------------------- 1 | # This is just an example to get you started. You may wish to put all of your 2 | # tests into a single file, or separate them into multiple `test1`, `test2` 3 | # etc. files (better names are recommended, just make sure the name starts with 4 | # the letter 't'). 5 | # 6 | # To run these tests, simply execute `nimble test`. 7 | 8 | import unittest 9 | 10 | import goropkg/submodule 11 | test "correct welcome": 12 | check getWelcomeMessage() == "Hello, World!" 13 | -------------------------------------------------------------------------------- /corona-nim/tests/usleep0.nim: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | proc test_usleep0() = 4 | var btime = times.now() 5 | linfo("before usleep", btime) 6 | #discard usleep(1000000) 7 | discard usleepc(30000000) 8 | linfo("after usleep", times.now()-btime) 9 | return 10 | 11 | proc test_usleep1(arg:pointer) = 12 | var btime = nowt0() # times.now() 13 | var tno = cast[int](arg) 14 | linfo("before usleep", btime, tno) 15 | for i in 0..50: 16 | discard usleepc(rand(320)*10000) 17 | linfo("inloop usleep", i, tno) 18 | linfo("after usleep", nowt0()-btime, tno, getFrame()==nil) 19 | return 20 | 21 | #crn_post(test_usleep0, nil) 22 | #crn_post(test_usleep1, cast[pointer](5)) 23 | proc runtest_usleep(cnt:int) = 24 | crn_post(test_usleep1, cast[pointer](cnt)) 25 | 26 | -------------------------------------------------------------------------------- /cplus/readme.md: -------------------------------------------------------------------------------- 1 | 自己创造一种语言的问题在于库的问题很难解决。 2 | 还有相应的工具,像编辑器补全,代码分析,效率分析等。 3 | 4 | -------------------------------------------------------------------------------- /docs/debug.md: -------------------------------------------------------------------------------- 1 | 2 | ### .gdbinit 3 | 4 | 首先会加载 $HOME/.gdbinit,可以在这设置 5 | 6 | 比如:添加set auto-load safe-path / 7 | 8 | 然后在当前目录的 $PWD/.gdbinit,设置当前项目需要的命令 9 | 10 | 然后执行 gdb 11 | 12 | ### smash stack 13 | 这可能是coro_create没加锁造成的,加了锁之后好像没出现过了。 14 | 15 | -------------------------------------------------------------------------------- /docs/pass.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ### pass1 4 | 5 | * 哪些函数中有需要定义的类型 6 | * 哪些函数中有用到go语句的 7 | * 哪些函数中有用到了channel 8 | 9 | -------------------------------------------------------------------------------- /golang/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | 3 | prs: 4 | #antlr4 -long-messages 5 | mkdir -p parser 6 | # cp with sed modify 7 | sed 's/package GoParseTree/package parser/' Go/go_parser_base.go > parser/go_parser_base.go 8 | antlr4 -long-messages -Dlanguage=Go -o parser GoLexer.g4 9 | antlr4 -long-messages -Dlanguage=Go -o parser GoParser.g4 10 | go install -v ./parser/ 11 | 12 | cpl: 13 | go build -v 14 | 15 | -------------------------------------------------------------------------------- /golang/README.md: -------------------------------------------------------------------------------- 1 | # Golang Grammar 2 | 3 | An ANTLR4 grammar for Golang based on [The Go Programming Language Specification](https://golang.org/ref/spec). 4 | 5 | ## How to use 6 | 7 | * Generate lexer and parser with ANTLR4 generator 8 | * Include both generated and base classes to project from corresponding 9 | directory (C#, Java, or Go). For Go runtime you should add prefix `p.` to 10 | all semantic predicates, i.e: `lineTerminatorAhead` -> `p.lineTerminatorAhead()` 11 | and so on. 12 | 13 | ## Main contributors 14 | 15 | * Sasa Coh, Michał Błotniak, 2017 16 | * Initial version 17 | * Ivan Kochurkin and @fred1268, kvanttt@gmail.com, Positive Technologies, 2019: 18 | * Separated lexer and parser 19 | * Fixes and refactoring 20 | * Dmitry Rassadin, flipparassa@gmail.com, Positive Technologies, 2019: 21 | * Samples set 22 | * Fixes and refactoring 23 | 24 | ## License 25 | 26 | [BSD-3](https://opensource.org/licenses/BSD-3-Clause) -------------------------------------------------------------------------------- /golang/examples/anonymousMethods.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import "fmt" 4 | import . "time" 5 | 6 | func AnonymousMethods() { 7 | lambd := func(s string) { Sleep(10); fmt.Println(s) } 8 | lambd("From lambda!") 9 | func() { fmt.Println("Create and invoke!")}() 10 | } 11 | -------------------------------------------------------------------------------- /golang/examples/arrayDecls.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func ArrayDecls() { 8 | /*[32]byte 9 | [2*N] struct { x, y int32 } 10 | [1000]*float64 11 | [3][5]int 12 | [2][2][2]float64 // same as [2]([2]([2]float64)) 13 | */ 14 | var a [2]string 15 | a[0] = "Hello" 16 | a[1] = "World" 17 | fmt.Println(a[0], a[1]) 18 | 19 | primes := [6]int{2, 3, 5, 7, 11, 13} 20 | fmt.Println(primes) 21 | 22 | var twoD [2][4]int 23 | for i := 0; i < 2; i++ { 24 | for j := 0; j < 3; j++ { 25 | twoD[i][j] = i + j 26 | } 27 | } 28 | fmt.Println("2d: ", twoD) 29 | } -------------------------------------------------------------------------------- /golang/examples/arrayEllipsisDecls.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type Custom struct { 8 | string 9 | } 10 | 11 | func ArrayEllipsisDecls() { 12 | stooges := [...]Custom{{"Moe"}, {"Larry"}, {"Curly"}} // len(stooges) == 3 13 | fmt.Println("Stooges: ", stooges) 14 | } -------------------------------------------------------------------------------- /golang/examples/bufChan.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import "fmt" 4 | 5 | func goRoutineA(a <-chan int) { 6 | val := <-a 7 | fmt.Println("goRoutineA received the data", val) 8 | } 9 | 10 | func BufChan() { 11 | c := make(chan int, 2) // a buffered channel 12 | c <- 3 13 | c <- 5 14 | close(c) 15 | fmt.Println(len(c), cap(c)) // 2 2 16 | x, ok := <-c 17 | fmt.Println(x, ok) // 3 true 18 | fmt.Println(len(c), cap(c)) // 1 2 19 | x, ok = <-c 20 | fmt.Println(x, ok) // 5 true 21 | fmt.Println(len(c), cap(c)) // 0 2 22 | x, ok = <-c 23 | fmt.Println(x, ok) // 0 false 24 | x, ok = <-c 25 | fmt.Println(x, ok) // 0 false 26 | fmt.Println(len(c), cap(c)) // 0 2 27 | // close(c) // panic! 28 | // The send will also panic if the above 29 | // close call is removed. 30 | // c <- 7 31 | 32 | ch := make(chan int) 33 | go goRoutineA(ch) 34 | } 35 | -------------------------------------------------------------------------------- /golang/examples/chan.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func Ch() { 9 | var ball = make(chan string) 10 | kickBall := func(playerName string) { 11 | for { 12 | fmt.Println(<-ball, "kicked the ball.") 13 | time.Sleep(time.Second) 14 | ball <- playerName 15 | } 16 | } 17 | go kickBall("John") 18 | go kickBall("Alice") 19 | go kickBall("Bob") 20 | go kickBall("Emily") 21 | time.Sleep(time.Second * 2) 22 | ball <- "referee" // kick off 23 | 24 | var c chan bool // nil 25 | <-c // blocking here for ever 26 | } 27 | -------------------------------------------------------------------------------- /golang/examples/constDecl.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import "fmt" 4 | 5 | // var entries map[string]int 6 | 7 | func constMultiRet() (int, int) { 8 | return 1, 2 9 | } 10 | 11 | func ConstDecls() { 12 | const ( 13 | c0 = iota // c0 == 0 14 | c1 = iota // c1 == 1 15 | c2 = iota // c2 == 2 16 | ) 17 | const ( 18 | Sunday = iota 19 | Monday 20 | Tuesday 21 | Wednesday 22 | Thursday 23 | Friday 24 | Partyday 25 | numberOfDays // this constant is not exported 26 | ) // TODO: Added support for iota token 27 | const Pi float64 = 3.14159265358979323846 28 | const zero = 0.0 // untyped floating-point constant 29 | const ( 30 | size int64 = 1024 31 | eof = -1 // untyped integer constant 32 | ) 33 | const a, b, c = 3, 4, "foo" // a = 3, b = 4, c = "foo", untyped integer and string constants 34 | const u, v float32 = 0, 3 // u = 0.0, v = 3.0 35 | fmt.Println(c0, c1, c2, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Partyday, numberOfDays, Pi, zero, size, eof, a, b, c, u, v) 36 | } 37 | -------------------------------------------------------------------------------- /golang/examples/defers.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import ( 4 | "fmt" 5 | "crypto/rsa" 6 | "crypto/rand" 7 | ) 8 | 9 | func DeferCallee() { 10 | fmt.Println("Called from the first defer!") 11 | } 12 | 13 | func DeferCallee2() { 14 | fmt.Println("Called from the second defer!") 15 | } 16 | 17 | func Defers() { 18 | pvk, err := rsa.GenerateKey(rand.Reader, 2048) 19 | defer DeferCallee() 20 | // switch the equal sign for the different number of executed defer invocations 21 | if extra := -1; err != nil { 22 | fmt.Println("Something went wrong", extra) 23 | } else { 24 | return 25 | } 26 | 27 | defer DeferCallee2() 28 | fmt.Printf("End\n", pvk.Size()) 29 | } 30 | -------------------------------------------------------------------------------- /golang/examples/example.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | // Send the sequence 2, 3, 4, … to channel 'ch'. 6 | func generate(ch chan<- int) { 7 | for i := 2; ; i++ { 8 | ch <- i // Send 'i' to channel 'ch'. 9 | } 10 | } 11 | 12 | // Copy the values from channel 'src' to channel 'dst', 13 | // removing those divisible by 'prime'. 14 | func filter(src <-chan int, dst chan<- int, prime int) { 15 | for i := range src { // Loop over values received from 'src'. 16 | if i%prime != 0 { 17 | dst <- i // Send 'i' to channel 'dst'. 18 | } 19 | } 20 | } 21 | 22 | // The prime sieve: Daisy-chain filter processes together. 23 | func sieve() { 24 | ch := make(chan int) // Create a new channel. 25 | go generate(ch) // Start generate() as a subprocess. 26 | for { 27 | prime := <-ch 28 | fmt.Print(prime, "\n") 29 | ch1 := make(chan int) 30 | go filter(ch, ch1, prime) 31 | ch = ch1 32 | } 33 | } 34 | 35 | func main() { 36 | sieve() 37 | } -------------------------------------------------------------------------------- /golang/examples/forStmts.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import "fmt" 4 | 5 | func S() (int, int) { 6 | return 1, 2 7 | } 8 | 9 | func ForStmts() { 10 | a, b := 1, 2 11 | for a < b { 12 | fmt.Println("From condition-only ForStmt") 13 | break 14 | } 15 | 16 | for ;; { 17 | fmt.Println("From empty ForClause ForStmt") 18 | break 19 | } 20 | 21 | // non-compaliable 22 | /*for j: = 0 ; ; { 23 | a += b 24 | fmt.Println("From ForClause with only init ForStmt") 25 | break 26 | }*/ 27 | 28 | for ; a < b; { 29 | fmt.Println("From condition-only ForClause ForClause ForStmt") 30 | break 31 | } 32 | 33 | for j:=0 ; a < b; { 34 | j++ 35 | fmt.Println("From init and condition ForClause ForClause ForStmt") 36 | break 37 | } 38 | 39 | for j:=0 ; ; j++ { 40 | fmt.Println("From init and post ForClause ForClause ForStmt") 41 | break 42 | } 43 | 44 | for ; a < b ; a++ { 45 | fmt.Println("From condition and post ForClause ForClause ForStmt") 46 | break 47 | } 48 | 49 | for z:=0 ; a < b ; z++ { 50 | fmt.Println("From full ForClause ForClause ForStmt") 51 | return 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /golang/examples/foreachStmts.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import "fmt" 4 | 5 | func ForeachStmts() { 6 | // Here we use `range` to sum the numbers in a slice. 7 | // Arrays work like this too. 8 | nums := []int{2, 3, 4} 9 | sum := 0 10 | for _, num := range nums { 11 | sum += num 12 | } 13 | fmt.Println("sum:", sum) 14 | 15 | // `range` on arrays and slices provides both the 16 | // index and value for each entry. Above we didn't 17 | // need the index, so we ignored it with the 18 | // blank identifier `_`. Sometimes we actually want 19 | // the indexes though. 20 | for i, num := range nums { 21 | if num == 3 { 22 | fmt.Println("index:", i) 23 | } 24 | } 25 | 26 | // `range` on map iterates over key/value pairs. 27 | kvs := map[string]string{"a": "apple", "b": "banana"} 28 | 29 | for k, v := range kvs { 30 | fmt.Printf("%s -> %s\n", k, v) 31 | } 32 | 33 | // Valid statement 34 | for range kvs { 35 | fmt.Printf("empty range\n") 36 | } 37 | } -------------------------------------------------------------------------------- /golang/examples/function.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | // func BodylessFunction() -------------------------------------------------------------------------------- /golang/examples/gostmts.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | // import "fmt" 4 | import . "time" 5 | 6 | func Server() { 7 | } 8 | 9 | func GoStmts() { 10 | go Server() 11 | go func() { Sleep(10) } () 12 | /*var c chan 13 | go func(ch chan<- bool) { for { sleep(10); ch <- true }} (<-c)*/ 14 | } 15 | -------------------------------------------------------------------------------- /golang/examples/hardcodedPassword.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import "fmt" 4 | 5 | type HpType struct { 6 | } 7 | 8 | func (c HpType) HP() { 9 | password := `hardcoded` 10 | // var password = "hardcoded" 11 | fmt.Printf("Hello, world\nYou type the password=%v\n", password) 12 | letters := []string{"a", "b", "c", "d"} 13 | // shadowing previous same decl 14 | // var letters []string 15 | //letters = make([]string, 4, 10) 16 | // letters[3] = "e" 17 | p := make([]string, 10) 18 | p = append(letters, "e", "f") 19 | fmt.Println(letters, len(letters), cap(letters)) 20 | fmt.Println(p, len(p), cap(p)) 21 | } 22 | -------------------------------------------------------------------------------- /golang/examples/ill_but_correct.go: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import "fmt" 4 | 5 | func main() { ; 6 | ch <- 1 } 7 | -------------------------------------------------------------------------------- /golang/examples/interface_inheritance.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type T1 struct { 6 | name string 7 | } 8 | 9 | func (t T1) M() {} 10 | func (t T1) N() {} 11 | func (t T1) String() string { return "" } 12 | func (t T1) Error() string { return "" } 13 | 14 | type T2 struct { 15 | name string 16 | } 17 | 18 | func (t T2) M() {} 19 | func (t T2) N() {} 20 | func (t T2) String() string { return "" } 21 | func (t T2) Error() string { return "" } 22 | 23 | type I interface { 24 | M() 25 | } 26 | 27 | // In the following interface declaration, error is an 28 | // inherited interface, not the "result" type of N() 29 | type V interface { 30 | I 31 | fmt.Stringer 32 | N() 33 | error 34 | } 35 | 36 | func main() { 37 | m := make(map[I]int) 38 | var i1 I = T1{"foo"} 39 | var i2 I = T2{"bar"} 40 | m[i1] = 1 41 | m[i2] = 2 42 | fmt.Println(m) 43 | 44 | n := make(map[V]int) 45 | var v1 V = T1{"foo"} 46 | var v2 V = T2{"bar"} 47 | v1.N() 48 | v2.M() 49 | v1.String() 50 | v2.Error() 51 | n[v1] = 3 52 | n[v2] = 4 53 | fmt.Println(n) 54 | } -------------------------------------------------------------------------------- /golang/examples/interfaces.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import "fmt" 4 | 5 | type Shape interface { 6 | Area(a float64) float64 7 | } 8 | 9 | type Object interface { 10 | Volume() float64 11 | } 12 | 13 | type Material interface { 14 | Shape 15 | Object 16 | } 17 | 18 | type Cube struct { 19 | side float64 20 | } 21 | 22 | func (c Cube) Area(a float64) float64 { 23 | return 6 * (c.side * c.side) * a 24 | } 25 | 26 | func (c Cube) Volume() float64 { 27 | return c.side * c.side * c.side 28 | } 29 | 30 | func Interfaces() { 31 | c := Cube{3} 32 | var m Material = c 33 | var s Shape = c 34 | var o Object = c 35 | fmt.Printf("dynamic type and value of interface m of static type Material is'%T' and '%v'\n", m, m) 36 | fmt.Printf("dynamic type and value of interface s of static type Shape is'%T' and '%v'\n", s, s) 37 | fmt.Printf("dynamic type and value of interface o of static type Object is'%T' and '%v'\n", o, o) 38 | } 39 | -------------------------------------------------------------------------------- /golang/examples/map_with_string.go: -------------------------------------------------------------------------------- 1 | package test_controller 2 | 3 | import ( 4 | "aa.bb.com/facility/assert" 5 | "aa.bb.com/xxx/post/internal/controller" 6 | "aa.bb.com/xxx/post/pkg/cerror" 7 | ctx2 "aa.bb.com/xxx/post/test/tools/ctx" 8 | "aa.bb.com/xxx/post/thrift_gen/base" 9 | "aa.bb.com/xxx/post/thrift_gen/something/xxx/post" 10 | "aa.bb.com/gopkg/logs" 11 | ) 12 | 13 | func newUpdateCommentRequest() *post.UpdateCommentRequest { 14 | req := post.NewUpdateCommentRequest() 15 | req.CommentId = 18 16 | fields := map[string]interface{}{ 17 | "extra": `{"test_update_fields":"update_fields_by_test"}`, 18 | } 19 | req.UpdateFields, _ = json.MarshalToString(fields) 20 | req.Base = &base.Base{ 21 | Caller: "some.interface.withip", 22 | } 23 | return req 24 | } 25 | 26 | func TestUpdateComment() { 27 | ctx := ctx2.MockKiteContext("contextname", "") 28 | req := newUpdateCommentRequest() 29 | resp, err := controller.UpdateComment(ctx, req) 30 | logs.Info("%+v %+v %+v", req, resp, err) 31 | assert.IsNil(err) 32 | assert.EqualInt32(resp.BaseResp.StatusCode, cerror.ErrNo_Success.Int32()) 33 | } 34 | 35 | -------------------------------------------------------------------------------- /golang/examples/maps.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import "fmt" 4 | 5 | type Vertex2 struct { 6 | Lat, Long float64 7 | } 8 | 9 | var s map[int]string 10 | var m map[string]Vertex2 11 | 12 | func Maps() { 13 | m = make(map[string]Vertex2) 14 | m["Bell Labs"] = Vertex2{ 15 | 40.68433, -74.39967, 16 | } 17 | s[1] ="test" 18 | fmt.Println(m["Bell Labs"]) 19 | } -------------------------------------------------------------------------------- /golang/examples/method.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import ( 4 | "fmt" 5 | "math" 6 | ) 7 | 8 | type Vertex struct { 9 | X, Y float64 10 | } 11 | 12 | func (v Vertex) Abs() float64 { 13 | return math.Sqrt(v.X*v.X + v.Y*v.Y) 14 | } 15 | 16 | func Methods() { 17 | v := Vertex{3, 4} 18 | fmt.Println(v.Abs()) 19 | } -------------------------------------------------------------------------------- /golang/examples/multiple_type_decl.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | type ( 9 | Abser interface { 10 | Abs() float64 11 | } 12 | 13 | MyError struct { 14 | When time.Time 15 | What string 16 | } 17 | 18 | MyCustomError struct { 19 | Message string 20 | Abser 21 | MyError 22 | } 23 | ) 24 | 25 | // The following takes precedence over instance call to Abs() 26 | func (myErr *MyCustomError) Abs() float64 { 27 | return 0.0 28 | } 29 | 30 | func main() { 31 | a:= MyCustomError{"New One", nil, MyError{time.Now(), "Hello"}} 32 | a.Abs() 33 | a.Message = "New" 34 | fmt.Println("MyCustomError method = %v", a.Abs()) 35 | } -------------------------------------------------------------------------------- /golang/examples/params.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import ("fmt" 4 | "reflect" 5 | ) 6 | 7 | func ParamTest(a, b int32, c int16) { 8 | fmt.Printf("Type of a is %s\n", reflect.TypeOf(a)) 9 | fmt.Printf("Type of a is %s\n", reflect.TypeOf(b)) 10 | fmt.Printf("Type of a is %s\n", reflect.TypeOf(c)) 11 | } -------------------------------------------------------------------------------- /golang/examples/promoted.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | ) 7 | 8 | type Foo1 func(x int) int 9 | 10 | type Foo2 func(x int) int 11 | 12 | type Request struct{} 13 | 14 | // T is a custom type 15 | type T2 struct { 16 | http.Request // field name is "Request" 17 | age int32 18 | } 19 | 20 | func Types() { 21 | // person := T{name: "Michael", age: 29} 22 | // fmt.Println(person) 23 | fmt.Println("123") 24 | } 25 | -------------------------------------------------------------------------------- /golang/examples/returnStmt.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | type Devnull struct {} 4 | 5 | func noResult() { 6 | return 7 | } 8 | 9 | func simpleF() int { 10 | return 2 11 | } 12 | 13 | func complexF1() (re float64, im float64) { 14 | return -7.0, -4.0 15 | } 16 | 17 | func complexF2() (re float64, im float64) { 18 | return complexF1() 19 | } 20 | 21 | func complexF3() (re float64, im float64) { 22 | re = 7.0 23 | im = 4.0 24 | return 25 | } 26 | 27 | func (Devnull) writeLength(p []byte) (n int, _ error) { 28 | n = len(p) 29 | return 30 | } 31 | 32 | func ReturnImported() { 33 | var p []byte 34 | var devnull Devnull 35 | noResult() // + 36 | simpleF() // + 37 | complexF1() // + 38 | complexF2() // + but sort out with propogating multiRet 39 | complexF3() // - 40 | devnull.writeLength(p) // - 41 | } -------------------------------------------------------------------------------- /golang/examples/select.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | func Selects() { 4 | var a []int 5 | var c, c1, c2, c3, c4, c5 chan int 6 | var i1, i2 int 7 | select { 8 | case i1 = <-c1: 9 | print("received ", i1, " from c1\n") 10 | case c2 <- i2: 11 | print("sent ", i2, " to c2\n") 12 | case i3, ok := (<-c3): // same as: i3, ok := <-c3 13 | if ok { 14 | print("received ", i3, " from c3\n") 15 | } else { 16 | print("c3 is closed\n") 17 | } 18 | case <-c5: 19 | print("received without an assignment") 20 | case a[f()] = <-c4: 21 | // same as: 22 | // case t := <-c4 23 | // a[f()] = t 24 | default: 25 | print("no communication\n") 26 | } 27 | 28 | for i := 0; i < 10; i++ { // send random sequence of bits to c 29 | select { 30 | case c <- 0: // note: no statement, no fallthrough, no folding of cases 31 | case c <- 1: 32 | default: 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /golang/examples/shortVarDecl.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import "fmt" 4 | import "os" 5 | 6 | func ShortVarDecls() { 7 | a, b := 0, 10 8 | c := func() int { return 7 } 9 | d := make(chan int) 10 | e, f, _ := os.Pipe() // os.Pipe() returns a connected pair of Files and an error, if any 11 | // _, y, _ := coord(p) // coord() returns three values; only interested in y coordinate 12 | fmt.Println(a, b, c, d, e, f) 13 | } 14 | -------------------------------------------------------------------------------- /golang/examples/sliceDecls.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func SliceDecls() { 8 | primes := [6]int{2, 3, 5, 7, 11, 13} 9 | var sl []int = primes[1:4] 10 | fmt.Println(sl) 11 | 12 | s := make([]string, 3) 13 | fmt.Println("emp:", s) 14 | 15 | s[0] = "a" 16 | s[1] = "b" 17 | s[2] = "c" 18 | fmt.Println("set:", s) 19 | fmt.Println("get:", s[2]) 20 | fmt.Println("len:", len(s)) 21 | 22 | s = append(s, "d") 23 | s = append(s, "e", "f") 24 | fmt.Println("apd:", s) 25 | 26 | c := make([]string, len(s)) 27 | copy(c, s) 28 | fmt.Println("cpy:", c) 29 | 30 | l := s[2:5] 31 | fmt.Println("sl1:", l) 32 | 33 | l = s[:5] 34 | fmt.Println("sl2:", l) 35 | 36 | l = s[2:] 37 | fmt.Println("sl3:", l) 38 | 39 | t := []string{"g", "h", "i"} 40 | fmt.Println("dcl:", t) 41 | 42 | twoD := make([][]int, 3) 43 | for i := 0; i < 3; i++ { 44 | innerLen := i + 1 45 | twoD[i] = make([]int, innerLen) 46 | for j := 0; j < innerLen; j++ { 47 | twoD[i][j] = i + j 48 | } 49 | } 50 | fmt.Println("2d: ", twoD) 51 | } -------------------------------------------------------------------------------- /golang/examples/strings.go: -------------------------------------------------------------------------------- 1 | // Verifies raw and interpreted string parsing (see issue #1131). 2 | package main 3 | 4 | import ( 5 | "fmt" 6 | ) 7 | 8 | type Vertex struct { 9 | X float64 `"X" Description` /* X Comment */ 10 | Y float64 "`Y` Description" // Y Comment 11 | } 12 | 13 | func main() { 14 | fmt.Println("this \"that") 15 | fmt.Println(`Hello`) 16 | } 17 | 18 | type Something struct { 19 | Msg string `World` 20 | } 21 | -------------------------------------------------------------------------------- /golang/examples/struct_promotion.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type Person struct { 6 | name string 7 | age int32 8 | } 9 | 10 | func (p Person) IsAdult() bool { 11 | return p.age >= 18 12 | } 13 | 14 | type Employee struct { 15 | position string 16 | } 17 | 18 | func (e Employee) IsManager() bool { 19 | return e.position == "manager" 20 | } 21 | 22 | // In the following structure declaration, Employee is a 23 | // promoted structure, not the "result" type of Person 24 | type Record struct { 25 | Person 26 | Employee 27 | } 28 | 29 | func main() { 30 | person := Person{name: "Michal", age: 29} 31 | fmt.Println(person) // {Michal 29} 32 | record := Record{} 33 | record.name = "Michal" 34 | record.age = 29 35 | record.position = "software engineer" 36 | 37 | fmt.Println(record) // {{Michal 29} {software engineer}} 38 | fmt.Println(record.name) // Michal 39 | fmt.Println(record.age) // 29 40 | fmt.Println(record.position) // software engineer 41 | fmt.Println(record.IsAdult()) // true 42 | fmt.Println(record.IsManager()) // false 43 | } -------------------------------------------------------------------------------- /golang/examples/struct_with_func_type.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type Person struct { 6 | work func() 7 | name string 8 | age int32 9 | } 10 | 11 | func main() { 12 | person := Person{work: nil, name: "Michał", age: 29} 13 | fmt.Println(person) // { Michał 29} 14 | } -------------------------------------------------------------------------------- /golang/examples/switchesExpr.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import ( 4 | "fmt" 5 | "runtime" 6 | ) 7 | 8 | func f() int { 9 | return 1 10 | } 11 | 12 | func g() {} 13 | 14 | func SwitchesExpr() int { 15 | switch os := runtime.GOOS; os { 16 | case "darwin": 17 | fmt.Println("OS X.") 18 | case "linux": 19 | fmt.Println("Linux.") 20 | default: 21 | // freebsd, openbsd, 22 | // plan9, windows... 23 | fmt.Printf("%s.\n", os) 24 | } 25 | 26 | tag := 1 27 | switch tag { 28 | default: g() 29 | case 0, 1, 2, 3: f() 30 | case 4, 5, 6, 7: f() 31 | } 32 | 33 | switch x := f(); { // missing switch expression means "true" 34 | case x < 0: return -x 35 | default: return x 36 | } 37 | 38 | switch { 39 | case 1 < 2: f() 40 | case 2 < 3: f() 41 | case tag == 4: f() 42 | } 43 | 44 | return 1 45 | } -------------------------------------------------------------------------------- /golang/examples/switchesType.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import "fmt" 4 | 5 | type O struct { 6 | 7 | } 8 | 9 | func (O) typee() {} 10 | 11 | func TypeSwitch(i interface{}) { 12 | switch v := i.(type) { 13 | case int: 14 | fmt.Printf("Twice %v is %v\n", v, v*2) 15 | case string: 16 | fmt.Printf("%q is %v bytes long\n", v, len(v)) 17 | case byte, uintptr: 18 | fmt.Printf("Type i %T", v) 19 | default: 20 | fmt.Printf("I don't know about type %T!\n", v) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /golang/examples/typeAsserts.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import "fmt" 4 | 5 | /* 6 | type I interface { m() } 7 | 8 | type J interface { n() } 9 | 10 | 11 | 12 | func (TwoS) m() {} 13 | func (TwoS) n() {} 14 | 15 | func call(y I) { 16 | s := y.(string) // illegal: string does not implement I (missing method m) 17 | r := y.(J) // r has type io.Reader and the dynamic type of y must implement both I and io.Reader 18 | } 19 | */ 20 | 21 | type TwoS struct { 22 | } 23 | 24 | func TypeAssertions() { 25 | var i interface{} = "hello" 26 | 27 | s := i.(string) 28 | fmt.Println(s) 29 | 30 | s, ok := i.(string) 31 | fmt.Println(s, ok) 32 | 33 | f, ok := i.(float64) 34 | fmt.Println(f, ok) 35 | 36 | t, ok := i.(TwoS) 37 | fmt.Println(t, ok) 38 | 39 | //f = i.(float64) // panic 40 | // fmt.Println(f) 41 | } 42 | -------------------------------------------------------------------------------- /golang/examples/varDecl.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import "fmt" 4 | 5 | var entries map[string]int 6 | 7 | func multiRet() (int, int) { 8 | return 1, 2 9 | } 10 | 11 | func VarDecls() { 12 | var a int // + 13 | var b, c float64 // + strange extra levels 14 | var d = 1 // + doesn't show zero value 15 | var e, f float32 = -1, -2 // + 16 | var ( 17 | g int 18 | h, i, j = 2.0, 3.0, "bar" 19 | ) // + need to precise general text span 20 | // var _, k = entries["1"] // map lookup; 21 | var l, m = multiRet() // + TODO: Figure out with duplication 22 | fmt.Println(a, b, c, d, e, f, g, h, i, j, /*k,*/ l, m) 23 | } 24 | -------------------------------------------------------------------------------- /golang/examples/weakHash.go: -------------------------------------------------------------------------------- 1 | package samples 2 | 3 | import "fmt" 4 | import "io" 5 | import "crypto/md5" 6 | import "crypto/sha256" 7 | 8 | import "golang.org/x/crypto/blake2s" 9 | 10 | // Trivial routine 11 | func WeakHash(a int32) { 12 | hMd5 := md5.New() 13 | hSha := sha256.New() 14 | hBlake2s, err := blake2s.New256(nil) 15 | if err == nil { 16 | io.WriteString(hMd5, "Welcome to Go Language Secure Coding Practices") 17 | io.WriteString(hSha, "Welcome to Go Language Secure Coding Practices") 18 | io.WriteString(hBlake2s, "Welcome to Go Language Secure Coding Practices") 19 | fmt.Printf("MD5 : %x\n", hMd5.Sum(nil)) 20 | fmt.Printf("SHA256 : %x\n", hSha.Sum(nil)) 21 | fmt.Printf("Blake2s-256: %x\n", hBlake2s.Sum(nil)) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /include/routine.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "libgo.h" 4 | 5 | co::AsyncCoroutinePool * pPool = 0; 6 | 7 | extern "C" 8 | void cxrt_init_routine_env() { 9 | pPool = co::AsyncCoroutinePool::Create(); 10 | pPool->InitCoroutinePool(512); 11 | pPool->Start(2,5); 12 | } 13 | 14 | void foo() 15 | { 16 | printf("do some block things in co::AsyncCoroutinePool.\n"); 17 | } 18 | 19 | void done() 20 | { 21 | printf("done.\n"); 22 | } 23 | 24 | extern "C" 25 | void cxrt_routine_post(void (*f)(void*), void*arg) { 26 | auto fo = std::bind(f, arg); 27 | pPool->Post(fo, &done); 28 | } 29 | 30 | extern "C" 31 | void* cxrt_chan_new(int sz) { 32 | auto ch = ::new (UseGC) co_chan(sz); 33 | return ch; 34 | } 35 | 36 | extern "C" 37 | void cxrt_chan_send(void*vch, void*arg) { 38 | co_chan* ch = static_cast*>(vch); 39 | (*ch) << arg; 40 | } 41 | extern "C" 42 | void* cxrt_chan_recv(void*vch) { 43 | co_chan* ch = static_cast*>(vch); 44 | co_chan& ch2 = (*ch); 45 | 46 | void*ret = 0; 47 | ch2 >> ret; 48 | return ret; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /misc/Makefile: -------------------------------------------------------------------------------- 1 | 2 | all: dm1 3 | 4 | dm0: 5 | gcc cogc.c -o cogc0 -g -O0 -L ../bdwgc/.libs -lgc -lpthread -I ../bdwgc/include 6 | 7 | dm1: 8 | gcc cogc1.c ../goro/coro.c -o cogc1 -g -O0 -L ../bdwgc/.libs -lgc -lpthread -I ../bdwgc/include -I ../goro -D_GNU_SOURCE -DCORO_STACKALLOC -DCORO_UCONTEXT -DHAVE_UCONTEXT_H -DHAVE_SETJMP_H -DHAVE_SIGALTSTACK 9 | 10 | -------------------------------------------------------------------------------- /scripts/build-bysrc-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | export GOPATH=$HOME 6 | export GO111MODULE="" 7 | export CGO_ENABLED=1 8 | 9 | go get -v github.com/thoas/go-funk 10 | go get -v github.com/twmb/algoimpl/go/graph 11 | #go get -v golang.org/x/tools/go/ast/astutil 12 | #go get -v golang.org/x/tools/go/packages 13 | go get -v github.com/smacker/go-tree-sitter 14 | go get -v github.com/xlab/c-for-go 15 | go get -v modernc.org/ir 16 | go get -v modernc.org/token 17 | go get -v github.com/kitech/goplusplus 18 | cp -a $GOPATH/src/github.com/kitech/goplusplus $GOPATH/src/gopp 19 | #ln -sv $PWD $GOPATH/src/ 20 | cp -a $PWD $GOPATH/src/ 21 | ln -sv $PWD/xgo $GOPATH/src/ 22 | 23 | cd $GOPATH/src/cygo/bysrc 24 | pwd 25 | 26 | go env 27 | go version 28 | ls 29 | 30 | go build -v -a 31 | ls -lh 32 | # build flag -mod=vendor only valid when using modules 33 | #go build -v -mod=vendor 34 | #ls -lh 35 | 36 | 37 | ./bysrc ./tpkgs/cgo1 38 | ./utests.sh 39 | for f in `ls ./tpkgs/`; do 40 | echo "$PWD ./bysrc ./tpkgs/$f" 41 | # ./bysrc "./tpkgs/$f/" 42 | done 43 | 44 | cd - 45 | 46 | -------------------------------------------------------------------------------- /scripts/build-bysrc-macos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | export GOPATH=$HOME 6 | export GO111MODULE="" 7 | export CGO_ENABLED=1 8 | 9 | go get -v github.com/thoas/go-funk 10 | go get -v github.com/twmb/algoimpl/go/graph 11 | #go get -v golang.org/x/tools/go/ast/astutil 12 | #go get -v golang.org/x/tools/go/packages 13 | go get -v github.com/smacker/go-tree-sitter 14 | go get -v github.com/xlab/c-for-go 15 | go get -v modernc.org/ir 16 | go get -v modernc.org/token 17 | go get -v github.com/kitech/goplusplus 18 | cp -a $GOPATH/src/github.com/kitech/goplusplus $GOPATH/src/gopp 19 | #ln -sv $PWD $GOPATH/src/ 20 | cp -a $PWD $GOPATH/src/ 21 | ln -sv $PWD/xgo $GOPATH/src/ 22 | 23 | cd $GOPATH/src/cygo/bysrc 24 | pwd 25 | 26 | go env 27 | go version 28 | ls 29 | 30 | go build -v -a 31 | ls -lh 32 | # build flag -mod=vendor only valid when using modules 33 | #go build -v -mod=vendor 34 | #ls -lh 35 | 36 | 37 | ./bysrc ./tpkgs/cgo1 38 | ./utests.sh 39 | for f in `ls ./tpkgs/`; do 40 | echo "$PWD ./bysrc ./tpkgs/$f" 41 | # ./bysrc "./tpkgs/$f/" 42 | done 43 | 44 | cd - 45 | 46 | -------------------------------------------------------------------------------- /scripts/build-bysrc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | myexe=$0 6 | if [[ $RUNNER_OS == "macOS" ]]; then 7 | selfdir=$(dirname $(readlink $myexe)) 8 | $selfidr/build-bysrc-macos.sh 9 | elif [[ $RUNNER_OS == "Windows" ]]; then 10 | # should be mingw env that can use pacman 11 | $selfdir/build-bysrc-win.sh 12 | else 13 | selfdir=$(dirname $(readlink -f $myexe)) 14 | $selfdir/build-bysrc-linux.sh 15 | fi 16 | 17 | -------------------------------------------------------------------------------- /scripts/build-libgc-8.0.4x.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | git clone https://github.com/ivmai/bdwgc 4 | ls 5 | wget https://github.com/ivmai/libatomic_ops/releases/download/v7.6.10/libatomic_ops-7.6.10.tar.gz 6 | tar xvf libatomic_ops-7.6.10.tar.gz 7 | mv libatomic_ops-7.6.10 bdwgc/libatomic_ops 8 | 9 | cd bdwgc 10 | ./autogen.sh 11 | ./configure --prefix=/usr 12 | make && sudo make install 13 | cd - 14 | 15 | -------------------------------------------------------------------------------- /scripts/date.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -x 4 | 5 | date 6 | -------------------------------------------------------------------------------- /scripts/preinstall.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # RUNNER_OS=macOS 4 | # RUNNER_OS=Windows 5 | # RUNNER_OS=Linux 6 | 7 | myexe=$0 8 | if [[ $RUNNER_OS == "macOS" ]]; then 9 | selfdir=$(dirname $(readlink $myexe)) 10 | brew install tcc curl 11 | brew install bdw-gc 12 | brew install libevent 13 | elif [[ $RUNNER_OS == "Windows" ]]; then 14 | # should be mingw env that can use pacman 15 | pacman -S --no-confirm tcc curl 16 | pacman -S --no-confirm bdw-gc 17 | pacman -S --no-confirm libevent 18 | else 19 | sudo apt install -y libxcb1-dev libxcb-xkb-dev libx11-xcb-dev libxcb-cursor-dev libxcb-render0-dev libxkbcommon-x11-dev libxkbcommon-dev libdbus-1-dev libcurl4-openssl-dev 20 | sudo apt install -y tcc libtcc-dev 21 | sudo apt remove -y libgc1c2 22 | 23 | selfdir=$(dirname $(readlink -f $myexe)) 24 | $selfdir/build-libgc-8.0.4x.sh 25 | fi 26 | -------------------------------------------------------------------------------- /src/cxiface.c: -------------------------------------------------------------------------------- 1 | #include "cxrtbase.h" 2 | 3 | cxeface cxeface_new_of(void* data) { 4 | cxeface efv = {0}; 5 | efv.data = data; 6 | return efv; 7 | } 8 | cxeface cxeface_new_of2(void* data, int sz) { 9 | cxeface efv = {0}; 10 | efv.data = cxmemdup(data, sz); 11 | return efv; 12 | } 13 | 14 | cxeface cxeface_new_int(int64 v) { 15 | return cxeface_new_of(cxmemdup(&v, sizeof(v))); 16 | } 17 | 18 | cxeface cxeface_new_float(double v) { 19 | return cxeface_new_of(cxmemdup(&v, sizeof(v))); 20 | } 21 | 22 | cxeface cxeface_new_string(cxstring* s) { 23 | return cxeface_new_of(s); 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/cxmemory.c: -------------------------------------------------------------------------------- 1 | 2 | #include "cxrtbase.h" 3 | 4 | extern void* crn_gc_malloc(size_t size); 5 | extern void* crn_gc_realloc(void* ptr, size_t size); 6 | extern void crn_gc_free(void* ptr); 7 | extern void crn_gc_free2(void* ptr); 8 | 9 | void* cxmalloc(size_t size) { 10 | void* ptr = crn_gc_malloc(size); 11 | return ptr; 12 | } 13 | void* cxrealloc(void*ptr, size_t size) { 14 | return crn_gc_realloc(ptr, size); 15 | } 16 | void cxfree(void* ptr) { 17 | crn_gc_free(ptr); 18 | } 19 | void* cxcalloc(size_t blocks, size_t size) { 20 | return crn_gc_malloc(blocks*size); 21 | } 22 | 23 | char* cxstrdup(char* str) { 24 | char* ds = cxmalloc(strlen(str)+1); 25 | strcpy(ds, str); 26 | return ds; 27 | } 28 | 29 | char* cxstrndup(char* str, int n) { 30 | char* ds = cxmalloc(n+1); 31 | strncpy(ds, str, n); 32 | return ds; 33 | } 34 | 35 | void* cxmemdup(void* ptr, int sz) { 36 | void* dp = cxmalloc(sz); 37 | memcpy(dp, ptr, sz); 38 | return dp; 39 | } 40 | 41 | -------------------------------------------------------------------------------- /src/cxqueue.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern void* cxmalloc(size_t size); 5 | extern void* cxcalloc(size_t blocks, size_t size); 6 | extern void cxfree(void* ptr); 7 | 8 | #define DEFAULT_CAPACITY 8 9 | #define DEFAULT_EXPANSION_FACTOR 2 10 | 11 | QueueConf cxdftfqconf = {.capacity = DEFAULT_CAPACITY, 12 | .mem_alloc = cxmalloc, 13 | .mem_calloc = cxcalloc, 14 | .mem_free = cxfree}; 15 | 16 | DequeConf cxdftdqconf = {.capacity = DEFAULT_CAPACITY, 17 | .mem_alloc = cxmalloc, 18 | .mem_calloc = cxcalloc, 19 | .mem_free = cxfree}; 20 | -------------------------------------------------------------------------------- /tests/simlink.c: -------------------------------------------------------------------------------- 1 | 2 | #include "cxpriv.h" 3 | #include "cxrtbase.h" 4 | 5 | int main(int argc, char** argv) { 6 | return 0; 7 | } 8 | 9 | -------------------------------------------------------------------------------- /xgo/adt/adt.go: -------------------------------------------------------------------------------- 1 | package adt 2 | 3 | func Keep() {} 4 | -------------------------------------------------------------------------------- /xgo/adt/queue.go: -------------------------------------------------------------------------------- 1 | package adt 2 | 3 | type Queue struct { 4 | data []voidptr 5 | max int 6 | } 7 | 8 | func NewQueue(max int) *Queue { 9 | assert(max >= 0) 10 | q := &Queue{} 11 | q.max = max 12 | return q 13 | } 14 | 15 | func (q *Queue) Push(v voidptr) bool { 16 | q.data = q.data.append(v) 17 | len := q.data.len 18 | if q.max > 0 && len >= q.max { 19 | // q.data = q.data.right(q.max) // TODO 20 | q.data = q.data[len-q.max:] 21 | } 22 | return true 23 | } 24 | 25 | func (q *Queue) Pop() voidptr { 26 | if q.data.len > 0 { 27 | v := q.data[0] 28 | q.data = q.data[1:] 29 | return v 30 | } 31 | return nil 32 | } 33 | 34 | func (q *Queue) Empty() bool { 35 | return q.data.len == 0 36 | } 37 | func (q *Queue) Len() int { 38 | return q.data.len 39 | } 40 | -------------------------------------------------------------------------------- /xgo/adt/queue_test.go: -------------------------------------------------------------------------------- 1 | package adt 2 | 3 | func test_q1() { 4 | q := NewQueue(3) 5 | println(q.Len(), q.Empty()) 6 | q.Push(q) 7 | q.Push(q) 8 | q.Push(q) 9 | q.Push(q) 10 | q.Push(q) 11 | println(q.Len(), q.Empty()) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /xgo/adt/stack.go: -------------------------------------------------------------------------------- 1 | package adt 2 | 3 | type Stack struct { 4 | data []voidptr 5 | } 6 | 7 | func NewStack() *Stack { 8 | stk := &Stack{} 9 | return stk 10 | } 11 | 12 | func (stk *Stack) Push(v voidptr) bool { 13 | stk.data.append(v) 14 | return true 15 | } 16 | 17 | func (stk *Stack) Pop() voidptr { 18 | if stk.data.len == 0 { 19 | return nil 20 | } 21 | v := stk.data[stk.data.len-1] 22 | stk.data = stk.data[:stk.data.len-1] 23 | return v 24 | } 25 | 26 | func (stk *Stack) Empty() bool { 27 | return stk.data.len == 0 28 | } 29 | func (stk *Stack) Len() int { 30 | return stk.data.len 31 | } 32 | 33 | func (stk *Stack) Clear() { 34 | if stk.data.len == 0 { 35 | return 36 | } 37 | stk.data.clear() 38 | } 39 | -------------------------------------------------------------------------------- /xgo/adt/stack_test.go: -------------------------------------------------------------------------------- 1 | package adt 2 | 3 | func test_stk1() { 4 | stk := NewStack() 5 | println(stk.Len(), stk.Empty()) 6 | stk.Push(q) 7 | println(stk.Len(), stk.Empty()) 8 | stk.Clear() 9 | println(stk.Len(), stk.Empty()) 10 | 11 | stk.Push(q) 12 | q1 := stk.Pop() 13 | println(stk.Len(), stk.Empty(), q1) 14 | q2 := stk.Pop() 15 | println(stk.Len(), stk.Empty(), q2) 16 | 17 | } 18 | -------------------------------------------------------------------------------- /xgo/builtin/array_test.go: -------------------------------------------------------------------------------- 1 | package builtin 2 | 3 | func test_build () { 4 | arr := make([]int, 5) 5 | arr[0] = 111 6 | arr[1] = 222 7 | arr[2] = 333 8 | arr[3] = 444 9 | a3 := arr[3] 10 | println(a3) 11 | alen := arr.len() 12 | println(alen) 13 | 14 | arr.delete(4) 15 | alen = arr.len() 16 | println(alen) 17 | 18 | arr.delete(0) 19 | alen = arr.len() 20 | println(alen) 21 | for idx,e in arr { 22 | println(idx, e) 23 | } 24 | 25 | arr.clear() 26 | alen = arr.len() 27 | println(alen) 28 | } 29 | -------------------------------------------------------------------------------- /xgo/builtin/builtin_test.go: -------------------------------------------------------------------------------- 1 | package builtin 2 | 3 | func test_build() { 4 | 5 | } 6 | 7 | func test_strlen() { 8 | s := "foo" 9 | s.len() == 3 10 | } 11 | -------------------------------------------------------------------------------- /xgo/builtin/closure.go: -------------------------------------------------------------------------------- 1 | package builtin 2 | 3 | const uniform_functype_method = 1 4 | const uniform_functype_bare = 2 5 | const uniform_functype_clos = 2 6 | 7 | type Unifunc struct { 8 | kind int 9 | obj voidptr 10 | under_fnptr func(voidptr) 11 | } 12 | 13 | func (ufn *Unifunc) Call() { 14 | fnptr := ufn.under_fnptr 15 | switch ufn.kind { 16 | case uniform_functype_bare: 17 | fnptr(nil) 18 | case uniform_functype_method: 19 | fnptr(ufn.obj) 20 | case uniform_functype_clos: 21 | fnptr(ufn.obj) 22 | } 23 | } 24 | 25 | struct gxcallable { 26 | isclos voidptr 27 | fnobj voidptr // properply this 28 | ismth usize 29 | fnptr voidptr 30 | } 31 | 32 | // ismth: 0=barefunc, 1=method, 2=anonfunc-with-capvars 33 | //export gxcallable_new 34 | func gxcallable_new(fnptr voidptr, ismth int, obj voidptr) voidptr { 35 | var caobj *gxcallable = malloc3(sizeof(voidptr(0)) * 2) 36 | caobj.isclos = voidptr(1) 37 | caobj.fnobj = obj 38 | caobj.ismth = ismth 39 | caobj.fnptr = fnptr 40 | return caobj 41 | } 42 | -------------------------------------------------------------------------------- /xgo/builtin/hamap_test.go: -------------------------------------------------------------------------------- 1 | package builtin 2 | 3 | func test_hamap1() { 4 | ov := 12345 5 | hv := htkey_hash_int(&ov, 0) 6 | println(hv) 7 | s := "foo" 8 | hv = htkey_hash_str(s.ptr, s.len) 9 | println(hv) 10 | } 11 | 12 | func test_hamap2() { 13 | m1 := mirmap_new(Int) 14 | m1len := m1.len() 15 | m1cap := m1.cap() 16 | println(m1len, m1cap) 17 | 18 | k1 := 5 19 | v1 := 6 20 | m1.insert(&k1, &v1) 21 | m1.dump() 22 | 23 | k2 := 6 24 | v2 := 7 25 | m1.insert(&k2, &v2) 26 | m1.dump() 27 | 28 | k3 := 7 29 | v3 := 8 30 | m1.insert(&k3, &v3) 31 | 32 | m1.dump() 33 | 34 | k3 = 7 35 | v3 = 9 36 | m1.insert(&k3, &v3) 37 | 38 | m1.dump() 39 | 40 | for i := 0; i < 100000; i++ { 41 | k := i 42 | v := i 43 | m1.insert(&k, &v) 44 | } 45 | m1.dumpmin() 46 | m1.chklinked() 47 | m1.clear() 48 | m1.dumpmin() 49 | } 50 | -------------------------------------------------------------------------------- /xgo/curl/useragent.go: -------------------------------------------------------------------------------- 1 | package curl 2 | 3 | const ( 4 | UAP_DEFAULT = 0 5 | UAP_HUMAN // firefox, chrome ... 6 | UAP_RANDOM 7 | ) 8 | 9 | var ( 10 | human_uas = []string{ 11 | // "firefox", "chrome", "IE", "Safari", 12 | "Mozilla/5.0 (X11; Linux x86_64; rv:66.0) Gecko/20100101 Firefox/66.0", 13 | } 14 | ) 15 | 16 | func rand_humanua() string { 17 | ualen := human_uas.len 18 | return human_uas[ualen-1] 19 | } 20 | 21 | func rand_randomua() string { 22 | return "" 23 | } 24 | -------------------------------------------------------------------------------- /xgo/cutil/cutil.go: -------------------------------------------------------------------------------- 1 | package cutil 2 | 3 | // c string list 4 | type Strlist struct { 5 | } 6 | -------------------------------------------------------------------------------- /xgo/dwarf/addr2line.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | // test hehehe 4 | 5 | void addr2line_test(void* addr, char* line, int* lineno) { 6 | return; 7 | } 8 | -------------------------------------------------------------------------------- /xgo/dwarf/addr2line.go: -------------------------------------------------------------------------------- 1 | package dwarf 2 | 3 | /* 4 | #cgo LDFLAGS: -ldwarf 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | // for type resolve 12 | extern int init_elf_dwarf2(); 13 | extern void rtdebug2_addr2line(void*, char*, int*); 14 | */ 15 | import "C" 16 | 17 | func init() { 18 | if false { 19 | C.init_elf_dwarf2() 20 | } 21 | } 22 | 23 | func addr2line1(addr voidptr) (string, int) { 24 | buf := C.cxmalloc(100) 25 | lineno := 0 26 | C.rtdebug2_addr2line(addr, buf, &lineno) 27 | filex := gostring(buf) 28 | return filex, lineno 29 | } 30 | 31 | func test_addr2line() { 32 | println("in here 111") 33 | buf := C.cxmalloc(100) 34 | var addr voidptr = &test_addr2line 35 | lineno := 0 36 | C.rtdebug2_addr2line(addr, buf, &lineno) 37 | filex := gostring(buf) 38 | var file string = filex 39 | println(lineno, file) 40 | } 41 | -------------------------------------------------------------------------------- /xgo/dwarf/helper.go: -------------------------------------------------------------------------------- 1 | package dwarf 2 | 3 | /* 4 | */ 5 | import "C" 6 | 7 | type CU voidptr 8 | type _Die struct { 9 | die_parent Die 10 | die_child Die 11 | die_left Die 12 | die_right Die 13 | die_offset uint64 14 | die_next_off uint64 15 | die_abnum uint64 16 | die_ab Abbrev 17 | die_tag Tag 18 | die_dbg Debug 19 | die_cu CU 20 | die_name byteptr 21 | die_attrarray *Attribute 22 | // STAILQ_HEAD(, _Dwarf_Attribute) die_attr; /* List of attributes. */ 23 | // STAILQ_ENTRY(_Dwarf_Die) die_pro_next; /* Next die in pro-die list. */ 24 | } 25 | 26 | // TODO incorrect result, maybe _Die struct not correct 27 | func (die Die) Dbg() Debug { 28 | var undie *_Die = die 29 | return undie.die_dbg 30 | } 31 | -------------------------------------------------------------------------------- /xgo/dwarf/libbfd.go: -------------------------------------------------------------------------------- 1 | package dwarf 2 | -------------------------------------------------------------------------------- /xgo/fmt/format.go: -------------------------------------------------------------------------------- 1 | package fmt 2 | 3 | func Sprintf(format string, args ...interface{}) string { 4 | slen := len(format) 5 | prepercnt := false 6 | for i := 0; i < slen; i++ { 7 | ch := format[i] 8 | if prepercnt { 9 | if ch == 'd' { 10 | println("int", args[i]) 11 | } else if ch == 's' { 12 | println("str", args[i]) 13 | } else if ch == 'f' { 14 | 15 | } else if ch == 'p' { 16 | 17 | } else { 18 | 19 | } 20 | } 21 | prepercnt = ch == '%' 22 | } 23 | return "aaa" 24 | } 25 | -------------------------------------------------------------------------------- /xgo/math/rand/rand.go: -------------------------------------------------------------------------------- 1 | package rand 2 | 3 | /* 4 | #include 5 | #include 6 | */ 7 | import "C" 8 | 9 | func dummying() { 10 | var p voidptr 11 | } 12 | 13 | func init() { 14 | C.srand(C.time(0)) 15 | } 16 | 17 | func Int() int { 18 | return C.rand() 19 | } 20 | 21 | func Intn(n int) int { 22 | rv := C.rand() 23 | return rv % n 24 | } 25 | -------------------------------------------------------------------------------- /xgo/misc.go: -------------------------------------------------------------------------------- 1 | package xmisc 2 | 3 | func RandName() string { 4 | 5 | } 6 | 7 | func Keep() {} 8 | -------------------------------------------------------------------------------- /xgo/runtime/libc.go: -------------------------------------------------------------------------------- 1 | package runtime 2 | 3 | /* 4 | */ 5 | import "C" 6 | -------------------------------------------------------------------------------- /xgo/src/coro/coroapi.c: -------------------------------------------------------------------------------- 1 | 2 | #include "coro.h" 3 | 4 | /* 5 | void libcoro_create(void* ctx, void* corofp, void* arg, void* sptr, size_t ssze) { 6 | coro_create(ctx, corofp, arg, sptr, ssze); 7 | } 8 | 9 | void libcoro_transfer(void* prev, void* next) { 10 | coro_transfer(prev, next); 11 | } 12 | */ 13 | 14 | void libcoro_destroy (void *ctx) { 15 | coro_destroy(ctx); 16 | } 17 | 18 | -------------------------------------------------------------------------------- /xgo/src/futex/futex_test.v: -------------------------------------------------------------------------------- 1 | /* 2 | module futex 3 | 4 | import time 5 | 6 | fn wait_proc(ft &Futex) { 7 | ft.wait() 8 | println("wait done") 9 | } 10 | 11 | fn test_1() { 12 | ft := newFutex() 13 | ft.wake() 14 | ft.wake() 15 | println("first wake???") 16 | go wait_proc(ft) 17 | time.sleep(3) 18 | ft.wake() 19 | time.sleep(1) 20 | } 21 | 22 | */ 23 | -------------------------------------------------------------------------------- /xgo/src/iohook/minlog.c: -------------------------------------------------------------------------------- 1 | #include "minlog.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | void __attribute__((no_instrument_function)) 11 | crn_simlog(int level, const char *filename, int line, const char* funcname, const char *fmt, ...) { 12 | // if (level > loglvl) return; 13 | static __thread char obuf[612] = {0}; 14 | const char* fbname = strrchr(filename, '/'); 15 | fbname = fbname != NULL ? (fbname++) : filename; 16 | struct timeval ltv = {0}; 17 | gettimeofday(<v, 0); 18 | // crn_loglock(); 19 | int len = snprintf(obuf, sizeof(obuf)-1, "%ld.%ld %s:%d %s: ", 20 | ltv.tv_sec, ltv.tv_usec, fbname, line, funcname); 21 | 22 | va_list args; 23 | va_start(args, fmt); 24 | len += vsnprintf(obuf+len, sizeof(obuf)-len-1, fmt, args); 25 | va_end(args); 26 | obuf[len] = '\0'; 27 | // fprintf(stderr, "%s", buf); 28 | // fflush(stderr); 29 | write(STDERR_FILENO, obuf, len); 30 | // crn_logunlock(); 31 | } 32 | -------------------------------------------------------------------------------- /xgo/src/iopoller/libiopoller.h: -------------------------------------------------------------------------------- 1 | #ifndef LIBIOPOLLER_H 2 | #define LIBIOPOLLER_H 3 | 4 | extern void netpoller_init(void* allocer, void* resumer); 5 | 6 | #endif /* LIBIOPOLLER_H */ 7 | -------------------------------------------------------------------------------- /xgo/src/iopoller/netpoller_test.v: -------------------------------------------------------------------------------- 1 | module iopoller 2 | 3 | 4 | fn test_1() { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /xgo/src/os/command.go: -------------------------------------------------------------------------------- 1 | package os 2 | 3 | /* 4 | #include 5 | */ 6 | import "C" 7 | 8 | type Cmd struct { 9 | cmd string 10 | args []string 11 | } 12 | 13 | func Command(cmd string, args ...string) *Cmd { 14 | cmdo := &Cmd{} 15 | cmdo.cmd = cmd 16 | cmdo.args = args 17 | return cmdo 18 | } 19 | 20 | func (cmd *Cmd) Run() error { 21 | return nil 22 | } 23 | 24 | func (cmd *Cmd) Output() error { 25 | return nil 26 | } 27 | 28 | // err and out 29 | func (cmd *Cmd) Errout() error { 30 | return nil 31 | } 32 | 33 | func Lookup(exename string) (string, error) { 34 | paths := Paths() 35 | for _, dir := range paths { 36 | exepath := dir + PathSep + exename 37 | if FileExist(exepath) { 38 | return exepath, nil 39 | } 40 | } 41 | 42 | return "", newoserr(C.ENOENT) 43 | } 44 | -------------------------------------------------------------------------------- /xgo/src/rand/rand.go: -------------------------------------------------------------------------------- 1 | package rand 2 | 3 | /* 4 | #include 5 | #include 6 | */ 7 | import "C" 8 | 9 | func init() { 10 | t := C.time(nil) 11 | C.srand(t) 12 | } 13 | -------------------------------------------------------------------------------- /xgo/src/vmm/vmm.go: -------------------------------------------------------------------------------- 1 | package vmm 2 | 3 | /* 4 | #cgo CFLAGS: -DGC_THREADS 5 | #cgo LDFLAGS: -lgc -lpthread 6 | 7 | #include 8 | 9 | */ 10 | import "C" 11 | 12 | // GC_StackBase 13 | struct StackInfo { 14 | membase voidptr 15 | regbase voidptr 16 | 17 | // extra 18 | handle voidptr 19 | stksz int 20 | stktop voidptr // membase + stksz 21 | } 22 | 23 | func get_my_stackbottom() *StackInfo { 24 | this := &StackInfo {} 25 | // alloc_lock() // hang!!! 26 | this.handle = C.GC_get_my_stackbottom(this) 27 | // alloc_unlock() 28 | return this 29 | } 30 | func set_stackbottom(si *StackInfo) { 31 | alloc_lock() 32 | C.GC_set_stackbottom(si.handle, si) 33 | alloc_unlock() 34 | } 35 | func set_stackbottom2(si *StackInfo) { 36 | //alloc_lock() 37 | C.GC_set_stackbottom(si.handle, si) 38 | //alloc_unlock() 39 | } 40 | 41 | func alloc_lock() { C.GC_alloc_lock() } 42 | func alloc_unlock() { C.GC_alloc_unlock() } 43 | 44 | -------------------------------------------------------------------------------- /xgo/xasm/asm.go: -------------------------------------------------------------------------------- 1 | package xasm 2 | 3 | /* 4 | void* cygo_asm_demo_full() { 5 | int a = 10; 6 | void* b = 0; 7 | __asm__ ("movl %1, %%eax; movq %%rsp, %0;" 8 | :"=r"(b) // output 9 | :"r"(a) // input 10 | :"%eax" // clobbered register 11 | ); 12 | } 13 | // but it only get SP of current state, not out scope state 14 | void* cygo_asm_getsp() { 15 | void* retval = 0; 16 | __asm__ ("movq %%rsp, %0;" 17 | :"=r"(retval) // output 18 | ); 19 | return retval; 20 | } 21 | */ 22 | import "C" 23 | 24 | const ( 25 | MOVL = iota + 1 26 | ADDL 27 | SUBL 28 | 29 | IMULL 30 | XADDL 31 | 32 | MOV 33 | SUB 34 | ADD 35 | 36 | LOCK 37 | 38 | EAX 39 | EBX 40 | ECX 41 | EDX 42 | ) 43 | 44 | // AT&T 语法,指令 源, 目标 45 | // INTERL语法,指令 目标, 源 46 | // AT&T 寄存器带前缀 %,而 INTEL 语法不带前缀,用来区分是哪种ASM语法 47 | // AT&T 立即数带前缀 $,而 INTEL 语法不带前缀,用来区分是哪种ASM语法 48 | 49 | type VM interface { 50 | mov(src int, dst int) 51 | push(src int, dst int) 52 | pop() 53 | } 54 | 55 | func outasm(code string, outs ...interface{}, ins ...interface{}, clobs ...string) { 56 | // => __asm__(code :"=r"(out0) : "r"(in0) : "clob0") 57 | } 58 | 59 | func keep() {} 60 | -------------------------------------------------------------------------------- /xgo/xdl/dl.go: -------------------------------------------------------------------------------- 1 | package xdl 2 | 3 | /* 4 | #include 5 | */ 6 | import "C" 7 | 8 | const ( 9 | RTLD_LAZY = C.RTLD_LAZY 10 | RTLD_NOW = C.RTLD_NOW 11 | RTLD_BINDING_MASK = C.RTLD_BINDING_MASK 12 | RTLD_NOLOAD = C.RTLD_NOLOAD 13 | RTLD_DEEPBIND = C.RTLD_DEEPBIND 14 | RTLD_NODELETE = C.RTLD_NODELETE 15 | 16 | RTLD_GLOBAL = C.RTLD_GLOBAL 17 | RTLD_LOCAL = C.RTLD_LOCAL 18 | ) 19 | 20 | func open(filename string) voidptr { 21 | return C.dlopen(filename.ptr, 0) 22 | } 23 | func close(handle voidptr) { 24 | C.dlclose(handle) 25 | return 26 | } 27 | func sym(handle voidptr, name string) voidptr { 28 | return C.dlsym(handle, name.ptr) 29 | } 30 | 31 | func error() string { 32 | p := C.dlerror() 33 | return gotring(p) 34 | } 35 | -------------------------------------------------------------------------------- /xgo/xdummy/dummy.go: -------------------------------------------------------------------------------- 1 | package xdummy 2 | 3 | func Keep() {} 4 | -------------------------------------------------------------------------------- /xgo/xerrors/errors.go: -------------------------------------------------------------------------------- 1 | package xerrors 2 | 3 | type ezerror struct { 4 | s string 5 | stacks []string 6 | } 7 | 8 | func (err *ezerror) Error() string { 9 | return err.s 10 | } 11 | 12 | func (err *ezerror) Stacks() []string { 13 | return err.stacks 14 | } 15 | 16 | func New(s string) error { 17 | var err error 18 | err = &ezerror{s} 19 | return err 20 | } 21 | 22 | func Wrap(err error, s string) error { 23 | var olderrpp **ezerror = &err 24 | var olderrp = *olderrpp 25 | 26 | olds := err.Error() 27 | var nerr error 28 | err1 := &ezerror{} 29 | err1.s = s 30 | err1.stacks = olderrp.stacks 31 | err1.stacks = append(err1.stacks, olds) 32 | nerr = err1 33 | return nerr 34 | } 35 | 36 | func Errorf(format string, args ...interface{}) error { 37 | return nil 38 | } 39 | 40 | func Keep() { 41 | 42 | } 43 | -------------------------------------------------------------------------------- /xgo/xlog/log_test.go: -------------------------------------------------------------------------------- 1 | package xlog 2 | 3 | func test_1() { 4 | test_addr2line() 5 | printint(123) 6 | // xlog.printstr("str123") 7 | // xlog.printptr((voidptr)(0x123)) 8 | // xlog.printflt(123.456) 9 | printx(123) 10 | printx(123.456) 11 | var p1 voidptr = 0x5 12 | printx(p1) 13 | printx("eee") 14 | printx('k') 15 | rv := xlog.printx1(true, "eee", 123, 123.456, 'k') 16 | } 17 | -------------------------------------------------------------------------------- /xgo/xmath/math.go: -------------------------------------------------------------------------------- 1 | package xmath 2 | 3 | /* 4 | #include 5 | */ 6 | import "C" 7 | 8 | func Keep() {} 9 | 10 | func Absint(j int) int { 11 | return C.abs(j) 12 | } 13 | 14 | func Absi64(j int64) int64 { 15 | return C.llabs(j) 16 | } 17 | -------------------------------------------------------------------------------- /xgo/xnet/httpcli.go: -------------------------------------------------------------------------------- 1 | package xnet 2 | 3 | type Request struct { 4 | Method string 5 | Headers map[string]string 6 | Uri string 7 | } 8 | 9 | type Response struct { 10 | Stcode int 11 | Stline string 12 | Ctlength i64 13 | Headers map[string]string 14 | Data string 15 | } 16 | 17 | type Client struct { 18 | } 19 | 20 | func NewRequest(method string, uri string, data voidptr) *Request { 21 | req := &Request{} 22 | req.Method = method 23 | req.Uri = uri 24 | 25 | return req 26 | } 27 | 28 | func (c *Client) Do(req *Request) (*Response, error) { 29 | return nil, nil 30 | } 31 | 32 | func Get() { 33 | 34 | } 35 | 36 | func Post() { 37 | 38 | } 39 | 40 | func Put() { 41 | 42 | } 43 | 44 | func Delete() { 45 | 46 | } 47 | -------------------------------------------------------------------------------- /xgo/xnet/httpcom.go: -------------------------------------------------------------------------------- 1 | package xnet 2 | 3 | const ( 4 | MethodGet = "GET" 5 | MethodPost = "POST" 6 | MethodPut = "PUT" 7 | MethodDelete = "DELETE" 8 | ) 9 | -------------------------------------------------------------------------------- /xgo/xnet/httpsrv.go: -------------------------------------------------------------------------------- 1 | package xnet 2 | -------------------------------------------------------------------------------- /xgo/xnet/ifaces.go: -------------------------------------------------------------------------------- 1 | package xnet 2 | 3 | type Listener interface { 4 | Accept() (int, error) 5 | } 6 | 7 | type Conn interface { 8 | Read(b []byte) (int, error) 9 | Write(b []byte) (int, error) 10 | Close() error 11 | } 12 | -------------------------------------------------------------------------------- /xgo/xnet/url_parser_test.go: -------------------------------------------------------------------------------- 1 | package xnet 2 | 3 | func test_urlpr1() { 4 | uo := ParseUrl("https://www.google.com/foo") 5 | println(uo) 6 | // xlog.Println(uo.Scheme, uo.Host, uo.Path) 7 | } 8 | -------------------------------------------------------------------------------- /xgo/xstrconv/strconv.go: -------------------------------------------------------------------------------- 1 | package xstrconv 2 | 3 | /* 4 | #include 5 | */ 6 | import "C" 7 | 8 | func Atoi(s string) int { 9 | rv := C.atoi(s.ptr) 10 | return rv 11 | } 12 | func Atol(s string) i64 { 13 | rv := C.atoll(s.ptr) 14 | return rv 15 | } 16 | func Atof(s string) f32 { 17 | rv := C.atof(s.ptr) 18 | return rv 19 | } 20 | -------------------------------------------------------------------------------- /xgo/xstrings/builder.go: -------------------------------------------------------------------------------- 1 | package xstrings 2 | 3 | /* 4 | */ 5 | import "C" 6 | 7 | type Builder struct { 8 | data []byte 9 | } 10 | 11 | func NewBuilder() *Builder { 12 | sb := &Builder{} 13 | return sb 14 | } 15 | 16 | func (sb *Builder) Write(s string) { 17 | sb.data.appendn(s.ptr, s.len) 18 | // C.cxarray2_appendn(sb.data, s, len(s)) 19 | } 20 | 21 | func (sb *Builder) Write2() { 22 | 23 | } 24 | 25 | func (sb *Builder) Len() int { 26 | return len(sb.data) 27 | } 28 | 29 | func (sb *Builder) String() string { 30 | blen := len(sb.data) 31 | // s := string(sb.data) // not work 32 | s := gostringn(sb, blen) 33 | return s 34 | } 35 | --------------------------------------------------------------------------------