├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── config.yml │ └── feature_request.yml └── workflows │ ├── go-cross.yml │ ├── main.yml │ └── release.yml ├── .gitignore ├── .golangci.yml ├── .goreleaser.yml ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── _test ├── a1.go ├── a10.go ├── a11.go ├── a12.go ├── a13.go ├── a14.go ├── a15.go ├── a16.go ├── a17.go ├── a18.go ├── a19.go ├── a2.go ├── a20.go ├── a21.go ├── a22.go ├── a23.go ├── a24.go ├── a25.go ├── a26.go ├── a27.go ├── a28.go ├── a29.go ├── a3.go ├── a30.go ├── a31.go ├── a32.go ├── a33.go ├── a34.go ├── a35.go ├── a36.go ├── a37.go ├── a38.go ├── a39.go ├── a4.go ├── a40.go ├── a41.go ├── a42.go ├── a43.go ├── a44.go ├── a5.go ├── a6.go ├── a7.go ├── a8.go ├── a9.go ├── add0.go ├── add1.go ├── add2.go ├── addr0.go ├── addr1.go ├── addr2.go ├── addr3.go ├── addr4.go ├── addr5.go ├── and.go ├── and0.go ├── and1.go ├── and2.go ├── and3.go ├── append0.go ├── append1.go ├── append2.go ├── append3.go ├── append4.go ├── assert0.go ├── assert1.go ├── assert2.go ├── assert3.go ├── assert4.go ├── assign.go ├── assign0.go ├── assign1.go ├── assign10.go ├── assign11.go ├── assign12.go ├── assign13.go ├── assign14.go ├── assign15.go ├── assign16.go ├── assign17.go ├── assign18.go ├── assign19.go ├── assign2.go ├── assign3.go ├── assign4.go ├── assign5.go ├── assign6.go ├── assign7.go ├── assign8.go ├── assign9.go ├── b1 │ └── foo │ │ └── foo.go ├── b2 │ └── foo │ │ └── foo.go ├── bad0.go ├── baz-bat │ └── baz-bat.go ├── bin.go ├── bin0.go ├── bin1.go ├── bin2.go ├── bin3.go ├── bin4.go ├── bin5.go ├── binstruct_ptr_map0.go ├── binstruct_ptr_slice0.go ├── binstruct_slice0.go ├── bltn.go ├── bltn0.go ├── bool.go ├── bool0.go ├── bool1.go ├── bool2.go ├── bool3.go ├── bool4.go ├── bool5.go ├── break0.go ├── break1.go ├── break2.go ├── break3.go ├── c1 │ └── c1.go ├── c2 │ └── c2.go ├── cap0.go ├── chan0.go ├── chan1.go ├── chan10.go ├── chan2.go ├── chan3.go ├── chan4.go ├── chan5.go ├── chan6.go ├── chan7.go ├── chan8.go ├── chan9.go ├── cli1.go ├── cli2.go ├── cli3.go ├── cli4.go ├── cli5.go ├── cli6.go ├── cli7.go ├── cli8.go ├── closure0.go ├── closure1.go ├── closure10.go ├── closure11.go ├── closure12.go ├── closure13.go ├── closure14.go ├── closure15.go ├── closure16.go ├── closure17.go ├── closure18.go ├── closure19.go ├── closure2.go ├── closure20.go ├── closure3.go ├── closure4.go ├── closure5.go ├── closure6.go ├── closure7.go ├── closure8.go ├── closure9.go ├── comp0.go ├── comp1.go ├── comp2.go ├── complex0.go ├── complex1.go ├── complex2.go ├── complex3.go ├── complex4.go ├── composite0.go ├── composite1.go ├── composite10.go ├── composite11.go ├── composite12.go ├── composite13.go ├── composite14.go ├── composite15.go ├── composite16.go ├── composite17.go ├── composite18.go ├── composite19.go ├── composite2.go ├── composite3.go ├── composite4.go ├── composite5.go ├── composite6.go ├── composite7.go ├── composite8.go ├── composite8bis.go ├── composite9.go ├── const0.go ├── const1.go ├── const10.go ├── const11.go ├── const12.go ├── const13.go ├── const14.go ├── const15.go ├── const16.go ├── const17.go ├── const18.go ├── const19.go ├── const2.go ├── const20.go ├── const21.go ├── const22.go ├── const23.go ├── const24.go ├── const25.go ├── const26.go ├── const3.go ├── const4.go ├── const5.go ├── const6.go ├── const7.go ├── const8.go ├── const9.go ├── cont.go ├── cont0.go ├── cont1.go ├── cont2.go ├── cont3.go ├── context.go ├── context2.go ├── convert0.go ├── convert1.go ├── convert2.go ├── convert3.go ├── copy0.go ├── copy1.go ├── copy2.go ├── ct │ ├── ct1.go │ ├── ct2.go │ └── ct3.go ├── ct1 │ └── ct1.go ├── d1 │ └── d1.go ├── d2 │ └── d2.go ├── d3.go ├── defer0.go ├── defer1.go ├── defer2.go ├── defer3.go ├── defer4.go ├── defer5.go ├── defer6.go ├── defer7.go ├── defer8.go ├── defer9.go ├── delete0.go ├── eval0.go ├── export0.go ├── export1.go ├── factor.go ├── fib.go ├── fib0.go ├── file_access.go ├── flag0.go ├── foo-bar │ └── foo-bar.go ├── foo │ ├── bar.go │ ├── bir.go │ └── boo │ │ └── boo.go ├── for0.go ├── for1.go ├── for10.go ├── for11.go ├── for12.go ├── for13.go ├── for14.go ├── for15.go ├── for16.go ├── for17.go ├── for18.go ├── for19.go ├── for2.go ├── for3.go ├── for4.go ├── for5.go ├── for6.go ├── for7.go ├── for8.go ├── for9.go ├── fun.go ├── fun10.go ├── fun11.go ├── fun12.go ├── fun13.go ├── fun14.go ├── fun15.go ├── fun16.go ├── fun17.go ├── fun18.go ├── fun19.go ├── fun2.go ├── fun20.go ├── fun21.go ├── fun22.go ├── fun23.go ├── fun24.go ├── fun25.go ├── fun26.go ├── fun27.go ├── fun28.go ├── fun3.go ├── fun4.go ├── fun5.go ├── fun6.go ├── fun7.go ├── fun8.go ├── fun9.go ├── gen1.go ├── gen10.go ├── gen11.go ├── gen12.go ├── gen13.go ├── gen2.go ├── gen3.go ├── gen4.go ├── gen5.go ├── gen6.go ├── gen7.go ├── gen8.go ├── gen9.go ├── goto0.go ├── goto1.go ├── heap.go ├── if.go ├── if0.go ├── if1.go ├── if2.go ├── if3.go ├── if4.go ├── if5.go ├── if6.go ├── if7.go ├── imag0.go ├── import0.go ├── import1.go ├── import2.go ├── import3.go ├── import4.go ├── import5.go ├── import6.go ├── import7.go ├── import8.go ├── import9.go ├── inc.go ├── inception.go ├── init0.go ├── init1.go ├── interface0.go ├── interface1.go ├── interface10.go ├── interface11.go ├── interface12.go ├── interface13.go ├── interface14.go ├── interface15.go ├── interface16.go ├── interface17.go ├── interface18.go ├── interface19.go ├── interface2.go ├── interface20.go ├── interface21.go ├── interface22.go ├── interface23.go ├── interface24.go ├── interface25.go ├── interface26.go ├── interface27.go ├── interface28.go ├── interface29.go ├── interface3.go ├── interface30.go ├── interface31.go ├── interface32.go ├── interface33.go ├── interface34.go ├── interface35.go ├── interface36.go ├── interface37.go ├── interface38.go ├── interface39.go ├── interface4.go ├── interface40.go ├── interface41.go ├── interface42.go ├── interface43.go ├── interface44.go ├── interface45.go ├── interface46.go ├── interface47.go ├── interface48.go ├── interface49.go ├── interface5.go ├── interface50.go ├── interface51.go ├── interface52.go ├── interface6.go ├── interface7.go ├── interface8.go ├── interface9.go ├── interp.gi ├── interp2.gi ├── io0.go ├── io1.go ├── io2.go ├── iota.go ├── iota0.go ├── ipp_as_key.go ├── issue-1007.go ├── issue-1010.go ├── issue-1022.go ├── issue-1052.go ├── issue-1065.go ├── issue-1068.go ├── issue-1088.go ├── issue-1089.go ├── issue-1093.go ├── issue-1094.go ├── issue-1101.go ├── issue-1115.go ├── issue-1126.go ├── issue-1128.go ├── issue-1134.go ├── issue-1136.go ├── issue-1145.go ├── issue-1156.go ├── issue-1163.go ├── issue-1166.go ├── issue-1167.go ├── issue-1173.go ├── issue-1175.go ├── issue-1177.go ├── issue-1179.go ├── issue-1181.go ├── issue-1185.go ├── issue-1187.go ├── issue-1189.go ├── issue-1202.go ├── issue-1205.go ├── issue-1208.go ├── issue-1260.go ├── issue-1276.go ├── issue-1280.go ├── issue-1285.go ├── issue-1288.go ├── issue-1300.go ├── issue-1304.go ├── issue-1306.go ├── issue-1308.go ├── issue-1311.go ├── issue-1315.go ├── issue-1320.go ├── issue-1326.go ├── issue-1328.go ├── issue-1330.go ├── issue-1332.go ├── issue-1333.go ├── issue-1337.go ├── issue-1342.go ├── issue-1344.go ├── issue-1354.go ├── issue-1355.go ├── issue-1360.go ├── issue-1361.go ├── issue-1364.go ├── issue-1365.go ├── issue-1368.go ├── issue-1371.go ├── issue-1373.go ├── issue-1375.go ├── issue-1378.go ├── issue-1381.go ├── issue-1404.go ├── issue-1408.go ├── issue-1411.go ├── issue-1416.go ├── issue-1421.go ├── issue-1425.go ├── issue-1439.go ├── issue-1442.go ├── issue-1447.go ├── issue-1451.go ├── issue-1454.go ├── issue-1459.go ├── issue-1460.go ├── issue-1465.go ├── issue-1466.go ├── issue-1470.go ├── issue-1475.go ├── issue-1488.go ├── issue-1496.go ├── issue-1515.go ├── issue-1536.go ├── issue-1571.go ├── issue-1594.go ├── issue-1618.go ├── issue-1640.go ├── issue-1653.go ├── issue-435.go ├── issue-558.go ├── issue-735.go ├── issue-770.go ├── issue-772.go ├── issue-775.go ├── issue-776.go ├── issue-782.go ├── issue-784.go ├── issue-880.go ├── issue-981.go ├── issue-993.go ├── l2.go ├── l3.go ├── l4.go ├── l5.go ├── len0.go ├── m1 │ ├── main.go │ └── main_test.go ├── m2 │ └── m2_test.go ├── make.go ├── make0.go ├── make1.go ├── make2.go ├── map.go ├── map10.go ├── map11.go ├── map12.go ├── map13.go ├── map14.go ├── map15.go ├── map16.go ├── map17.go ├── map18.go ├── map19.go ├── map2.go ├── map20.go ├── map21.go ├── map22.go ├── map23.go ├── map24.go ├── map25.go ├── map26.go ├── map27.go ├── map28.go ├── map29.go ├── map3.go ├── map30.go ├── map31.go ├── map4.go ├── map5.go ├── map6.go ├── map7.go ├── map8.go ├── map9.go ├── math0.go ├── math1.go ├── math2.go ├── math3.go ├── method.go ├── method0.go ├── method1.go ├── method10.go ├── method11.go ├── method12.go ├── method13.go ├── method14.go ├── method15.go ├── method16.go ├── method17.go ├── method18.go ├── method19.go ├── method2.go ├── method20.go ├── method21.go ├── method22.go ├── method23.go ├── method24.go ├── method25.go ├── method26.go ├── method27.go ├── method28.go ├── method29.go ├── method3.go ├── method30.go ├── method31.go ├── method32.go ├── method33.go ├── method34.go ├── method35.go ├── method36.go ├── method37.go ├── method38.go ├── method38 │ ├── a.go │ └── b.go ├── method39.go ├── method4.go ├── method40.go ├── method5.go ├── method6.go ├── method7.go ├── method8.go ├── method9.go ├── named0.go ├── named1.go ├── named2.go ├── named3.go ├── named3 │ └── named3.go ├── named4.go ├── neg0.go ├── new0.go ├── new1.go ├── new2.go ├── nil0.go ├── nil1.go ├── nil2.go ├── nil3.go ├── not0.go ├── not1.go ├── not2.go ├── num0.go ├── op0.go ├── op1.go ├── op10.go ├── op11.go ├── op2.go ├── op3.go ├── op4.go ├── op5.go ├── op6.go ├── op7.go ├── op8.go ├── op9.go ├── opfloat32.go ├── opfloat64.go ├── opint16.go ├── opint32.go ├── opint64.go ├── opint8.go ├── opstring.go ├── opuint16.go ├── opuint32.go ├── opuint64.go ├── opuint8.go ├── or0.go ├── or1.go ├── or2.go ├── os0.go ├── p1 │ ├── s1.go │ └── s2.go ├── p2 │ └── p2.go ├── p3 │ └── empty ├── p4 │ └── p4.go ├── p5.go ├── p5 │ └── p5.go ├── p6.go ├── p6 │ └── p6.go ├── panic0.go ├── pkgname0.go ├── pkgname1.go ├── pkgname2.go ├── primes.go ├── print0.go ├── ptr0.go ├── ptr1.go ├── ptr2.go ├── ptr3.go ├── ptr4.go ├── ptr5.go ├── ptr5a.go ├── ptr6.go ├── ptr7.go ├── ptr8.go ├── ptr_array0.go ├── ptr_array1.go ├── ptr_array2.go ├── ptr_array3.go ├── range0.go ├── range1.go ├── range2.go ├── range3.go ├── range4.go ├── range5.go ├── range6.go ├── range7.go ├── range8.go ├── range9.go ├── real0.go ├── recover0.go ├── recover1.go ├── recover2.go ├── recover3.go ├── recover4.go ├── recurse0.go ├── recurse1.go ├── recurse2.go ├── recurse3.go ├── redeclaration-global0.go ├── redeclaration-global1.go ├── redeclaration-global2.go ├── redeclaration-global3.go ├── redeclaration-global4.go ├── redeclaration-global5.go ├── redeclaration-global6.go ├── redeclaration-global7.go ├── redeclaration0.go ├── redeclaration1.go ├── redeclaration2.go ├── redeclaration3.go ├── redeclaration4.go ├── redeclaration5.go ├── restricted0.go ├── restricted1.go ├── restricted2.go ├── restricted3.go ├── ret1.go ├── ret2.go ├── ret3.go ├── ret4.go ├── ret5.go ├── ret6.go ├── ret7.go ├── ret8.go ├── run0.go ├── run1.go ├── run10.go ├── run11.go ├── run12.go ├── run13.go ├── run4.go ├── run5.go ├── run6.go ├── run7.go ├── run8.go ├── run9.go ├── rune0.go ├── rune1.go ├── rune2.go ├── sample.plugin ├── scope0.go ├── scope1.go ├── scope2.go ├── scope3.go ├── scope4.go ├── scope5.go ├── scope6.go ├── scope7.go ├── secure.gi ├── select.go ├── select0.go ├── select1.go ├── select10.go ├── select11.go ├── select12.go ├── select13.go ├── select14.go ├── select15.go ├── select2.go ├── select3.go ├── select4.go ├── select5.go ├── select6.go ├── select7.go ├── select8.go ├── select9.go ├── selector-scope0.go ├── server.go ├── server0.go ├── server1.go ├── server1a.go ├── server2.go ├── server3.go ├── server4.go ├── server5.go ├── server6.go ├── server7.go ├── shift0.go ├── shift1.go ├── shift2.go ├── shift3.go ├── sieve.go ├── slice.go ├── str.go ├── str0.go ├── str1.go ├── str2.go ├── str3.go ├── str4.go ├── struct.go ├── struct0.go ├── struct0a.go ├── struct1.go ├── struct10.go ├── struct11.go ├── struct12.go ├── struct13.go ├── struct14.go ├── struct15.go ├── struct16.go ├── struct17.go ├── struct18.go ├── struct19.go ├── struct2.go ├── struct20.go ├── struct21.go ├── struct22.go ├── struct23.go ├── struct24.go ├── struct25.go ├── struct26.go ├── struct27.go ├── struct28.go ├── struct29.go ├── struct3.go ├── struct30.go ├── struct31.go ├── struct32.go ├── struct33.go ├── struct34.go ├── struct35.go ├── struct36.go ├── struct37.go ├── struct38.go ├── struct39.go ├── struct4.go ├── struct40.go ├── struct41.go ├── struct42.go ├── struct43.go ├── struct44.go ├── struct45.go ├── struct46.go ├── struct47.go ├── struct48.go ├── struct49.go ├── struct5.go ├── struct50.go ├── struct51.go ├── struct52.go ├── struct53.go ├── struct54.go ├── struct55.go ├── struct56.go ├── struct57.go ├── struct58.go ├── struct59.go ├── struct6.go ├── struct60.go ├── struct61.go ├── struct62.go ├── struct7.go ├── struct8.go ├── struct9.go ├── switch.go ├── switch0.go ├── switch1.go ├── switch10.go ├── switch11.go ├── switch12.go ├── switch13.go ├── switch14.go ├── switch15.go ├── switch16.go ├── switch17.go ├── switch18.go ├── switch19.go ├── switch2.go ├── switch20.go ├── switch21.go ├── switch22.go ├── switch23.go ├── switch24.go ├── switch25.go ├── switch26.go ├── switch27.go ├── switch28.go ├── switch29.go ├── switch3.go ├── switch30.go ├── switch31.go ├── switch32.go ├── switch33.go ├── switch34.go ├── switch35.go ├── switch36.go ├── switch37.go ├── switch38.go ├── switch39.go ├── switch4.go ├── switch40.go ├── switch5.go ├── switch6.go ├── switch7.go ├── switch8.go ├── switch9.go ├── tag0.go ├── testdata │ └── redeclaration-global7 │ │ └── src │ │ └── guthib.com │ │ ├── bar │ │ └── quux.go │ │ ├── baz │ │ └── quux.go │ │ ├── tata │ │ └── tutu.go │ │ └── toto │ │ └── titi.go ├── time0.go ├── time1.go ├── time10.go ├── time11.go ├── time12.go ├── time13.go ├── time14.go ├── time15.go ├── time16.go ├── time2.go ├── time3.go ├── time4.go ├── time5.go ├── time6.go ├── time7.go ├── time8.go ├── time9.go ├── type0.go ├── type1.go ├── type10.go ├── type11.go ├── type12.go ├── type13.go ├── type14.go ├── type15.go ├── type16.go ├── type17.go ├── type18.go ├── type19.go ├── type2.go ├── type20.go ├── type21.go ├── type22.go ├── type23.go ├── type24.go ├── type25.go ├── type26.go ├── type27.go ├── type28.go ├── type29.go ├── type3.go ├── type30.go ├── type31.go ├── type32.go ├── type33.go ├── type34.go ├── type4.go ├── type5.go ├── type6.go ├── type7.go ├── type8.go ├── type9.go ├── unsafe0.go ├── unsafe1.go ├── unsafe10.go ├── unsafe2.go ├── unsafe3.go ├── unsafe4.go ├── unsafe5.go ├── unsafe6.go ├── unsafe7.go ├── unsafe8.go ├── var.go ├── var10.go ├── var11.go ├── var12.go ├── var13.go ├── var14.go ├── var15.go ├── var16.go ├── var2.go ├── var3.go ├── var4.go ├── var5.go ├── var6.go ├── var7.go ├── var8.go ├── var9.go ├── variadic.go ├── variadic0.go ├── variadic1.go ├── variadic10.go ├── variadic2.go ├── variadic3.go ├── variadic4.go ├── variadic5.go ├── variadic6.go ├── variadic7.go ├── variadic8.go ├── variadic9.go └── vars │ ├── first.go │ └── second.go ├── cmd └── yaegi │ ├── extract.go │ ├── help.go │ ├── run.go │ ├── test.go │ ├── yaegi.go │ └── yaegi_test.go ├── doc └── images │ └── yaegi.png ├── example ├── closure │ ├── _pkg │ │ └── src │ │ │ └── foo │ │ │ └── bar │ │ │ └── bar.go │ └── closure_test.go ├── fs │ └── fs_test.go ├── getfunc │ ├── _gopath │ │ └── src │ │ │ └── github.com │ │ │ └── foo │ │ │ └── bar │ │ │ └── foobar.go │ └── getfunc_test.go └── pkg │ ├── _pkg │ └── src │ │ └── github.com │ │ └── foo │ │ └── pkg │ │ ├── pkg.go │ │ └── vendor │ │ └── guthib.com │ │ └── traefik │ │ └── fromage │ │ └── fromage.go │ ├── _pkg0 │ └── src │ │ └── github.com │ │ └── foo │ │ └── pkg │ │ ├── fromage │ │ ├── cheese │ │ │ └── cheese.go │ │ └── fromage.go │ │ └── pkg.go │ ├── _pkg1 │ └── src │ │ └── github.com │ │ └── foo │ │ └── pkg │ │ ├── fromage │ │ └── fromage.go │ │ └── pkg.go │ ├── _pkg10 │ └── src │ │ └── github.com │ │ └── foo │ │ ├── pkg.go │ │ └── vendor │ │ └── guthib.com │ │ └── traefik │ │ └── fromage │ │ └── fromage.go │ ├── _pkg11 │ └── src │ │ └── foo │ │ ├── foo.go │ │ └── vendor │ │ └── guthib.com │ │ └── traefik │ │ └── fromage │ │ └── fromage.go │ ├── _pkg12 │ └── src │ │ └── guthib.com │ │ └── foo │ │ ├── main.go │ │ ├── pkg │ │ └── pkg.go │ │ └── vendor │ │ └── guthib.com │ │ └── bar │ │ └── bar.go │ ├── _pkg13 │ └── src │ │ └── guthib.com │ │ └── foo │ │ └── bar │ │ ├── main.go │ │ └── vendor │ │ └── guthib.com │ │ └── bat │ │ └── baz │ │ └── baz.go │ ├── _pkg2 │ └── src │ │ └── github.com │ │ └── foo │ │ └── pkg │ │ ├── pkg.go │ │ └── vendor │ │ └── guthib.com │ │ └── traefik │ │ └── fromage │ │ ├── fromage.go │ │ └── vendor │ │ └── guthib.com │ │ └── traefik │ │ └── cheese │ │ └── fromage.go │ ├── _pkg3 │ └── src │ │ └── github.com │ │ └── foo │ │ └── pkg │ │ ├── pkg.go │ │ └── vendor │ │ └── guthib.com │ │ └── traefik │ │ └── fromage │ │ ├── couteau │ │ └── couteau.go │ │ ├── fromage.go │ │ └── vendor │ │ └── guthib.com │ │ └── traefik │ │ └── cheese │ │ └── fromage.go │ ├── _pkg4 │ └── src │ │ └── github.com │ │ └── foo │ │ └── pkg │ │ ├── pkg.go │ │ └── vendor │ │ └── guthib.com │ │ └── traefik │ │ └── fromage │ │ ├── couteau │ │ └── couteau.go │ │ ├── fromage.go │ │ └── vendor │ │ └── guthib.com │ │ └── traefik │ │ └── cheese │ │ ├── cheese.go │ │ └── vin │ │ └── vin.go │ ├── _pkg5 │ └── src │ │ └── github.com │ │ └── foo │ │ └── pkg │ │ ├── pkg.go │ │ └── vendor │ │ └── guthib.com │ │ └── traefik │ │ ├── cheese │ │ ├── cheese.go │ │ └── vin │ │ │ └── vin.go │ │ └── fromage │ │ ├── couteau │ │ └── couteau.go │ │ └── fromage.go │ ├── _pkg6 │ └── src │ │ ├── github.com │ │ └── foo │ │ │ └── pkg │ │ │ ├── pkg.go │ │ │ └── vendor │ │ │ └── guthib.com │ │ │ └── traefik │ │ │ └── fromage │ │ │ ├── couteau │ │ │ └── couteau.go │ │ │ └── fromage.go │ │ └── guthib.com │ │ └── traefik │ │ └── cheese │ │ ├── cheese.go │ │ └── vin │ │ └── vin.go │ ├── _pkg7 │ └── src │ │ └── github.com │ │ └── foo │ │ └── pkg │ │ ├── pkg.go │ │ └── vendor │ │ └── guthib.com │ │ └── traefik │ │ ├── fromage │ │ └── fromage.go │ │ └── vin │ │ ├── vendor │ │ └── guthib.com │ │ │ └── traefik │ │ │ └── cheese │ │ │ └── cheese.go │ │ └── vin.go │ ├── _pkg8 │ └── src │ │ └── github.com │ │ └── foo │ │ └── pkg │ │ ├── fromage │ │ └── fromage.go │ │ └── pkg.go │ ├── _pkg9 │ └── src │ │ └── github.com │ │ └── foo │ │ └── pkg │ │ ├── fromage │ │ └── fromage.go │ │ ├── pkg.go │ │ └── pkgfalse.go │ └── pkg_test.go ├── extract ├── extract.go ├── extract_test.go └── testdata │ ├── 1 │ └── src │ │ └── guthib.com │ │ ├── bar │ │ └── main.go │ │ └── baz │ │ ├── baz.go │ │ └── go.mod │ ├── 2 │ └── src │ │ └── guthib.com │ │ ├── bar │ │ └── main.go │ │ └── baz │ │ └── baz.go │ ├── 3 │ └── src │ │ └── guthib.com │ │ ├── bar │ │ └── main.go │ │ └── baz │ │ ├── baz.go │ │ └── go.mod │ ├── 4 │ └── src │ │ └── guthib.com │ │ └── bar │ │ ├── main.go │ │ └── vendor │ │ └── guthib.com │ │ └── baz │ │ ├── baz.go │ │ └── go.mod │ ├── 5 │ └── src │ │ └── guthib.com │ │ └── bar │ │ ├── main.go │ │ └── vendor │ │ └── guthib.com │ │ └── baz │ │ └── baz.go │ ├── 6 │ └── src │ │ └── guthib.com │ │ ├── bar │ │ └── main.go │ │ └── baz-baz │ │ ├── baz.go │ │ └── go.mod │ └── 7 │ └── src │ └── guthib.com │ └── variadic │ ├── go.mod │ └── variadic.go ├── generate.go ├── go.mod ├── install.sh ├── internal ├── cmd │ ├── extract │ │ └── extract.go │ └── genop │ │ └── genop.go └── unsafe2 │ ├── go1_20_unsafe.go │ ├── go1_21_unsafe.go │ └── unsafe_test.go ├── interp ├── ast.go ├── build.go ├── build_test.go ├── cfg.go ├── compile_test.go ├── debugger.go ├── doc.go ├── dot.go ├── example_eval_test.go ├── export_test.go ├── generic.go ├── gta.go ├── hooks.go ├── interp.go ├── interp_consistent_test.go ├── interp_eval_test.go ├── interp_export_test.go ├── interp_file_test.go ├── interp_issue_1634_test.go ├── interp_test.go ├── op.go ├── program.go ├── realfs.go ├── run.go ├── scope.go ├── self_example_test.go ├── src.go ├── src_test.go ├── testdata │ ├── concurrent │ │ ├── composite │ │ │ ├── composite_lit.go │ │ │ └── composite_sparse.go │ │ ├── hello1.go │ │ └── hello2.go │ ├── multi │ │ └── 731 │ │ │ ├── sample1.go │ │ │ ├── sample2.go │ │ │ └── sample3.go │ └── src │ │ └── github.com │ │ └── foo │ │ ├── bar │ │ └── baz │ │ │ └── baz.go │ │ └── vendor │ │ └── whatever │ │ └── whatever.go ├── trace.go ├── type.go ├── typecheck.go ├── typestring.go ├── use.go └── value.go └── stdlib ├── generic ├── go1_21_cmp.go.txt ├── go1_21_generic.go ├── go1_21_maps.go.txt ├── go1_21_slices.go.txt ├── go1_21_sync.go.txt ├── go1_21_sync_atomic.go.txt ├── go1_22_cmp_cmp.go.txt ├── go1_22_generic.go ├── go1_22_maps_maps.go.txt ├── go1_22_slices_slices.go.txt ├── go1_22_slices_sort.go.txt ├── go1_22_slices_zsortanyfunc.go.txt ├── go1_22_sync_atomic_type.go.txt └── go1_22_sync_oncefunc.go.txt ├── go1_21_archive_tar.go ├── go1_21_archive_zip.go ├── go1_21_bufio.go ├── go1_21_bytes.go ├── go1_21_cmp.go ├── go1_21_compress_bzip2.go ├── go1_21_compress_flate.go ├── go1_21_compress_gzip.go ├── go1_21_compress_lzw.go ├── go1_21_compress_zlib.go ├── go1_21_container_heap.go ├── go1_21_container_list.go ├── go1_21_container_ring.go ├── go1_21_context.go ├── go1_21_crypto.go ├── go1_21_crypto_aes.go ├── go1_21_crypto_cipher.go ├── go1_21_crypto_des.go ├── go1_21_crypto_dsa.go ├── go1_21_crypto_ecdh.go ├── go1_21_crypto_ecdsa.go ├── go1_21_crypto_ed25519.go ├── go1_21_crypto_elliptic.go ├── go1_21_crypto_hmac.go ├── go1_21_crypto_md5.go ├── go1_21_crypto_rand.go ├── go1_21_crypto_rc4.go ├── go1_21_crypto_rsa.go ├── go1_21_crypto_sha1.go ├── go1_21_crypto_sha256.go ├── go1_21_crypto_sha512.go ├── go1_21_crypto_subtle.go ├── go1_21_crypto_tls.go ├── go1_21_crypto_x509.go ├── go1_21_crypto_x509_pkix.go ├── go1_21_database_sql.go ├── go1_21_database_sql_driver.go ├── go1_21_debug_buildinfo.go ├── go1_21_debug_dwarf.go ├── go1_21_debug_elf.go ├── go1_21_debug_gosym.go ├── go1_21_debug_macho.go ├── go1_21_debug_pe.go ├── go1_21_debug_plan9obj.go ├── go1_21_encoding.go ├── go1_21_encoding_ascii85.go ├── go1_21_encoding_asn1.go ├── go1_21_encoding_base32.go ├── go1_21_encoding_base64.go ├── go1_21_encoding_binary.go ├── go1_21_encoding_csv.go ├── go1_21_encoding_gob.go ├── go1_21_encoding_hex.go ├── go1_21_encoding_json.go ├── go1_21_encoding_pem.go ├── go1_21_encoding_xml.go ├── go1_21_errors.go ├── go1_21_expvar.go ├── go1_21_flag.go ├── go1_21_fmt.go ├── go1_21_go_ast.go ├── go1_21_go_build.go ├── go1_21_go_build_constraint.go ├── go1_21_go_constant.go ├── go1_21_go_doc.go ├── go1_21_go_doc_comment.go ├── go1_21_go_format.go ├── go1_21_go_importer.go ├── go1_21_go_parser.go ├── go1_21_go_printer.go ├── go1_21_go_scanner.go ├── go1_21_go_token.go ├── go1_21_go_types.go ├── go1_21_hash.go ├── go1_21_hash_adler32.go ├── go1_21_hash_crc32.go ├── go1_21_hash_crc64.go ├── go1_21_hash_fnv.go ├── go1_21_hash_maphash.go ├── go1_21_html.go ├── go1_21_html_template.go ├── go1_21_image.go ├── go1_21_image_color.go ├── go1_21_image_color_palette.go ├── go1_21_image_draw.go ├── go1_21_image_gif.go ├── go1_21_image_jpeg.go ├── go1_21_image_png.go ├── go1_21_index_suffixarray.go ├── go1_21_io.go ├── go1_21_io_fs.go ├── go1_21_io_ioutil.go ├── go1_21_log.go ├── go1_21_log_slog.go ├── go1_21_log_syslog.go ├── go1_21_maps.go ├── go1_21_math.go ├── go1_21_math_big.go ├── go1_21_math_bits.go ├── go1_21_math_cmplx.go ├── go1_21_math_rand.go ├── go1_21_mime.go ├── go1_21_mime_multipart.go ├── go1_21_mime_quotedprintable.go ├── go1_21_net.go ├── go1_21_net_http.go ├── go1_21_net_http_cgi.go ├── go1_21_net_http_cookiejar.go ├── go1_21_net_http_fcgi.go ├── go1_21_net_http_httptest.go ├── go1_21_net_http_httptrace.go ├── go1_21_net_http_httputil.go ├── go1_21_net_http_pprof.go ├── go1_21_net_mail.go ├── go1_21_net_netip.go ├── go1_21_net_rpc.go ├── go1_21_net_rpc_jsonrpc.go ├── go1_21_net_smtp.go ├── go1_21_net_textproto.go ├── go1_21_net_url.go ├── go1_21_os.go ├── go1_21_os_signal.go ├── go1_21_os_user.go ├── go1_21_path.go ├── go1_21_path_filepath.go ├── go1_21_reflect.go ├── go1_21_regexp.go ├── go1_21_regexp_syntax.go ├── go1_21_runtime.go ├── go1_21_runtime_debug.go ├── go1_21_runtime_metrics.go ├── go1_21_runtime_pprof.go ├── go1_21_runtime_trace.go ├── go1_21_slices.go ├── go1_21_sort.go ├── go1_21_strconv.go ├── go1_21_strings.go ├── go1_21_sync.go ├── go1_21_sync_atomic.go ├── go1_21_testing.go ├── go1_21_testing_fstest.go ├── go1_21_testing_iotest.go ├── go1_21_testing_quick.go ├── go1_21_testing_slogtest.go ├── go1_21_text_scanner.go ├── go1_21_text_tabwriter.go ├── go1_21_text_template.go ├── go1_21_text_template_parse.go ├── go1_21_time.go ├── go1_21_unicode.go ├── go1_21_unicode_utf16.go ├── go1_21_unicode_utf8.go ├── go1_22_archive_tar.go ├── go1_22_archive_zip.go ├── go1_22_bufio.go ├── go1_22_bytes.go ├── go1_22_cmp.go ├── go1_22_compress_bzip2.go ├── go1_22_compress_flate.go ├── go1_22_compress_gzip.go ├── go1_22_compress_lzw.go ├── go1_22_compress_zlib.go ├── go1_22_container_heap.go ├── go1_22_container_list.go ├── go1_22_container_ring.go ├── go1_22_context.go ├── go1_22_crypto.go ├── go1_22_crypto_aes.go ├── go1_22_crypto_cipher.go ├── go1_22_crypto_des.go ├── go1_22_crypto_dsa.go ├── go1_22_crypto_ecdh.go ├── go1_22_crypto_ecdsa.go ├── go1_22_crypto_ed25519.go ├── go1_22_crypto_elliptic.go ├── go1_22_crypto_hmac.go ├── go1_22_crypto_md5.go ├── go1_22_crypto_rand.go ├── go1_22_crypto_rc4.go ├── go1_22_crypto_rsa.go ├── go1_22_crypto_sha1.go ├── go1_22_crypto_sha256.go ├── go1_22_crypto_sha512.go ├── go1_22_crypto_subtle.go ├── go1_22_crypto_tls.go ├── go1_22_crypto_x509.go ├── go1_22_crypto_x509_pkix.go ├── go1_22_database_sql.go ├── go1_22_database_sql_driver.go ├── go1_22_debug_buildinfo.go ├── go1_22_debug_dwarf.go ├── go1_22_debug_elf.go ├── go1_22_debug_gosym.go ├── go1_22_debug_macho.go ├── go1_22_debug_pe.go ├── go1_22_debug_plan9obj.go ├── go1_22_encoding.go ├── go1_22_encoding_ascii85.go ├── go1_22_encoding_asn1.go ├── go1_22_encoding_base32.go ├── go1_22_encoding_base64.go ├── go1_22_encoding_binary.go ├── go1_22_encoding_csv.go ├── go1_22_encoding_gob.go ├── go1_22_encoding_hex.go ├── go1_22_encoding_json.go ├── go1_22_encoding_pem.go ├── go1_22_encoding_xml.go ├── go1_22_errors.go ├── go1_22_expvar.go ├── go1_22_flag.go ├── go1_22_fmt.go ├── go1_22_go_ast.go ├── go1_22_go_build.go ├── go1_22_go_build_constraint.go ├── go1_22_go_constant.go ├── go1_22_go_doc.go ├── go1_22_go_doc_comment.go ├── go1_22_go_format.go ├── go1_22_go_importer.go ├── go1_22_go_parser.go ├── go1_22_go_printer.go ├── go1_22_go_scanner.go ├── go1_22_go_token.go ├── go1_22_go_types.go ├── go1_22_go_version.go ├── go1_22_hash.go ├── go1_22_hash_adler32.go ├── go1_22_hash_crc32.go ├── go1_22_hash_crc64.go ├── go1_22_hash_fnv.go ├── go1_22_hash_maphash.go ├── go1_22_html.go ├── go1_22_html_template.go ├── go1_22_image.go ├── go1_22_image_color.go ├── go1_22_image_color_palette.go ├── go1_22_image_draw.go ├── go1_22_image_gif.go ├── go1_22_image_jpeg.go ├── go1_22_image_png.go ├── go1_22_index_suffixarray.go ├── go1_22_io.go ├── go1_22_io_fs.go ├── go1_22_io_ioutil.go ├── go1_22_log.go ├── go1_22_log_slog.go ├── go1_22_log_syslog.go ├── go1_22_maps.go ├── go1_22_math.go ├── go1_22_math_big.go ├── go1_22_math_bits.go ├── go1_22_math_cmplx.go ├── go1_22_math_rand.go ├── go1_22_math_rand_v2.go ├── go1_22_mime.go ├── go1_22_mime_multipart.go ├── go1_22_mime_quotedprintable.go ├── go1_22_net.go ├── go1_22_net_http.go ├── go1_22_net_http_cgi.go ├── go1_22_net_http_cookiejar.go ├── go1_22_net_http_fcgi.go ├── go1_22_net_http_httptest.go ├── go1_22_net_http_httptrace.go ├── go1_22_net_http_httputil.go ├── go1_22_net_http_pprof.go ├── go1_22_net_mail.go ├── go1_22_net_netip.go ├── go1_22_net_rpc.go ├── go1_22_net_rpc_jsonrpc.go ├── go1_22_net_smtp.go ├── go1_22_net_textproto.go ├── go1_22_net_url.go ├── go1_22_os.go ├── go1_22_os_signal.go ├── go1_22_os_user.go ├── go1_22_path.go ├── go1_22_path_filepath.go ├── go1_22_reflect.go ├── go1_22_regexp.go ├── go1_22_regexp_syntax.go ├── go1_22_runtime.go ├── go1_22_runtime_debug.go ├── go1_22_runtime_metrics.go ├── go1_22_runtime_pprof.go ├── go1_22_runtime_trace.go ├── go1_22_slices.go ├── go1_22_sort.go ├── go1_22_strconv.go ├── go1_22_strings.go ├── go1_22_sync.go ├── go1_22_sync_atomic.go ├── go1_22_testing.go ├── go1_22_testing_fstest.go ├── go1_22_testing_iotest.go ├── go1_22_testing_quick.go ├── go1_22_testing_slogtest.go ├── go1_22_text_scanner.go ├── go1_22_text_tabwriter.go ├── go1_22_text_template.go ├── go1_22_text_template_parse.go ├── go1_22_time.go ├── go1_22_unicode.go ├── go1_22_unicode_utf16.go ├── go1_22_unicode_utf8.go ├── maptypes.go ├── restricted.go ├── stdlib-go1.22.go ├── stdlib.go ├── syscall ├── go1_21_syscall_aix_ppc64.go ├── go1_21_syscall_android_386.go ├── go1_21_syscall_android_amd64.go ├── go1_21_syscall_android_arm.go ├── go1_21_syscall_android_arm64.go ├── go1_21_syscall_darwin_amd64.go ├── go1_21_syscall_darwin_arm64.go ├── go1_21_syscall_dragonfly_amd64.go ├── go1_21_syscall_freebsd_386.go ├── go1_21_syscall_freebsd_amd64.go ├── go1_21_syscall_freebsd_arm.go ├── go1_21_syscall_freebsd_arm64.go ├── go1_21_syscall_freebsd_riscv64.go ├── go1_21_syscall_illumos_amd64.go ├── go1_21_syscall_ios_amd64.go ├── go1_21_syscall_ios_arm64.go ├── go1_21_syscall_js_wasm.go ├── go1_21_syscall_linux_386.go ├── go1_21_syscall_linux_amd64.go ├── go1_21_syscall_linux_arm.go ├── go1_21_syscall_linux_arm64.go ├── go1_21_syscall_linux_loong64.go ├── go1_21_syscall_linux_mips.go ├── go1_21_syscall_linux_mips64.go ├── go1_21_syscall_linux_mips64le.go ├── go1_21_syscall_linux_mipsle.go ├── go1_21_syscall_linux_ppc64.go ├── go1_21_syscall_linux_ppc64le.go ├── go1_21_syscall_linux_riscv64.go ├── go1_21_syscall_linux_s390x.go ├── go1_21_syscall_netbsd_386.go ├── go1_21_syscall_netbsd_amd64.go ├── go1_21_syscall_netbsd_arm.go ├── go1_21_syscall_netbsd_arm64.go ├── go1_21_syscall_openbsd_386.go ├── go1_21_syscall_openbsd_amd64.go ├── go1_21_syscall_openbsd_arm.go ├── go1_21_syscall_openbsd_arm64.go ├── go1_21_syscall_plan9_386.go ├── go1_21_syscall_plan9_amd64.go ├── go1_21_syscall_plan9_arm.go ├── go1_21_syscall_solaris_amd64.go ├── go1_21_syscall_wasip1_wasm.go ├── go1_21_syscall_windows_386.go ├── go1_21_syscall_windows_amd64.go ├── go1_21_syscall_windows_arm.go ├── go1_21_syscall_windows_arm64.go ├── go1_22_syscall_aix_ppc64.go ├── go1_22_syscall_android_386.go ├── go1_22_syscall_android_amd64.go ├── go1_22_syscall_android_arm.go ├── go1_22_syscall_android_arm64.go ├── go1_22_syscall_darwin_amd64.go ├── go1_22_syscall_darwin_arm64.go ├── go1_22_syscall_dragonfly_amd64.go ├── go1_22_syscall_freebsd_386.go ├── go1_22_syscall_freebsd_amd64.go ├── go1_22_syscall_freebsd_arm.go ├── go1_22_syscall_freebsd_arm64.go ├── go1_22_syscall_freebsd_riscv64.go ├── go1_22_syscall_illumos_amd64.go ├── go1_22_syscall_ios_amd64.go ├── go1_22_syscall_ios_arm64.go ├── go1_22_syscall_js_wasm.go ├── go1_22_syscall_linux_386.go ├── go1_22_syscall_linux_amd64.go ├── go1_22_syscall_linux_arm.go ├── go1_22_syscall_linux_arm64.go ├── go1_22_syscall_linux_loong64.go ├── go1_22_syscall_linux_mips.go ├── go1_22_syscall_linux_mips64.go ├── go1_22_syscall_linux_mips64le.go ├── go1_22_syscall_linux_mipsle.go ├── go1_22_syscall_linux_ppc64.go ├── go1_22_syscall_linux_ppc64le.go ├── go1_22_syscall_linux_riscv64.go ├── go1_22_syscall_linux_s390x.go ├── go1_22_syscall_netbsd_386.go ├── go1_22_syscall_netbsd_amd64.go ├── go1_22_syscall_netbsd_arm.go ├── go1_22_syscall_netbsd_arm64.go ├── go1_22_syscall_openbsd_386.go ├── go1_22_syscall_openbsd_amd64.go ├── go1_22_syscall_openbsd_arm.go ├── go1_22_syscall_openbsd_arm64.go ├── go1_22_syscall_openbsd_ppc64.go ├── go1_22_syscall_plan9_386.go ├── go1_22_syscall_plan9_amd64.go ├── go1_22_syscall_plan9_arm.go ├── go1_22_syscall_solaris_amd64.go ├── go1_22_syscall_wasip1_wasm.go ├── go1_22_syscall_windows_386.go ├── go1_22_syscall_windows_amd64.go ├── go1_22_syscall_windows_arm.go ├── go1_22_syscall_windows_arm64.go └── syscall.go ├── unrestricted ├── go1_21_syscall_aix_ppc64.go ├── go1_21_syscall_android_386.go ├── go1_21_syscall_android_amd64.go ├── go1_21_syscall_android_arm.go ├── go1_21_syscall_android_arm64.go ├── go1_21_syscall_darwin_amd64.go ├── go1_21_syscall_darwin_arm64.go ├── go1_21_syscall_dragonfly_amd64.go ├── go1_21_syscall_freebsd_386.go ├── go1_21_syscall_freebsd_amd64.go ├── go1_21_syscall_freebsd_arm.go ├── go1_21_syscall_freebsd_arm64.go ├── go1_21_syscall_freebsd_riscv64.go ├── go1_21_syscall_illumos_amd64.go ├── go1_21_syscall_ios_amd64.go ├── go1_21_syscall_ios_arm64.go ├── go1_21_syscall_js_wasm.go ├── go1_21_syscall_linux_386.go ├── go1_21_syscall_linux_amd64.go ├── go1_21_syscall_linux_arm.go ├── go1_21_syscall_linux_arm64.go ├── go1_21_syscall_linux_loong64.go ├── go1_21_syscall_linux_mips.go ├── go1_21_syscall_linux_mips64.go ├── go1_21_syscall_linux_mips64le.go ├── go1_21_syscall_linux_mipsle.go ├── go1_21_syscall_linux_ppc64.go ├── go1_21_syscall_linux_ppc64le.go ├── go1_21_syscall_linux_riscv64.go ├── go1_21_syscall_linux_s390x.go ├── go1_21_syscall_netbsd_386.go ├── go1_21_syscall_netbsd_amd64.go ├── go1_21_syscall_netbsd_arm.go ├── go1_21_syscall_netbsd_arm64.go ├── go1_21_syscall_openbsd_386.go ├── go1_21_syscall_openbsd_amd64.go ├── go1_21_syscall_openbsd_arm.go ├── go1_21_syscall_openbsd_arm64.go ├── go1_21_syscall_plan9_386.go ├── go1_21_syscall_plan9_amd64.go ├── go1_21_syscall_plan9_arm.go ├── go1_21_syscall_solaris_amd64.go ├── go1_21_syscall_wasip1_wasm.go ├── go1_21_syscall_windows_386.go ├── go1_21_syscall_windows_amd64.go ├── go1_21_syscall_windows_arm.go ├── go1_21_syscall_windows_arm64.go ├── go1_22_syscall_aix_ppc64.go ├── go1_22_syscall_android_386.go ├── go1_22_syscall_android_amd64.go ├── go1_22_syscall_android_arm.go ├── go1_22_syscall_android_arm64.go ├── go1_22_syscall_darwin_amd64.go ├── go1_22_syscall_darwin_arm64.go ├── go1_22_syscall_dragonfly_amd64.go ├── go1_22_syscall_freebsd_386.go ├── go1_22_syscall_freebsd_amd64.go ├── go1_22_syscall_freebsd_arm.go ├── go1_22_syscall_freebsd_arm64.go ├── go1_22_syscall_freebsd_riscv64.go ├── go1_22_syscall_illumos_amd64.go ├── go1_22_syscall_ios_amd64.go ├── go1_22_syscall_ios_arm64.go ├── go1_22_syscall_js_wasm.go ├── go1_22_syscall_linux_386.go ├── go1_22_syscall_linux_amd64.go ├── go1_22_syscall_linux_arm.go ├── go1_22_syscall_linux_arm64.go ├── go1_22_syscall_linux_loong64.go ├── go1_22_syscall_linux_mips.go ├── go1_22_syscall_linux_mips64.go ├── go1_22_syscall_linux_mips64le.go ├── go1_22_syscall_linux_mipsle.go ├── go1_22_syscall_linux_ppc64.go ├── go1_22_syscall_linux_ppc64le.go ├── go1_22_syscall_linux_riscv64.go ├── go1_22_syscall_linux_s390x.go ├── go1_22_syscall_netbsd_386.go ├── go1_22_syscall_netbsd_amd64.go ├── go1_22_syscall_netbsd_arm.go ├── go1_22_syscall_netbsd_arm64.go ├── go1_22_syscall_openbsd_386.go ├── go1_22_syscall_openbsd_amd64.go ├── go1_22_syscall_openbsd_arm.go ├── go1_22_syscall_openbsd_arm64.go ├── go1_22_syscall_openbsd_ppc64.go ├── go1_22_syscall_plan9_386.go ├── go1_22_syscall_plan9_amd64.go ├── go1_22_syscall_plan9_arm.go ├── go1_22_syscall_solaris_amd64.go ├── go1_22_syscall_wasip1_wasm.go ├── go1_22_syscall_windows_386.go ├── go1_22_syscall_windows_amd64.go ├── go1_22_syscall_windows_arm.go ├── go1_22_syscall_windows_arm64.go └── unrestricted.go ├── unsafe ├── go1_21_unsafe.go ├── go1_22_unsafe.go └── unsafe.go └── wrapper-composed.go /.gitignore: -------------------------------------------------------------------------------- 1 | .*.swo 2 | .*.swp 3 | *.dot 4 | *.out 5 | .idea/ 6 | /yaegi 7 | internal/cmd/extract/extract 8 | example/inception/inception 9 | _test/tmp/ 10 | /dist 11 | -------------------------------------------------------------------------------- /_test/a1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := [6]int{1, 2, 3, 4, 5, 6} 5 | println(a[1]) // 2 6 | for i, v := range a { 7 | println(v) 8 | if i == 3 { 9 | break 10 | } 11 | } 12 | } 13 | 14 | // Output: 15 | // 2 16 | // 1 17 | // 2 18 | // 3 19 | // 4 20 | -------------------------------------------------------------------------------- /_test/a11.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := []int{1, 2, 3, 4} 5 | for _, v := range a { 6 | println(v) 7 | } 8 | } 9 | 10 | // Output: 11 | // 1 12 | // 2 13 | // 3 14 | // 4 15 | -------------------------------------------------------------------------------- /_test/a12.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var buf [12]int 7 | fmt.Println(buf[0]) 8 | } 9 | 10 | // Output: 11 | // 0 12 | -------------------------------------------------------------------------------- /_test/a13.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T1 struct { 4 | num []int 5 | } 6 | 7 | func main() { 8 | a := T1{[]int{1, 3, 5}} 9 | for i, v := range a.num { 10 | println(i, v) 11 | } 12 | } 13 | 14 | // Output: 15 | // 0 1 16 | // 1 3 17 | // 2 5 18 | -------------------------------------------------------------------------------- /_test/a14.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | const size = 12 6 | 7 | func main() { 8 | var buf [size]int 9 | fmt.Println(buf) 10 | } 11 | 12 | // Output: 13 | // [0 0 0 0 0 0 0 0 0 0 0 0] 14 | -------------------------------------------------------------------------------- /_test/a15.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | const size = 12 6 | 7 | func main() { 8 | var buf [size]int 9 | fmt.Println(buf[:]) 10 | } 11 | 12 | // Output: 13 | // [0 0 0 0 0 0 0 0 0 0 0 0] 14 | -------------------------------------------------------------------------------- /_test/a17.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := make([]int, 2, 7) 7 | fmt.Println(a, len(a), cap(a)) 8 | } 9 | 10 | // Output: 11 | // [0 0] 2 7 12 | -------------------------------------------------------------------------------- /_test/a18.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := []int64{1, 2, 3, 4} 5 | for _, v := range a { 6 | println(v) 7 | } 8 | } 9 | 10 | // Output: 11 | // 1 12 | // 2 13 | // 3 14 | // 4 15 | -------------------------------------------------------------------------------- /_test/a19.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var buf [bsize]byte 5 | println(len(buf)) 6 | } 7 | 8 | const bsize = 10 9 | 10 | // Output: 11 | // 10 12 | -------------------------------------------------------------------------------- /_test/a20.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type IntArray []int 6 | 7 | func (h *IntArray) Add(x int) { 8 | *h = append(*h, x) 9 | } 10 | 11 | func main() { 12 | a := IntArray{} 13 | a.Add(4) 14 | 15 | fmt.Println(a) 16 | } 17 | 18 | // Output: 19 | // [4] 20 | -------------------------------------------------------------------------------- /_test/a21.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := []byte("hello") 7 | fmt.Println(a) 8 | a = append(a, '=') 9 | fmt.Println(a) 10 | } 11 | 12 | // Output: 13 | // [104 101 108 108 111] 14 | // [104 101 108 108 111 61] 15 | -------------------------------------------------------------------------------- /_test/a22.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := [256]int{} 5 | var b uint8 = 12 6 | a[b] = 1 7 | println(a[b]) 8 | } 9 | 10 | // Output: 11 | // 1 12 | -------------------------------------------------------------------------------- /_test/a26.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := [3]int{1, 2, 3} 5 | b := [3]int{1, 2, 3} 6 | println(a == b) 7 | } 8 | 9 | // Output: 10 | // true 11 | -------------------------------------------------------------------------------- /_test/a27.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := [...]string{"hello", "world"} 7 | fmt.Printf("%v %T\n", a, a) 8 | } 9 | 10 | // Output: 11 | // [hello world] [2]string 12 | -------------------------------------------------------------------------------- /_test/a28.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := [...]string{9: "hello"} 7 | fmt.Printf("%v %T\n", a, a) 8 | } 9 | 10 | // Output: 11 | // [ hello] [10]string 12 | -------------------------------------------------------------------------------- /_test/a3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := [6]int{1, 2, 3, 4, 5, 6} 7 | fmt.Println(a[2:]) 8 | } 9 | 10 | // Output: 11 | // [3 4 5 6] 12 | -------------------------------------------------------------------------------- /_test/a30.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | for range []struct{}{} { 5 | } 6 | println("ok") 7 | } 8 | 9 | // Output: 10 | // ok 11 | -------------------------------------------------------------------------------- /_test/a31.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | for range []int{0, 1, 2} { 5 | print("hello ") 6 | } 7 | println("") 8 | } 9 | 10 | // Output: 11 | // hello hello hello 12 | -------------------------------------------------------------------------------- /_test/a32.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type T struct{} 6 | 7 | var a = []T{{}} 8 | 9 | func main() { 10 | fmt.Println(a) 11 | } 12 | 13 | // Output: 14 | // [{}] 15 | -------------------------------------------------------------------------------- /_test/a33.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := [...]int{1, 2, 3} 7 | b := a 8 | fmt.Println(b) 9 | } 10 | 11 | // Output: 12 | // [1 2 3] 13 | -------------------------------------------------------------------------------- /_test/a34.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := [...]int{1, 2, 3} 7 | var b [3]int = a 8 | fmt.Println(b) 9 | } 10 | 11 | // Output: 12 | // [1 2 3] 13 | -------------------------------------------------------------------------------- /_test/a35.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := [...]int{1, 2, 3} 7 | b := a 8 | b[0] = -1 9 | fmt.Println(a) 10 | } 11 | 12 | // Output: 13 | // [1 2 3] 14 | -------------------------------------------------------------------------------- /_test/a36.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := [...]int{1, 2, 3} 7 | var b [3]int = a 8 | b[0] = -1 9 | fmt.Println(a) 10 | } 11 | 12 | // Output: 13 | // [1 2 3] 14 | -------------------------------------------------------------------------------- /_test/a37.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := [...]int{1, 2, 3} 7 | fmt.Println(a) 8 | } 9 | 10 | // Output: 11 | // [1 2 3] 12 | -------------------------------------------------------------------------------- /_test/a38.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := [...]byte{} 7 | fmt.Printf("%T\n", a) 8 | } 9 | 10 | // Output: 11 | // [0]uint8 12 | -------------------------------------------------------------------------------- /_test/a39.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := [...]byte{} 7 | b := a 8 | fmt.Printf("%T %T\n", a, b) 9 | } 10 | 11 | // Output: 12 | // [0]uint8 [0]uint8 13 | -------------------------------------------------------------------------------- /_test/a4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := [6]int{1, 2, 3, 4, 5, 6} 7 | fmt.Println(a[2:4]) 8 | } 9 | 10 | // Output: 11 | // [3 4] 12 | -------------------------------------------------------------------------------- /_test/a40.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type rule uint8 6 | 7 | const ( 8 | r0 rule = iota 9 | r1 10 | r2 11 | ) 12 | 13 | var a = [...]int{ 14 | r0: 1, 15 | r1: 12, 16 | } 17 | 18 | func main() { 19 | fmt.Println(a) 20 | } 21 | 22 | // Output: 23 | // [1 12] 24 | -------------------------------------------------------------------------------- /_test/a41.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var a = [...]bool{true, true} 4 | 5 | func main() { 6 | println(a[0] && true) 7 | } 8 | 9 | // Output: 10 | // true 11 | -------------------------------------------------------------------------------- /_test/a42.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/binary" 5 | "fmt" 6 | ) 7 | 8 | func main() { 9 | var b [8]byte 10 | binary.LittleEndian.PutUint64(b[:], uint64(1)) 11 | 12 | fmt.Println(b) 13 | } 14 | 15 | // Output: 16 | // [1 0 0 0 0 0 0 0] 17 | -------------------------------------------------------------------------------- /_test/a43.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type T [l1 + l2]int 6 | 7 | const ( 8 | l1 = 2 9 | l2 = 3 10 | ) 11 | 12 | func main() { 13 | fmt.Println(T{}) 14 | } 15 | 16 | // Output: 17 | // [0 0 0 0 0] 18 | -------------------------------------------------------------------------------- /_test/a44.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var a = [max]int{} 4 | 5 | const max = 32 6 | 7 | func main() { 8 | println(len(a)) 9 | } 10 | 11 | // Output: 12 | // 32 13 | -------------------------------------------------------------------------------- /_test/a5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := [6]int{1, 2, 3, 4, 5, 6} 7 | fmt.Println(a[:4]) 8 | } 9 | 10 | // Output: 11 | // [1 2 3 4] 12 | -------------------------------------------------------------------------------- /_test/a6.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := [6]int{1, 2, 3, 4, 5, 6} 7 | fmt.Println(a[:]) 8 | } 9 | 10 | // Output: 11 | // [1 2 3 4 5 6] 12 | -------------------------------------------------------------------------------- /_test/a7.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := [6]int{1, 2, 3, 4, 5, 6} 7 | fmt.Println(len(a)) 8 | } 9 | 10 | // Output: 11 | // 6 12 | -------------------------------------------------------------------------------- /_test/a8.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | //a := []int{1, 2} 7 | a := make([]int, 2) 8 | //a[0] = 1 9 | //a[1] = 2 10 | fmt.Println(a) 11 | } 12 | 13 | // Output: 14 | // [0 0] 15 | -------------------------------------------------------------------------------- /_test/a9.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | //var ( 6 | // samples = []int{} 7 | // b = 1 8 | //) 9 | 10 | func main() { 11 | var samples = []int{} 12 | samples = append(samples, 1) 13 | fmt.Println(samples) 14 | } 15 | 16 | // Output: 17 | // [1] 18 | -------------------------------------------------------------------------------- /_test/add0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a interface{} = 2 + 5 5 | println(a.(int)) 6 | } 7 | 8 | // Output: 9 | // 7 10 | -------------------------------------------------------------------------------- /_test/add2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type iface interface{} 4 | 5 | func main() { 6 | b := 2 7 | var a iface = 5 + b 8 | println(a.(int)) 9 | } 10 | 11 | // Output: 12 | // 7 13 | -------------------------------------------------------------------------------- /_test/and1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := f2() && f1() 5 | println(a) 6 | } 7 | 8 | func f1() bool { 9 | println("f1") 10 | return true 11 | } 12 | 13 | func f2() bool { 14 | println("f2") 15 | return false 16 | } 17 | 18 | // Output: 19 | // f2 20 | // false 21 | -------------------------------------------------------------------------------- /_test/and3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var a = true && true 4 | 5 | func main() { 6 | println(a) 7 | } 8 | 9 | // Output: 10 | // true 11 | -------------------------------------------------------------------------------- /_test/append0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func f(a []int, b int) interface{} { return append(a, b) } 6 | 7 | func main() { 8 | a := []int{1, 2} 9 | r := f(a, 3) 10 | fmt.Println(r.([]int)) 11 | } 12 | 13 | // Output: 14 | // [1 2 3] 15 | -------------------------------------------------------------------------------- /_test/append3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := []int{1, 2} 7 | b := [2]int{3, 4} 8 | fmt.Println(append(a, b[:]...)) 9 | fmt.Println(append(a, []int{5, 6}...)) 10 | } 11 | 12 | // Output: 13 | // [1 2 3 4] 14 | // [1 2 5 6] 15 | -------------------------------------------------------------------------------- /_test/append4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := []*int{} 7 | a = append(a, nil) 8 | fmt.Println(a) 9 | } 10 | 11 | // Output: 12 | // [] 13 | -------------------------------------------------------------------------------- /_test/assert3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "crypto/rsa" 4 | 5 | func main() { 6 | var pKey interface{} = &rsa.PublicKey{} 7 | 8 | if _, ok := pKey.(*rsa.PublicKey); ok { 9 | println("ok") 10 | } else { 11 | println("nok") 12 | } 13 | } 14 | 15 | // Output: 16 | // ok 17 | -------------------------------------------------------------------------------- /_test/assert4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var cc interface{} = 2 4 | var dd = cc.(int) 5 | 6 | func main() { 7 | println(dd) 8 | } 9 | 10 | // Output: 11 | // 2 12 | -------------------------------------------------------------------------------- /_test/assign.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a, b := 1, 2 // Multiple assign 5 | println(a, b) 6 | } 7 | 8 | // Output: 9 | // 1 2 10 | -------------------------------------------------------------------------------- /_test/assign1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var buf []byte 7 | 8 | buf = nil 9 | fmt.Println(buf) 10 | } 11 | 12 | // Output: 13 | // [] 14 | -------------------------------------------------------------------------------- /_test/assign10.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a uint 5 | a = 1 + 2 6 | println(a) 7 | } 8 | 9 | // Output: 10 | // 3 11 | -------------------------------------------------------------------------------- /_test/assign11.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | _, _, _ = fmt.Println("test") 7 | } 8 | 9 | // Error: 10 | // 6:2: assignment mismatch: 3 variables but fmt.Println returns 2 values 11 | -------------------------------------------------------------------------------- /_test/assign12.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a, b, c := fmt.Println("test") 7 | println(a, b, c) 8 | } 9 | 10 | // Error: 11 | // 6:2: assignment mismatch: 3 variables but fmt.Println returns 2 values 12 | -------------------------------------------------------------------------------- /_test/assign14.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var optionsG map[string]string = nil 4 | 5 | var roundG = 30 6 | 7 | func main() { 8 | dummy := roundG 9 | roundG = dummy + 1 10 | println(roundG) 11 | println(optionsG == nil) 12 | } 13 | 14 | // Output: 15 | // 31 16 | // true 17 | -------------------------------------------------------------------------------- /_test/assign15.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var c chan<- struct{} = make(chan struct{}) 5 | var d <-chan struct{} = c 6 | 7 | _ = d 8 | } 9 | 10 | // Error: 11 | // _test/assign15.go:5:26: cannot use type chan<- struct {} as type <-chan struct {} in assignment 12 | -------------------------------------------------------------------------------- /_test/assign16.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type H struct { 4 | bits uint 5 | } 6 | 7 | func main() { 8 | h := &H{8} 9 | var x uint = (1 << h.bits) >> 6 10 | 11 | println(x) 12 | } 13 | 14 | // Output: 15 | // 4 16 | -------------------------------------------------------------------------------- /_test/assign19.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a, b, c := 1, 2 5 | _, _, _ = a, b, c 6 | } 7 | 8 | // Error: 9 | // _test/assign19.go:4:2: cannot assign 2 values to 3 variables 10 | -------------------------------------------------------------------------------- /_test/assign2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | r := uint32(2000000000) 5 | r = hello(r) 6 | println(r) 7 | } 8 | 9 | func hello(r uint32) uint32 { return r + 1 } 10 | 11 | // Output: 12 | // 2000000001 13 | -------------------------------------------------------------------------------- /_test/assign3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a, b := 1, 2 5 | println(a, b) 6 | a, b = b, a 7 | println(a, b) 8 | } 9 | 10 | // Output: 11 | // 1 2 12 | // 2 1 13 | -------------------------------------------------------------------------------- /_test/assign4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a, b, c := 1, 2, 3 5 | println(a, b, c) 6 | a, b, c = c, a, b 7 | println(a, b, c) 8 | } 9 | 10 | // Output: 11 | // 1 2 3 12 | // 3 1 2 13 | -------------------------------------------------------------------------------- /_test/assign5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | t := []int{1, 2} 7 | fmt.Println(t) 8 | t[0], t[1] = t[1], t[0] 9 | fmt.Println(t) 10 | } 11 | 12 | // Output: 13 | // [1 2] 14 | // [2 1] 15 | -------------------------------------------------------------------------------- /_test/assign6.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | t := map[string]int{"a": 1, "b": 2} 7 | fmt.Println(t["a"], t["b"]) 8 | t["a"], t["b"] = t["b"], t["a"] 9 | fmt.Println(t["a"], t["b"]) 10 | } 11 | 12 | // Output: 13 | // 1 2 14 | // 2 1 15 | -------------------------------------------------------------------------------- /_test/assign8.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | _ = 1 5 | println(1) 6 | } 7 | 8 | // Output: 9 | // 1 10 | -------------------------------------------------------------------------------- /_test/assign9.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type foo func(b int) 4 | 5 | func boo(b int) { println("boo", b) } 6 | 7 | func main() { 8 | var f foo 9 | 10 | f = boo 11 | f(4) 12 | } 13 | 14 | // Output: 15 | // boo 4 16 | -------------------------------------------------------------------------------- /_test/b1/foo/foo.go: -------------------------------------------------------------------------------- 1 | package foo 2 | 3 | import bar "github.com/traefik/yaegi/_test/b2/foo" 4 | 5 | var Desc = "in b1/foo" 6 | 7 | var Desc2 = Desc + bar.Desc 8 | -------------------------------------------------------------------------------- /_test/b2/foo/foo.go: -------------------------------------------------------------------------------- 1 | package foo 2 | 3 | var Desc = "in b2/foo" 4 | -------------------------------------------------------------------------------- /_test/bad0.go: -------------------------------------------------------------------------------- 1 | println("Hello") 2 | 3 | // Error: 4 | // 1:1: expected 'package', found println 5 | -------------------------------------------------------------------------------- /_test/baz-bat/baz-bat.go: -------------------------------------------------------------------------------- 1 | package baz 2 | 3 | var Name = "baz-bat" 4 | -------------------------------------------------------------------------------- /_test/bin.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | f := fmt.Println 7 | f("Hello") 8 | } 9 | 10 | // Output: 11 | // Hello 12 | -------------------------------------------------------------------------------- /_test/bin0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "strings" 4 | 5 | func main() { 6 | a := strings.SplitN("truc machin", " ", 2) 7 | println(a[0]) 8 | } 9 | 10 | // Output: 11 | // truc 12 | -------------------------------------------------------------------------------- /_test/bin2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "math" 6 | ) 7 | 8 | func main() { 9 | fmt.Println(math.Abs(-5)) 10 | } 11 | 12 | // Output: 13 | // 5 14 | -------------------------------------------------------------------------------- /_test/bin3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | str := "part1" 7 | str += fmt.Sprintf("%s", "part2") 8 | fmt.Println(str) 9 | } 10 | 11 | // Output: 12 | // part1part2 13 | -------------------------------------------------------------------------------- /_test/bin5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | ) 7 | 8 | func main() { 9 | addr := net.TCPAddr{IP: net.IPv4(1, 1, 1, 1), Port: 80} 10 | var s fmt.Stringer = &addr 11 | fmt.Println(s.String()) 12 | } 13 | 14 | // Output: 15 | // 1.1.1.1:80 16 | -------------------------------------------------------------------------------- /_test/binstruct_ptr_slice0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "image" 6 | ) 7 | 8 | func main() { 9 | v := []*image.Point{ 10 | {X: 3, Y: 2}, 11 | {X: 4, Y: 5}, 12 | } 13 | fmt.Println(v) 14 | } 15 | 16 | // Output: 17 | // [(3,2) (4,5)] 18 | -------------------------------------------------------------------------------- /_test/binstruct_slice0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "image" 6 | ) 7 | 8 | func main() { 9 | v := []image.Point{ 10 | {X: 3, Y: 2}, 11 | } 12 | fmt.Println(v) 13 | } 14 | 15 | // Output: 16 | // [(3,2)] 17 | -------------------------------------------------------------------------------- /_test/bltn.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | println("Hello") 5 | } 6 | 7 | // Output: 8 | // Hello 9 | -------------------------------------------------------------------------------- /_test/bltn0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | f := println 5 | f("Hello") 6 | } 7 | 8 | // Error: 9 | // 4:7: use of builtin println not in function call 10 | -------------------------------------------------------------------------------- /_test/bool.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println(false, true) 7 | } 8 | 9 | // Output: 10 | // false true 11 | -------------------------------------------------------------------------------- /_test/bool0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println(true) 7 | } 8 | 9 | // Output: 10 | // true 11 | -------------------------------------------------------------------------------- /_test/bool1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | v bool 5 | } 6 | 7 | func main() { 8 | a := T{} 9 | if a.v { 10 | println("ok") 11 | } else { 12 | println("nok") 13 | } 14 | } 15 | 16 | // Output: 17 | // nok 18 | -------------------------------------------------------------------------------- /_test/bool2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | v bool 5 | } 6 | 7 | func main() { 8 | a := &T{} 9 | if a.v { 10 | println("ok") 11 | } else { 12 | println("nok") 13 | } 14 | } 15 | 16 | // Output: 17 | // nok 18 | -------------------------------------------------------------------------------- /_test/bool3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | m := map[int]bool{0: false, 1: true} 5 | if m[0] { 6 | println(0) 7 | } else { 8 | println(1) 9 | } 10 | } 11 | 12 | // Output: 13 | // 1 14 | -------------------------------------------------------------------------------- /_test/bool4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | m := []bool{false, true} 5 | if m[0] { 6 | println(0) 7 | } else { 8 | println(1) 9 | } 10 | } 11 | 12 | // Output: 13 | // 1 14 | -------------------------------------------------------------------------------- /_test/bool5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var b bool 5 | m := &b 6 | 7 | if *m { 8 | println(0) 9 | } else { 10 | println(1) 11 | } 12 | } 13 | 14 | // Output: 15 | // 1 16 | -------------------------------------------------------------------------------- /_test/c1/c1.go: -------------------------------------------------------------------------------- 1 | package c1 2 | 3 | import "github.com/traefik/yaegi/_test/c2" 4 | 5 | var C1 = c2.C2 + "x" 6 | -------------------------------------------------------------------------------- /_test/c2/c2.go: -------------------------------------------------------------------------------- 1 | package c2 2 | 3 | import "github.com/traefik/yaegi/_test/c1" 4 | 5 | var C2 = c1.C1 + "Y" 6 | -------------------------------------------------------------------------------- /_test/cap0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func f(a []int) interface{} { 4 | return cap(a) 5 | } 6 | 7 | func g(a []int) int { 8 | return cap(a) 9 | } 10 | 11 | func main() { 12 | a := []int{1, 2} 13 | println(g(a)) 14 | println(f(a).(int)) 15 | } 16 | 17 | // Output: 18 | // 2 19 | // 2 20 | -------------------------------------------------------------------------------- /_test/chan0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Channel chan string 4 | 5 | func send(c Channel) { c <- "ping" } 6 | 7 | func main() { 8 | channel := make(Channel) 9 | go send(channel) 10 | msg := <-channel 11 | println(msg) 12 | } 13 | 14 | // Output: 15 | // ping 16 | -------------------------------------------------------------------------------- /_test/chan1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func send(c chan<- string) { c <- "ping" } 4 | 5 | func main() { 6 | channel := make(chan string) 7 | go send(channel) 8 | msg := <-channel 9 | println(msg) 10 | } 11 | 12 | // Output: 13 | // ping 14 | -------------------------------------------------------------------------------- /_test/chan10.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "time" 4 | 5 | func main() { 6 | var tick <-chan time.Time = time.Tick(time.Millisecond) 7 | _ = tick 8 | println("success") 9 | } 10 | 11 | // Output: 12 | // success 13 | -------------------------------------------------------------------------------- /_test/chan2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | messages := make(chan string) 7 | 8 | go func() { messages <- "ping" }() 9 | 10 | msg := <-messages 11 | fmt.Println(msg) 12 | } 13 | 14 | // Output: 15 | // ping 16 | -------------------------------------------------------------------------------- /_test/chan3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func send(c chan<- int32) { c <- 123 } 4 | 5 | func main() { 6 | channel := make(chan int32) 7 | go send(channel) 8 | msg := <-channel 9 | println(msg) 10 | } 11 | 12 | // Output: 13 | // 123 14 | -------------------------------------------------------------------------------- /_test/chan4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func send(c chan<- bool) { c <- false } 4 | 5 | func main() { 6 | channel := make(chan bool) 7 | go send(channel) 8 | if <-channel { 9 | println("ok") 10 | } else { 11 | println("nok") 12 | } 13 | } 14 | 15 | // Output: 16 | // nok 17 | -------------------------------------------------------------------------------- /_test/chan6.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func send(c chan<- int32) { c <- 123 } 4 | 5 | func main() { 6 | channel := make(chan int32) 7 | go send(channel) 8 | msg, ok := <-channel 9 | println(msg, ok) 10 | } 11 | -------------------------------------------------------------------------------- /_test/chan7.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | queue := make(chan string, 2) 7 | queue <- "one" 8 | queue <- "two" 9 | close(queue) 10 | for elem := range queue { 11 | fmt.Println(elem) 12 | } 13 | } 14 | 15 | // Output: 16 | // one 17 | // two 18 | -------------------------------------------------------------------------------- /_test/chan8.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | messages := make(chan bool) 5 | 6 | go func() { messages <- true }() 7 | 8 | println(<-messages && true) 9 | } 10 | 11 | // Output: 12 | // true 13 | -------------------------------------------------------------------------------- /_test/closure0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type adder func(int, int) int 4 | 5 | func genAdd(k int) adder { 6 | return func(i, j int) int { 7 | return i + j + k 8 | } 9 | } 10 | 11 | func main() { 12 | f := genAdd(5) 13 | println(f(3, 4)) 14 | } 15 | 16 | // Output: 17 | // 12 18 | -------------------------------------------------------------------------------- /_test/closure19.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | foos := []func(){} 5 | 6 | for i := 0; i < 3; i++ { 7 | i := i 8 | foos = append(foos, func() { println(i) }) 9 | } 10 | foos[0]() 11 | foos[1]() 12 | foos[2]() 13 | } 14 | 15 | // Output: 16 | // 0 17 | // 1 18 | // 2 19 | -------------------------------------------------------------------------------- /_test/closure20.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | foos := []func(){} 5 | 6 | for i := range 3 { 7 | i := i 8 | foos = append(foos, func() { println(i) }) 9 | } 10 | foos[0]() 11 | foos[1]() 12 | foos[2]() 13 | } 14 | 15 | // Output: 16 | // 0 17 | // 1 18 | // 2 19 | -------------------------------------------------------------------------------- /_test/closure8.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var f = func(a int) int { return 2 + a } 4 | 5 | func main() { 6 | println(f(3)) 7 | } 8 | 9 | // Output: 10 | // 5 11 | -------------------------------------------------------------------------------- /_test/comp0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | println(2 < 2.4) 5 | } 6 | 7 | // Output: 8 | // true 9 | -------------------------------------------------------------------------------- /_test/comp1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a interface{} = 1 < 2 5 | println(a.(bool)) 6 | } 7 | 8 | // Output: 9 | // true 10 | -------------------------------------------------------------------------------- /_test/comp2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type delta int32 4 | 5 | func main() { 6 | a := delta(-1) 7 | 8 | println(a != -1) 9 | println(a == -1) 10 | } 11 | 12 | // Output: 13 | // false 14 | // true 15 | -------------------------------------------------------------------------------- /_test/complex0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := complex(3, 2) 7 | fmt.Println(a, real(a), imag(a)) 8 | } 9 | 10 | // Output: 11 | // (3+2i) 3 2 12 | -------------------------------------------------------------------------------- /_test/complex1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var c complex128 7 | c = 1 8 | fmt.Printf("%T %v\n", c, c) 9 | } 10 | 11 | // Output: 12 | // complex128 (1+0i) 13 | -------------------------------------------------------------------------------- /_test/complex2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | c := complex(1, 0) 7 | c += 1 8 | fmt.Printf("%T %v\n", c, c) 9 | } 10 | 11 | // Output: 12 | // complex128 (2+0i) 13 | -------------------------------------------------------------------------------- /_test/complex3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var s int = 1 + complex(1, 0) 7 | fmt.Printf("%T %v\n", s, s) 8 | } 9 | 10 | // Output: 11 | // int 2 12 | -------------------------------------------------------------------------------- /_test/complex4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func f(a, b float64) interface{} { return complex(a, b) } 6 | 7 | func main() { 8 | a := f(3, 2) 9 | fmt.Println(a.(complex128)) 10 | } 11 | 12 | // Output: 13 | // (3+2i) 14 | -------------------------------------------------------------------------------- /_test/composite0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | var a = &[]*T{} 6 | 7 | type T struct{ name string } 8 | 9 | func main() { 10 | fmt.Println(a) 11 | } 12 | 13 | // Output: 14 | // &[] 15 | -------------------------------------------------------------------------------- /_test/composite1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | var a = &[]*T{{}} 6 | 7 | type T struct{ name string } 8 | 9 | func main() { 10 | fmt.Println((*a)[0]) 11 | } 12 | 13 | // Output: 14 | // &{} 15 | -------------------------------------------------------------------------------- /_test/composite10.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := []map[int]int{make(map[int]int)} 7 | 8 | for _, b := range a { 9 | fmt.Println(b) 10 | } 11 | } 12 | 13 | // Output: 14 | // map[] 15 | -------------------------------------------------------------------------------- /_test/composite11.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "image/color" 6 | ) 7 | 8 | func main() { 9 | c := color.NRGBA64{1, 1, 1, 1} 10 | 11 | fmt.Println(c) 12 | } 13 | 14 | // Output: 15 | // {1 1 1 1} 16 | -------------------------------------------------------------------------------- /_test/composite12.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type A struct { 4 | C D 5 | } 6 | 7 | type D struct { 8 | E string 9 | } 10 | 11 | func main() { 12 | a := A{} 13 | a.C = D{"bb"} 14 | 15 | println(a.C.E) 16 | } 17 | 18 | // Output: 19 | // bb 20 | -------------------------------------------------------------------------------- /_test/composite13.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type A struct { 4 | C D 5 | } 6 | 7 | type D struct { 8 | E string 9 | } 10 | 11 | func main() { 12 | a := A{} 13 | a.C = D{E: "bb"} 14 | 15 | println(a.C.E) 16 | } 17 | 18 | // Output: 19 | // bb 20 | -------------------------------------------------------------------------------- /_test/composite14.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type T struct { 6 | b []byte 7 | } 8 | 9 | func main() { 10 | t := T{nil} 11 | fmt.Println(t) 12 | } 13 | 14 | // Output: 15 | // {[]} 16 | -------------------------------------------------------------------------------- /_test/composite16.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/url" 6 | ) 7 | 8 | func main() { 9 | body := url.Values{ 10 | "Action": {"none"}, 11 | } 12 | fmt.Println(body) 13 | } 14 | 15 | // Output: 16 | // map[Action:[none]] 17 | -------------------------------------------------------------------------------- /_test/composite2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | var a = &[]*T{{"hello"}} 6 | 7 | type T struct{ name string } 8 | 9 | func main() { 10 | fmt.Println((*a)[0]) 11 | } 12 | 13 | // Output: 14 | // &{hello} 15 | -------------------------------------------------------------------------------- /_test/composite3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var err error 5 | var ok bool 6 | 7 | _, ok = err.(interface{ IsSet() bool }) 8 | println(ok) 9 | } 10 | 11 | // Output: 12 | // false 13 | -------------------------------------------------------------------------------- /_test/composite4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var err error 5 | 6 | _, ok := err.(interface{ IsSet() bool }) 7 | println(ok) 8 | } 9 | 10 | // Output: 11 | // false 12 | -------------------------------------------------------------------------------- /_test/composite5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type T struct { 6 | m uint16 7 | } 8 | 9 | var t = T{1<<2 | 1<<3} 10 | 11 | func main() { 12 | fmt.Println(t) 13 | } 14 | 15 | // Output: 16 | // {12} 17 | -------------------------------------------------------------------------------- /_test/composite6.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/traefik/yaegi/_test/ct1" 7 | ) 8 | 9 | type T struct { 10 | m uint16 11 | } 12 | 13 | var t = T{1 << ct1.R} 14 | 15 | func main() { 16 | fmt.Println(t) 17 | } 18 | 19 | // Output: 20 | // {2} 21 | -------------------------------------------------------------------------------- /_test/composite7.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | name string 5 | } 6 | 7 | var tab = []*T{{ 8 | name: "foo", 9 | }, { 10 | name: "bar", 11 | }} 12 | 13 | func main() { 14 | println(len(tab)) 15 | println(tab[0].name) 16 | } 17 | 18 | // Output: 19 | // 2 20 | // foo 21 | -------------------------------------------------------------------------------- /_test/composite8.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct{ I int } 4 | 5 | func main() { 6 | t := []*T{} 7 | s := []int{1, 2} 8 | for _, e := range s { 9 | x := &T{e} 10 | t = append(t, x) 11 | } 12 | println(t[0].I, t[1].I) 13 | } 14 | 15 | // Output: 16 | // 1 2 17 | -------------------------------------------------------------------------------- /_test/composite8bis.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct{ I int } 4 | 5 | func main() { 6 | t := []*T{} 7 | s := []int{1, 2} 8 | for _, e := range s { 9 | x := &T{I: e} 10 | t = append(t, x) 11 | } 12 | println(t[0].I, t[1].I) 13 | } 14 | 15 | // Output: 16 | // 1 2 17 | -------------------------------------------------------------------------------- /_test/composite9.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := [][]int{make([]int,0)} 7 | 8 | for _, b := range a { 9 | fmt.Println(b) 10 | } 11 | } 12 | 13 | // Output: 14 | // [] 15 | -------------------------------------------------------------------------------- /_test/const0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const ( 4 | a = iota 5 | b 6 | ) 7 | 8 | func main() { 9 | println(a, b) 10 | } 11 | 12 | // Output: 13 | // 0 1 14 | -------------------------------------------------------------------------------- /_test/const1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | a int 5 | b string 6 | } 7 | 8 | var t = T{1, "hello"} 9 | 10 | func main() { 11 | println(t.a, t.b) 12 | } 13 | 14 | // Output: 15 | // 1 hello 16 | -------------------------------------------------------------------------------- /_test/const10.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const ( 4 | a = 2 5 | b = c + d 6 | c = a + d 7 | d = e + f 8 | e = 3 9 | f = 4 10 | ) 11 | 12 | func main() { 13 | println(b) 14 | } 15 | 16 | // Output: 17 | // 16 18 | -------------------------------------------------------------------------------- /_test/const11.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | const ( 5 | x = 2 * iota 6 | dim 7 | ) 8 | var t [dim * 2]int 9 | println(t[0], len(t)) 10 | } 11 | 12 | // Output: 13 | // 0 4 14 | -------------------------------------------------------------------------------- /_test/const12.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Kind int 4 | 5 | const ( 6 | None Kind = 0 7 | Left Kind = 1 << iota 8 | Right 9 | Both Kind = Left | Right 10 | ) 11 | 12 | func main() { 13 | println(None, Left, Right, Both) 14 | } 15 | 16 | // Output: 17 | // 0 2 4 6 18 | -------------------------------------------------------------------------------- /_test/const14.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "compress/flate" 4 | 5 | func f1(i int) { println("i:", i) } 6 | 7 | func main() { 8 | i := flate.BestSpeed 9 | f1(i) 10 | } 11 | 12 | // Output: 13 | // i: 1 14 | -------------------------------------------------------------------------------- /_test/const15.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T1 t1 4 | 5 | type t1 int8 6 | 7 | const ( 8 | P2 T1 = 2 9 | P3 T1 = 3 10 | ) 11 | 12 | func main() { 13 | println(P3) 14 | } 15 | 16 | // Output: 17 | // 3 18 | -------------------------------------------------------------------------------- /_test/const16.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func main() { 8 | fmt.Println(7 / 3) 9 | } 10 | 11 | // Output: 12 | // 2 13 | -------------------------------------------------------------------------------- /_test/const17.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | var t [7/3]int 6 | 7 | func main() { 8 | t[0] = 3/2 9 | t[1] = 5/2 10 | fmt.Println(t) 11 | } 12 | 13 | // Output: 14 | // [1 2] 15 | -------------------------------------------------------------------------------- /_test/const18.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "time" 4 | 5 | func main() { 6 | a := int64(time.Second) 7 | println(a) 8 | } 9 | 10 | // Output: 11 | // 1000000000 12 | -------------------------------------------------------------------------------- /_test/const19.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func get10Hours() time.Duration { 9 | return 10 * time.Hour 10 | } 11 | 12 | func main() { 13 | fmt.Println(get10Hours().String()) 14 | } 15 | 16 | // Output: 17 | // 10h0m0s 18 | -------------------------------------------------------------------------------- /_test/const2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | println(a) 5 | } 6 | 7 | const a = "hello" 8 | 9 | // Output: 10 | // hello 11 | -------------------------------------------------------------------------------- /_test/const20.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | const maxLen = int64(int64(^uint64(0) >> 1)) 6 | 7 | func main() { 8 | fmt.Println(maxLen) 9 | } 10 | 11 | // Output: 12 | // 9223372036854775807 13 | -------------------------------------------------------------------------------- /_test/const21.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const a = 64 4 | 5 | var b uint = a * a / 2 6 | 7 | func main() { 8 | println(b) 9 | } 10 | 11 | // Output: 12 | // 2048 13 | -------------------------------------------------------------------------------- /_test/const22.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const ( 4 | numDec uint8 = (1 << iota) / 2 5 | numHex 6 | numOct 7 | numFloat 8 | ) 9 | 10 | func main() { 11 | println(13 & (numHex | numOct)) 12 | } 13 | 14 | // Output: 15 | // 1 16 | -------------------------------------------------------------------------------- /_test/const23.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const maxlen = len("hello") 4 | 5 | var gfm = [maxlen]byte{} 6 | 7 | func main() { 8 | println(len(gfm)) 9 | } 10 | 11 | // Output: 12 | // 5 13 | -------------------------------------------------------------------------------- /_test/const24.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var aa = [...]int{1, 2, 3} 4 | 5 | const maxlen = cap(aa) 6 | 7 | var gfm = [maxlen]byte{} 8 | 9 | func main() { 10 | println(len(gfm)) 11 | } 12 | 13 | // Output: 14 | // 3 15 | -------------------------------------------------------------------------------- /_test/const25.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const ( 4 | FGBlack Attribute = iota + 30 5 | ) 6 | 7 | type Attribute int 8 | 9 | func main() { 10 | println(FGBlack) 11 | } 12 | -------------------------------------------------------------------------------- /_test/const3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const a, b, c int = 1, 2, 3 4 | 5 | func main() { println(a, b, c) } 6 | 7 | // Output: 8 | // 1 2 3 9 | -------------------------------------------------------------------------------- /_test/const4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const ( 4 | a = 2 5 | b = 3 6 | c 7 | ) 8 | 9 | func main() { 10 | println(a, b, c) 11 | } 12 | 13 | // Output: 14 | // 2 3 3 15 | -------------------------------------------------------------------------------- /_test/const5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | const ( 8 | a uint8 = 2 * iota 9 | b 10 | c 11 | ) 12 | 13 | func main() { 14 | fmt.Printf("%T\n", c) 15 | fmt.Println(a, b, c) 16 | } 17 | 18 | // Output: 19 | // uint8 20 | // 0 2 4 21 | -------------------------------------------------------------------------------- /_test/const7.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | const ( 6 | a = iota 7 | b 8 | c 9 | d 10 | ) 11 | 12 | type T [c]int 13 | 14 | func main() { 15 | fmt.Println(T{}) 16 | } 17 | 18 | // Output: 19 | // [0 0] 20 | -------------------------------------------------------------------------------- /_test/const8.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const ( 4 | a = 2 5 | b = c + d 6 | c = 4 7 | d = 5 8 | ) 9 | 10 | func main() { 11 | println(a, b, c, d) 12 | } 13 | 14 | // Output: 15 | // 2 9 4 5 16 | -------------------------------------------------------------------------------- /_test/const9.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const ( 4 | a = 2 5 | b = c + d 6 | c = a + d 7 | d = e + f 8 | e = b + 2 9 | f = 4 10 | ) 11 | 12 | func main() { 13 | println(b) 14 | } 15 | 16 | // Error: 17 | // 5:2: constant definition loop 18 | -------------------------------------------------------------------------------- /_test/cont.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | for i := 0; i < 10; i++ { 5 | if i < 5 { 6 | continue 7 | } 8 | println(i) 9 | } 10 | } 11 | 12 | // Output: 13 | // 5 14 | // 6 15 | // 7 16 | // 8 17 | // 9 18 | -------------------------------------------------------------------------------- /_test/copy0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := []int{10, 20, 30} 7 | b := [4]int{} 8 | c := b[:] 9 | copy(c, a) 10 | fmt.Println(c) 11 | } 12 | 13 | // Output: 14 | // [10 20 30 0] 15 | -------------------------------------------------------------------------------- /_test/copy1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := []int{10, 20, 30} 7 | b := &[4]int{} 8 | c := b[:] 9 | copy(c, a) 10 | fmt.Println(c) 11 | } 12 | 13 | // Output: 14 | // [10 20 30 0] 15 | -------------------------------------------------------------------------------- /_test/copy2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func f(a, b []int) interface{} { return copy(a, b) } 6 | 7 | func main() { 8 | a := []int{10, 20, 30} 9 | b := [4]int{} 10 | c := b[:] 11 | r := f(c, a) 12 | fmt.Println(r.(int)) 13 | } 14 | 15 | // Output: 16 | // 3 17 | -------------------------------------------------------------------------------- /_test/ct/ct1.go: -------------------------------------------------------------------------------- 1 | package ct 2 | 3 | func init() { println("hello from ct1") } 4 | -------------------------------------------------------------------------------- /_test/ct/ct2.go: -------------------------------------------------------------------------------- 1 | // +build !dummy 2 | 3 | package ct 4 | 5 | func init() { println("hello from ct2") } 6 | -------------------------------------------------------------------------------- /_test/ct/ct3.go: -------------------------------------------------------------------------------- 1 | // +build dummy 2 | 3 | package ct 4 | 5 | func init() { println("hello from ct3") } 6 | -------------------------------------------------------------------------------- /_test/ct1/ct1.go: -------------------------------------------------------------------------------- 1 | package ct1 2 | 3 | type Class uint 4 | 5 | const ( 6 | L Class = iota 7 | R 8 | AL 9 | ) 10 | -------------------------------------------------------------------------------- /_test/d1/d1.go: -------------------------------------------------------------------------------- 1 | package d1 2 | 3 | type T struct { 4 | Name string 5 | } 6 | 7 | func (t *T) F() { println(t.Name) } 8 | 9 | func NewT(s string) *T { return &T{s} } 10 | -------------------------------------------------------------------------------- /_test/d2/d2.go: -------------------------------------------------------------------------------- 1 | package d2 2 | 3 | import "github.com/traefik/yaegi/_test/d1" 4 | 5 | var ( 6 | X = d1.NewT("test") 7 | F = X.F 8 | ) 9 | -------------------------------------------------------------------------------- /_test/d3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/traefik/yaegi/_test/d2" 4 | 5 | func main() { 6 | f := d2.F 7 | f() 8 | } 9 | 10 | // Output: 11 | // test 12 | -------------------------------------------------------------------------------- /_test/defer0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | println("hello") 7 | defer fmt.Println("bye") 8 | defer fmt.Println("au revoir") 9 | println("world") 10 | } 11 | 12 | // Output: 13 | // hello 14 | // world 15 | // au revoir 16 | // bye 17 | -------------------------------------------------------------------------------- /_test/defer1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | println("hello") 7 | defer func() { 8 | fmt.Println("bye") 9 | }() 10 | println("world") 11 | } 12 | 13 | // Output: 14 | // hello 15 | // world 16 | // bye 17 | -------------------------------------------------------------------------------- /_test/defer2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | println("hello") 7 | i := 12 8 | defer func() { 9 | fmt.Println("i:", i) 10 | }() 11 | i = 20 12 | println("world") 13 | } 14 | 15 | // Output: 16 | // hello 17 | // world 18 | // i: 20 19 | -------------------------------------------------------------------------------- /_test/defer3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | "net/http/httptest" 6 | ) 7 | 8 | func main() { 9 | println("hello") 10 | mux := http.NewServeMux() 11 | server := httptest.NewServer(mux) 12 | defer server.Close() 13 | } 14 | 15 | // Output: 16 | // hello 17 | -------------------------------------------------------------------------------- /_test/delete0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := map[string]int{"hello": 1, "world": 3} 7 | delete(a, "hello") 8 | fmt.Println(a) 9 | } 10 | 11 | // Output: 12 | // map[world:3] 13 | -------------------------------------------------------------------------------- /_test/export0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func Test() { 4 | println("Hello from test") 5 | } 6 | 7 | // Output: 8 | // 9 | -------------------------------------------------------------------------------- /_test/export1.go: -------------------------------------------------------------------------------- 1 | package sample 2 | 3 | type Sample struct{ Name string } 4 | 5 | func (s *Sample) Test() { 6 | println("Hello from test", s.Name) 7 | } 8 | 9 | // Output: 10 | // 11 | -------------------------------------------------------------------------------- /_test/fib.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Compute fibonacci numbers, no memoization 4 | func fib(n int) int { 5 | if n < 2 { 6 | return n 7 | } 8 | return fib(n-2) + fib(n-1) 9 | } 10 | 11 | func main() { 12 | println(fib(35)) 13 | //println(fib(10)) 14 | } 15 | -------------------------------------------------------------------------------- /_test/fib0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Compute fibonacci numbers, no memoization 4 | func fib(n int) int { 5 | if n < 2 { 6 | return n 7 | } 8 | return fib(n-2) + fib(n-1) 9 | } 10 | 11 | func main() { 12 | println(fib(4)) 13 | } 14 | 15 | // Output: 16 | // 3 17 | -------------------------------------------------------------------------------- /_test/flag0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | ) 7 | 8 | func main() { 9 | flag.Parse() 10 | fmt.Println("Narg:", flag.NArg()) 11 | } 12 | 13 | // Output: 14 | // Narg: 0 15 | -------------------------------------------------------------------------------- /_test/foo-bar/foo-bar.go: -------------------------------------------------------------------------------- 1 | package bar 2 | 3 | var Name = "foo-bar" 4 | -------------------------------------------------------------------------------- /_test/foo/bar.go: -------------------------------------------------------------------------------- 1 | package foo 2 | 3 | import "github.com/traefik/yaegi/_test/foo/boo" 4 | 5 | var Bar = "BARR" 6 | var Boo = boo.Boo 7 | 8 | func init() { println("init foo") } 9 | -------------------------------------------------------------------------------- /_test/foo/bir.go: -------------------------------------------------------------------------------- 1 | package foo 2 | 3 | import "github.com/traefik/yaegi/_test/foo/boo" 4 | 5 | var Bir = boo.Boo + "22" 6 | -------------------------------------------------------------------------------- /_test/foo/boo/boo.go: -------------------------------------------------------------------------------- 1 | package boo 2 | 3 | var Boo = "Boo" 4 | 5 | func init() { println("init boo") } 6 | -------------------------------------------------------------------------------- /_test/for0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | i := 0 5 | //for ;i >= 0; i++ { 6 | for { 7 | if i > 5 { 8 | break 9 | } 10 | println(i) 11 | i++ 12 | } 13 | } 14 | 15 | // Output: 16 | // 0 17 | // 1 18 | // 2 19 | // 3 20 | // 4 21 | // 5 22 | -------------------------------------------------------------------------------- /_test/for1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | i := 0 5 | for i < 10 { 6 | if i > 4 { 7 | break 8 | } 9 | println(i) 10 | i++ 11 | } 12 | } 13 | 14 | // Output: 15 | // 0 16 | // 1 17 | // 2 18 | // 3 19 | // 4 20 | -------------------------------------------------------------------------------- /_test/for10.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | for a := 0; false; { 5 | println("nok", a) 6 | a++ 7 | break 8 | } 9 | println("bye") 10 | } 11 | 12 | // Output: 13 | // bye 14 | -------------------------------------------------------------------------------- /_test/for11.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 0 5 | for ; true; a++ { 6 | println("nok", a) 7 | break 8 | } 9 | println("bye", a) 10 | } 11 | 12 | // Output: 13 | // nok 0 14 | // bye 0 15 | -------------------------------------------------------------------------------- /_test/for12.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | for a := 0; false; a++ { 5 | println("nok", a) 6 | break 7 | } 8 | println("bye") 9 | } 10 | 11 | // Output: 12 | // bye 13 | -------------------------------------------------------------------------------- /_test/for13.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 0 5 | for ; false; a++ { 6 | println("nok", a) 7 | break 8 | } 9 | println("bye", a) 10 | } 11 | 12 | // Output: 13 | // bye 0 14 | -------------------------------------------------------------------------------- /_test/for14.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | for a := 0; true; a++ { 5 | println(a) 6 | if a > 0 { 7 | break 8 | } 9 | } 10 | println("bye") 11 | } 12 | 13 | // Output: 14 | // 0 15 | // 1 16 | // bye 17 | -------------------------------------------------------------------------------- /_test/for15.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func f() int { println("in f"); return 1 } 4 | 5 | func main() { 6 | for i := f(); ; { 7 | println("in loop") 8 | if i > 0 { 9 | break 10 | } 11 | } 12 | } 13 | 14 | // Output: 15 | // in f 16 | // in loop 17 | -------------------------------------------------------------------------------- /_test/for16.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | max := 1 5 | for ; ; max-- { 6 | if max == 0 { 7 | break 8 | } 9 | println("in for") 10 | } 11 | println("bye") 12 | } 13 | 14 | // Output: 15 | // in for 16 | // bye 17 | -------------------------------------------------------------------------------- /_test/for17.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | mx := 3 5 | for i := range mx { 6 | println(i) 7 | } 8 | } 9 | 10 | // Output: 11 | // 0 12 | // 1 13 | // 2 14 | -------------------------------------------------------------------------------- /_test/for18.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | for i := range 3 { 5 | println(i) 6 | } 7 | } 8 | 9 | // Output: 10 | // 0 11 | // 1 12 | // 2 13 | -------------------------------------------------------------------------------- /_test/for19.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | for range 3 { 5 | println("i") 6 | } 7 | } 8 | 9 | // Output: 10 | // i 11 | // i 12 | // i 13 | -------------------------------------------------------------------------------- /_test/for2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | for i := 2; ; i++ { 5 | println(i) 6 | if i > 3 { 7 | break 8 | } 9 | } 10 | } 11 | 12 | // Output: 13 | // 2 14 | // 3 15 | // 4 16 | -------------------------------------------------------------------------------- /_test/for4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | for i := 1; i <= 2; i++ { 5 | var x, y int 6 | println(x, y) 7 | x, y = i, 2*i 8 | println(x, y) 9 | } 10 | } 11 | 12 | // Output: 13 | // 0 0 14 | // 1 2 15 | // 0 0 16 | // 2 4 17 | -------------------------------------------------------------------------------- /_test/for5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a bool 5 | 6 | for a { 7 | println("nok") 8 | break 9 | } 10 | println("bye") 11 | } 12 | 13 | // Output: 14 | // bye 15 | -------------------------------------------------------------------------------- /_test/for7.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | for i := 0; i; { 5 | } 6 | } 7 | 8 | // Error: 9 | // 4:14: non-bool used as for condition 10 | -------------------------------------------------------------------------------- /_test/for8.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | for i := 0; i < 4; i++ { 5 | for { 6 | break 7 | } 8 | if i == 1 { 9 | continue 10 | } 11 | println(i) 12 | } 13 | } 14 | 15 | // Output: 16 | // 0 17 | // 2 18 | // 3 19 | -------------------------------------------------------------------------------- /_test/for9.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | for false { 5 | println("nok") 6 | break 7 | } 8 | println("bye") 9 | } 10 | 11 | // Output: 12 | // bye 13 | -------------------------------------------------------------------------------- /_test/fun.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func f(i int) int { return i + 15 } 4 | 5 | func main() { 6 | println(f(4)) 7 | } 8 | 9 | // Output: 10 | // 19 11 | -------------------------------------------------------------------------------- /_test/fun11.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var f F 4 | 5 | type F func(int) 6 | 7 | func main() { 8 | println("ok") 9 | } 10 | 11 | // Output: 12 | // ok 13 | -------------------------------------------------------------------------------- /_test/fun12.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func use(interface{}) {} 4 | 5 | func main() { 6 | z := map[string]interface{}{"a": 5} 7 | use(z) 8 | println("bye") 9 | } 10 | 11 | // Output: 12 | // bye 13 | -------------------------------------------------------------------------------- /_test/fun14.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func f() (bool, int) { return true, 2 } 4 | 5 | func g() (bool, int) { return f() } 6 | 7 | func main() { 8 | b, i := g() 9 | println(b, i) 10 | } 11 | 12 | // Output: 13 | // true 2 14 | -------------------------------------------------------------------------------- /_test/fun15.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func f1(a int) interface{} { return a + 1 } 4 | 5 | func f2(a int64) interface{} { return a + 1 } 6 | 7 | func main() { 8 | c := f1(3) 9 | println(c.(int)) 10 | b := f2(3) 11 | println(b.(int64)) 12 | } 13 | 14 | // Output: 15 | // 4 16 | // 4 17 | -------------------------------------------------------------------------------- /_test/fun17.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func f1(a int) interface{} { return a + 1 } 4 | 5 | func f2(a int) interface{} { return f1(a) } 6 | 7 | func main() { 8 | c := f2(3) 9 | println(c.(int)) 10 | } 11 | 12 | // Output: 13 | // 4 14 | -------------------------------------------------------------------------------- /_test/fun18.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var m = map[string]int{"foo": 1, "bar": 2} 4 | 5 | func f(s string) interface{} { return m[s] } 6 | 7 | func main() { 8 | println(f("foo").(int)) 9 | } 10 | 11 | // Output: 12 | // 1 13 | -------------------------------------------------------------------------------- /_test/fun19.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func foo() ([]string, error) { 8 | return nil, fmt.Errorf("bar") 9 | } 10 | 11 | func main() { 12 | a, b := foo() 13 | fmt.Println(a, b) 14 | } 15 | 16 | // Output: 17 | // [] bar 18 | -------------------------------------------------------------------------------- /_test/fun2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Coord struct{ x, y int } 4 | 5 | func f(c Coord) int { return c.x + c.y } 6 | 7 | func main() { 8 | c := Coord{3, 4} 9 | println(f(c)) 10 | } 11 | 12 | // Output: 13 | // 7 14 | -------------------------------------------------------------------------------- /_test/fun21.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func Bar() string { 4 | return 5 | } 6 | 7 | func main() { 8 | println(Bar()) 9 | } 10 | 11 | // Error: 12 | // 4:2: not enough arguments to return 13 | -------------------------------------------------------------------------------- /_test/fun22.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "time" 4 | 5 | func main() { 6 | time.Date() 7 | } 8 | 9 | // Error: 10 | // 6:2: not enough arguments in call to time.Date 11 | -------------------------------------------------------------------------------- /_test/fun23.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func f(x int) { return x } 4 | 5 | func main() { 6 | print("hello") 7 | } 8 | 9 | // Error: 10 | // 3:17: too many arguments to return 11 | -------------------------------------------------------------------------------- /_test/fun24.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func f(x int) (int, int) { return x, "foo" } 4 | 5 | func main() { 6 | print("hello") 7 | } 8 | 9 | // Error: 10 | // cannot use "foo" (type stringT) as type intT in return argument 11 | -------------------------------------------------------------------------------- /_test/fun25.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func f(x string) (a int, b int) { return x, 5 } 4 | 5 | func main() { 6 | print("hello") 7 | } 8 | 9 | // Error: 10 | // cannot use x (type stringT) as type intT in return argument 11 | -------------------------------------------------------------------------------- /_test/fun26.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type F func() (int, error) 4 | 5 | func f1() (int, error) { return 3, nil } 6 | 7 | func f2(a string, f F) { 8 | c, _ := f() 9 | println(a, c) 10 | } 11 | 12 | func main() { 13 | f2("hello", F(f1)) 14 | } 15 | 16 | // Output: 17 | // hello 3 18 | -------------------------------------------------------------------------------- /_test/fun3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Coord struct{ x, y int } 4 | 5 | func f(i, j int, c Coord) int { return i*c.x + j*c.y } 6 | 7 | func main() { 8 | c := Coord{3, 4} 9 | println(f(2, 3, c)) 10 | } 11 | 12 | // Output: 13 | // 18 14 | -------------------------------------------------------------------------------- /_test/fun4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func f() {} 4 | 5 | func main() { 6 | f() 7 | println("ok") 8 | } 9 | 10 | // Output: 11 | // ok 12 | -------------------------------------------------------------------------------- /_test/fun5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func f(i int64) { 4 | println(i) 5 | } 6 | 7 | func main() { 8 | f(34) 9 | } 10 | 11 | // Output: 12 | // 34 13 | -------------------------------------------------------------------------------- /_test/fun7.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | goflag "flag" 5 | "fmt" 6 | ) 7 | 8 | func Foo(goflag *goflag.Flag) { 9 | fmt.Println(goflag) 10 | } 11 | 12 | func main() { 13 | g := &goflag.Flag{} 14 | Foo(g) 15 | } 16 | 17 | // Output: 18 | // &{ } 19 | -------------------------------------------------------------------------------- /_test/fun8.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { println(f == nil) } 4 | 5 | var f func() 6 | 7 | // Output: 8 | // true 9 | -------------------------------------------------------------------------------- /_test/fun9.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T uint 4 | 5 | func main() { 6 | type myint int 7 | var i = myint(1) 8 | println(i) 9 | } 10 | 11 | // Output: 12 | // 1 13 | -------------------------------------------------------------------------------- /_test/gen10.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func genFunc() (f func()) { 4 | return f 5 | } 6 | 7 | func main() { 8 | println(genFunc() == nil) 9 | } 10 | 11 | // Output: 12 | // true 13 | -------------------------------------------------------------------------------- /_test/goto0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | println("foo") 5 | goto L1 6 | println("Hello") 7 | L1: 8 | println("bar") 9 | println("bye") 10 | } 11 | 12 | // Output: 13 | // foo 14 | // bar 15 | // bye 16 | -------------------------------------------------------------------------------- /_test/goto1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | if true { 5 | goto here 6 | } 7 | here: 8 | println("ok") 9 | } 10 | 11 | // Output: 12 | // ok 13 | -------------------------------------------------------------------------------- /_test/if.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | if a := f(); a > 0 { 5 | println(a) 6 | } 7 | } 8 | 9 | func f() int { return 1 } 10 | 11 | // Output: 12 | // 1 13 | -------------------------------------------------------------------------------- /_test/if0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a bool 5 | 6 | if a { 7 | println("ok") 8 | } else { 9 | println("nok") 10 | } 11 | } 12 | 13 | // Output: 14 | // nok 15 | -------------------------------------------------------------------------------- /_test/if1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | i := 1 5 | if i > 0 { 6 | } 7 | println("bye") 8 | } 9 | 10 | // Output: 11 | // bye 12 | -------------------------------------------------------------------------------- /_test/if2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var i int 7 | if i % 1000000 { 8 | fmt.Println("oops") 9 | } 10 | } 11 | 12 | // Error: 13 | // 7:5: non-bool used as if condition 14 | -------------------------------------------------------------------------------- /_test/if3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 0 5 | if false { 6 | println("false") 7 | a = 1 8 | } else { 9 | println("true") 10 | a = -1 11 | } 12 | println(a) 13 | } 14 | 15 | // Output: 16 | // true 17 | // -1 18 | -------------------------------------------------------------------------------- /_test/if4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const bad = false 4 | 5 | func main() { 6 | a := 0 7 | if bad { 8 | println("false") 9 | a = 1 10 | } else { 11 | println("true") 12 | a = -1 13 | } 14 | println(a) 15 | } 16 | 17 | // Output: 18 | // true 19 | // -1 20 | -------------------------------------------------------------------------------- /_test/if5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | if true { 5 | println("ok") 6 | } 7 | println("bye") 8 | } 9 | 10 | // Output: 11 | // ok 12 | // bye 13 | -------------------------------------------------------------------------------- /_test/if6.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | if false { 5 | println("nok") 6 | } 7 | println("bye") 8 | } 9 | 10 | // Output: 11 | // bye 12 | -------------------------------------------------------------------------------- /_test/if7.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 0 5 | b := false 6 | if (b) { 7 | a = 1 8 | } else { 9 | a = -1 10 | } 11 | println(a) 12 | } 13 | 14 | // Output: 15 | // -1 16 | -------------------------------------------------------------------------------- /_test/imag0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func f(c complex128) interface{} { return imag(c) } 6 | 7 | func main() { 8 | c := complex(3, 2) 9 | a := f(c) 10 | fmt.Println(a.(float64)) 11 | } 12 | 13 | // Output: 14 | // 2 15 | -------------------------------------------------------------------------------- /_test/import0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println("Hello", 42) 7 | } 8 | 9 | // Output: 10 | // Hello 42 11 | -------------------------------------------------------------------------------- /_test/import1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import f "fmt" 4 | 5 | func main() { 6 | f.Println("Hello", 42) 7 | } 8 | 9 | // Output: 10 | // Hello 42 11 | -------------------------------------------------------------------------------- /_test/import2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import . "fmt" 4 | 5 | func main() { 6 | Println("Hello", 42) 7 | } 8 | 9 | // Output: 10 | // Hello 42 11 | -------------------------------------------------------------------------------- /_test/import3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/traefik/yaegi/_test/foo" 4 | 5 | func main() { println(foo.Bar, foo.Boo) } 6 | 7 | // Output: 8 | // init boo 9 | // init foo 10 | // BARR Boo 11 | -------------------------------------------------------------------------------- /_test/import4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/traefik/yaegi/_test/p1" 4 | 5 | func main() { println("num:", p1.Uint32()) } 6 | 7 | // Output: 8 | // num: 2596996162 9 | -------------------------------------------------------------------------------- /_test/import5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import boo "github.com/traefik/yaegi/_test/foo" 4 | 5 | func main() { println(boo.Bar, boo.Boo, boo.Bir) } 6 | 7 | // Output: 8 | // init boo 9 | // init foo 10 | // BARR Boo Boo22 11 | -------------------------------------------------------------------------------- /_test/import6.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/traefik/yaegi/_test/c1" 4 | 5 | func main() { 6 | println(c1.C1) 7 | } 8 | 9 | // Error: 10 | // import cycle not allowed 11 | // imports github.com/traefik/yaegi/_test/c1 12 | -------------------------------------------------------------------------------- /_test/import7.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import bar "github.com/traefik/yaegi/_test/foo-bar" 4 | 5 | func main() { 6 | println(bar.Name) 7 | } 8 | 9 | // Output: 10 | // foo-bar 11 | -------------------------------------------------------------------------------- /_test/import8.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/traefik/yaegi/_test/b1/foo" 4 | 5 | func main() { 6 | println(foo.Desc) 7 | } 8 | 9 | // Output: 10 | // in b1/foo 11 | -------------------------------------------------------------------------------- /_test/import9.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/traefik/yaegi/_test/baz-bat" 4 | 5 | func main() { 6 | println(baz.Name) 7 | } 8 | 9 | // Output: 10 | // baz-bat 11 | -------------------------------------------------------------------------------- /_test/inc.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | i := 2 5 | //i++ 6 | i = i + 1 7 | println(i) 8 | } 9 | 10 | // Output: 11 | // 3 12 | -------------------------------------------------------------------------------- /_test/init1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func init() { 4 | println("here") 5 | } 6 | 7 | func main() { 8 | init() 9 | } 10 | 11 | // Error: 12 | // _test/init1.go:8:2: undefined: init 13 | -------------------------------------------------------------------------------- /_test/interface10.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Edge interface { 4 | ReverseEdge() Edge 5 | } 6 | 7 | func main() { 8 | println("hello") 9 | } 10 | 11 | // Output: 12 | // hello 13 | -------------------------------------------------------------------------------- /_test/interface12.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type I1 interface { 4 | Truc() 5 | } 6 | 7 | type T1 struct{} 8 | 9 | func (T1) Truc() { println("in T1 truc") } 10 | 11 | var x I1 = T1{} 12 | 13 | func main() { 14 | x.Truc() 15 | } 16 | 17 | // Output: 18 | // in T1 truc 19 | -------------------------------------------------------------------------------- /_test/interface14.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct{} 4 | 5 | func (t *T) Error() string { return "T: error" } 6 | 7 | var invalidT = &T{} 8 | 9 | func main() { 10 | var err error 11 | if err != invalidT { 12 | println("ok") 13 | } 14 | } 15 | 16 | // Output: 17 | // ok 18 | -------------------------------------------------------------------------------- /_test/interface17.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct{} 4 | 5 | func (t T) Error() string { return "T: error" } 6 | 7 | var invalidT = T{} 8 | 9 | func main() { 10 | var err error 11 | if err != invalidT { 12 | println("ok") 13 | } 14 | } 15 | 16 | // Output: 17 | // ok 18 | -------------------------------------------------------------------------------- /_test/interface19.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | var I interface{} 6 | 7 | func main() { 8 | fmt.Printf("%T %v\n", I, I) 9 | } 10 | 11 | // Output: 12 | // 13 | -------------------------------------------------------------------------------- /_test/interface20.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var a interface{} 7 | a = string("A") 8 | fmt.Println(a) 9 | } 10 | 11 | // Output: 12 | // A 13 | -------------------------------------------------------------------------------- /_test/interface21.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | s := make([]interface{}, 1) 7 | s[0] = 1 8 | fmt.Println(s[0]) 9 | } 10 | 11 | // Output: 12 | // 1 13 | -------------------------------------------------------------------------------- /_test/interface22.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | s := make([]interface{}, 0) 7 | s = append(s, 1) 8 | fmt.Println(s[0]) 9 | } 10 | 11 | // Output: 12 | // 1 13 | -------------------------------------------------------------------------------- /_test/interface23.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | m := make(map[string]interface{}) 7 | m["A"] = string("A") 8 | fmt.Println(m["A"]) 9 | } 10 | 11 | // Output: 12 | // A 13 | -------------------------------------------------------------------------------- /_test/interface24.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | m := make(map[string]interface{}) 7 | fmt.Println(m["B"]) 8 | } 9 | 10 | // Output: 11 | // 12 | -------------------------------------------------------------------------------- /_test/interface25.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | m := make(map[string]interface{}) 7 | m["A"] = 1 8 | for _, v := range m { 9 | fmt.Println(v) 10 | } 11 | } 12 | 13 | // Output: 14 | // 1 15 | -------------------------------------------------------------------------------- /_test/interface26.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | s := make([]interface{}, 0) 7 | s = append(s, 1) 8 | for _, v := range s { 9 | fmt.Println(v) 10 | } 11 | } 12 | 13 | // Output: 14 | // 1 15 | -------------------------------------------------------------------------------- /_test/interface27.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | var errs = map[int]error{0: nil} 6 | 7 | func main() { 8 | fmt.Println(errs) 9 | } 10 | 11 | // Output: 12 | // map[0:] 13 | -------------------------------------------------------------------------------- /_test/interface28.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | var errs = []error{nil} 6 | 7 | func main() { 8 | fmt.Println(errs) 9 | } 10 | 11 | // Output: 12 | // [] 13 | -------------------------------------------------------------------------------- /_test/interface29.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a interface{} 5 | println(a == nil) 6 | } 7 | 8 | // Output: 9 | // true 10 | -------------------------------------------------------------------------------- /_test/interface30.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a interface{} 5 | println(a != nil) 6 | } 7 | 8 | // Output: 9 | // false 10 | -------------------------------------------------------------------------------- /_test/interface31.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | s := []interface{}{"test", 2} 7 | fmt.Println(s[0], s[1]) 8 | } 9 | 10 | // Output: 11 | // test 2 12 | -------------------------------------------------------------------------------- /_test/interface32.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | s := [2]interface{}{"test", 2} 7 | fmt.Println(s[0], s[1]) 8 | } 9 | 10 | // Output: 11 | // test 2 12 | -------------------------------------------------------------------------------- /_test/interface33.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var a = map[string]interface{}{"test": "test"} 7 | fmt.Println(a["test"]) 8 | } 9 | 10 | // Output: 11 | // test 12 | -------------------------------------------------------------------------------- /_test/interface34.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | s := [2]interface{}{1: "test", 0: 2} 7 | fmt.Println(s[0], s[1]) 8 | } 9 | 10 | // Output: 11 | // 2 test 12 | -------------------------------------------------------------------------------- /_test/interface35.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type T struct { 6 | I interface{} 7 | } 8 | 9 | func main() { 10 | t := T{"test"} 11 | fmt.Println(t) 12 | } 13 | 14 | // Output: 15 | // {test} 16 | -------------------------------------------------------------------------------- /_test/interface42.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | v := interface{}(0) 7 | 8 | fmt.Println(v) 9 | } 10 | 11 | // Output: 12 | // 0 13 | -------------------------------------------------------------------------------- /_test/interface43.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | v := interface{}(nil) 7 | 8 | fmt.Println(v) 9 | } 10 | 11 | // Output: 12 | // 13 | -------------------------------------------------------------------------------- /_test/interface44.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type S struct { 4 | a int 5 | } 6 | 7 | func main() { 8 | var i interface{} = S{a: 1} 9 | 10 | s, ok := i.(S) 11 | if !ok { 12 | println("bad") 13 | return 14 | } 15 | println(s.a) 16 | } 17 | 18 | // Output: 19 | // 1 20 | -------------------------------------------------------------------------------- /_test/interface45.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var i interface{} = 1 7 | var s struct{} 8 | s, _ = i.(struct{}) 9 | fmt.Println(s) 10 | } 11 | 12 | // Output: 13 | // {} 14 | -------------------------------------------------------------------------------- /_test/interface48.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type I1 interface{ A } 6 | 7 | type A = I2 8 | 9 | type I2 interface{ F() I1 } 10 | 11 | func main() { 12 | var i I1 13 | fmt.Println(i) 14 | } 15 | 16 | // Output: 17 | // 18 | -------------------------------------------------------------------------------- /_test/interface50.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := true 5 | var b interface{} = 5 6 | println(b.(int)) 7 | b = a == true 8 | println(b.(bool)) 9 | } 10 | 11 | // Output: 12 | // 5 13 | // true 14 | -------------------------------------------------------------------------------- /_test/interface52.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "testing" 4 | 5 | func main() { 6 | t := testing.T{} 7 | var tb testing.TB 8 | tb = &t 9 | if tb.TempDir() == "" { 10 | println("FAIL") 11 | return 12 | } 13 | println("PASS") 14 | } 15 | 16 | // Output: 17 | // PASS 18 | -------------------------------------------------------------------------------- /_test/interface9.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type Int int 6 | 7 | func (I Int) String() string { 8 | return "foo" 9 | } 10 | 11 | func main() { 12 | var i Int 13 | var st fmt.Stringer = i 14 | fmt.Println(st.String()) 15 | } 16 | 17 | // Output: 18 | // foo 19 | -------------------------------------------------------------------------------- /_test/interp.gi: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/traefik/yaegi/interp" 5 | ) 6 | 7 | func main() { 8 | i := interp.New(interp.Opt{}) 9 | i.Eval(`println("Hello")`) 10 | } 11 | 12 | // Output: 13 | // Hello 14 | -------------------------------------------------------------------------------- /_test/io0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "crypto/rand" 5 | "fmt" 6 | "io" 7 | ) 8 | 9 | func main() { 10 | var buf [16]byte 11 | fmt.Println(buf) 12 | io.ReadFull(rand.Reader, buf[:]) 13 | //io.ReadFull(rand.Reader, buf) 14 | fmt.Println(buf) 15 | } 16 | -------------------------------------------------------------------------------- /_test/io1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/base64" 5 | "fmt" 6 | ) 7 | 8 | func main() { 9 | var buf [4]byte 10 | s := base64.RawStdEncoding.EncodeToString(buf[:]) 11 | fmt.Println(s) 12 | } 13 | 14 | // Output: 15 | // AAAAAA 16 | -------------------------------------------------------------------------------- /_test/issue-1022.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | defer func() { 7 | r := recover() 8 | if r != nil { 9 | fmt.Println(r) 10 | } 11 | }() 12 | 13 | panic("Ho Ho Ho!") 14 | } 15 | 16 | // Output: 17 | // Ho Ho Ho! 18 | -------------------------------------------------------------------------------- /_test/issue-1068.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type I interface { 4 | Hello() 5 | } 6 | 7 | type T struct{} 8 | 9 | func (t T) Hello() { println("hello") } 10 | 11 | type I2 I 12 | 13 | func main() { 14 | var i I2 = T{} 15 | i.Hello() 16 | } 17 | 18 | // Output: 19 | // hello 20 | -------------------------------------------------------------------------------- /_test/issue-1089.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | fmt.Println(`"` + time.RFC3339Nano + `"`) 10 | } 11 | 12 | // Output: 13 | // "2006-01-02T15:04:05.999999999Z07:00" 14 | -------------------------------------------------------------------------------- /_test/issue-1093.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func b() string { 4 | return "b" 5 | } 6 | 7 | func main() { 8 | var x int 9 | x = "a" + b() 10 | } 11 | 12 | // Error: 13 | // 9:6: cannot use type untyped string as type int in assignment 14 | -------------------------------------------------------------------------------- /_test/issue-1094.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var x interface{} 7 | x = "a" + fmt.Sprintf("b") 8 | fmt.Printf("%v %T\n", x, x) 9 | } 10 | 11 | // Output: 12 | // ab string 13 | -------------------------------------------------------------------------------- /_test/issue-1101.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | ) 7 | 8 | func main() { 9 | method := "POST" 10 | switch method { 11 | case http.MethodPost: 12 | fmt.Println("It's a post!") 13 | } 14 | } 15 | 16 | // Output: 17 | // It's a post! 18 | -------------------------------------------------------------------------------- /_test/issue-1128.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "net" 4 | 5 | func main() { 6 | c := append(net.Buffers{}, []byte{}) 7 | println(len(c)) 8 | } 9 | 10 | // Output: 11 | // 1 12 | -------------------------------------------------------------------------------- /_test/issue-1145.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "sync" 4 | 5 | type F func() 6 | 7 | func main() { 8 | var wg sync.WaitGroup 9 | var f F = wg.Done 10 | println(f != nil) 11 | } 12 | 13 | // Output: 14 | // true 15 | -------------------------------------------------------------------------------- /_test/issue-1173.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var real = func() { println("Hello") } 4 | 5 | func main() { 6 | real() 7 | } 8 | 9 | // Output: 10 | // Hello 11 | -------------------------------------------------------------------------------- /_test/issue-1175.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Level int8 4 | 5 | const ( 6 | a Level = -1 7 | b Level = 5 8 | d = b - a + 1 9 | ) 10 | 11 | type counters [d]int 12 | 13 | func main() { 14 | println(len(counters{})) 15 | } 16 | 17 | // Output: 18 | // 7 19 | -------------------------------------------------------------------------------- /_test/issue-1177.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type counters [3][16]int 4 | 5 | func main() { 6 | cs := &counters{} 7 | p := &cs[0][1] 8 | *p = 2 9 | println(cs[0][1]) 10 | } 11 | 12 | // Output: 13 | // 2 14 | -------------------------------------------------------------------------------- /_test/issue-1181.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a, b := 1, 2 5 | a, b = b, -a 6 | println(a, b) 7 | } 8 | 9 | // Output: 10 | // 2 -1 11 | -------------------------------------------------------------------------------- /_test/issue-1288.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | println("Hi") 5 | goto done 6 | done: 7 | } 8 | 9 | // Output: 10 | // Hi 11 | -------------------------------------------------------------------------------- /_test/issue-1306.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func check() (result bool, err error) { 6 | return true, nil 7 | } 8 | 9 | func main() { 10 | result, error := check() 11 | fmt.Println(result, error) 12 | } 13 | 14 | // Output: 15 | // true 16 | -------------------------------------------------------------------------------- /_test/issue-1311.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | v interface{} 5 | } 6 | 7 | func f() (ret int64, err error) { 8 | ret += 2 9 | return 10 | } 11 | 12 | func main() { 13 | t := &T{} 14 | t.v, _ = f() 15 | println(t.v.(int64)) 16 | } 17 | 18 | // Output: 19 | // 2 20 | -------------------------------------------------------------------------------- /_test/issue-1342.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var a interface{} 7 | a = "a" 8 | fmt.Println(a, a == "a") 9 | } 10 | 11 | // Output: 12 | // a true 13 | -------------------------------------------------------------------------------- /_test/issue-1344.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var m = map[string]interface{}{"a": "a"} 7 | a, _ := m["a"] 8 | b, ok := a.(string) 9 | fmt.Println("a:", a, ", b:", b, ", ok:", ok) 10 | } 11 | 12 | // Output: 13 | // a: a , b: a , ok: true 14 | -------------------------------------------------------------------------------- /_test/issue-1360.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | . "net" 6 | ) 7 | 8 | func main() { 9 | v := IP{} 10 | fmt.Println(v) 11 | } 12 | 13 | // Output: 14 | // 15 | -------------------------------------------------------------------------------- /_test/issue-1364.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | func main() { 9 | var value interface{} 10 | var err error 11 | value, err = strconv.ParseFloat("123", 64) 12 | fmt.Println(value, err) 13 | } 14 | 15 | // Output: 16 | // 123 17 | -------------------------------------------------------------------------------- /_test/issue-1368.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const dollar byte = 36 4 | 5 | func main() { 6 | var c byte = 36 7 | switch true { 8 | case c == dollar: 9 | println("ok") 10 | default: 11 | println("not ok") 12 | } 13 | } 14 | 15 | // Output: 16 | // ok 17 | -------------------------------------------------------------------------------- /_test/issue-1373.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "go/ast" 6 | ) 7 | 8 | func NewBadExpr() ast.Expr { 9 | return &ast.BadExpr{} 10 | } 11 | 12 | func main() { 13 | fmt.Printf("%T\n", NewBadExpr().(*ast.BadExpr)) 14 | } 15 | 16 | // Output: 17 | // *ast.BadExpr 18 | -------------------------------------------------------------------------------- /_test/issue-1408.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type ( 4 | Number = int32 5 | Number2 = Number 6 | ) 7 | 8 | func f(n Number2) { println(n) } 9 | 10 | func main() { 11 | var n Number = 5 12 | f(n) 13 | } 14 | 15 | // Output: 16 | // 5 17 | -------------------------------------------------------------------------------- /_test/issue-1411.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Number int32 4 | 5 | func (n Number) IsValid() bool { return true } 6 | 7 | type Number1 = Number 8 | 9 | type Number2 = Number1 10 | 11 | func main() { 12 | a := Number2(5) 13 | println(a.IsValid()) 14 | } 15 | 16 | // Output: true 17 | -------------------------------------------------------------------------------- /_test/issue-1421.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Number = int 4 | 5 | func main() { 6 | println(Number(1) < int(2)) 7 | } 8 | 9 | // Output: true 10 | -------------------------------------------------------------------------------- /_test/issue-1451.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type t1 uint8 4 | 5 | const ( 6 | n1 t1 = iota 7 | n2 8 | ) 9 | 10 | type T struct { 11 | elem [n2 + 1]int 12 | } 13 | 14 | func main() { 15 | println(len(T{}.elem)) 16 | } 17 | 18 | // Output: 19 | // 2 20 | -------------------------------------------------------------------------------- /_test/issue-1470.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | num [tnum + 2]int 5 | } 6 | 7 | const tnum = 23 8 | 9 | func main() { 10 | t := T{} 11 | println(len(t.num)) 12 | } 13 | 14 | // Output: 15 | // 25 16 | -------------------------------------------------------------------------------- /_test/issue-1475.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T uint16 4 | 5 | func f() T { return 0 } 6 | 7 | func main() { 8 | println(f()) 9 | } 10 | 11 | // Output: 12 | // 0 13 | -------------------------------------------------------------------------------- /_test/issue-1536.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var a [len(prefix+path) + 2]int 4 | 5 | const ( 6 | prefix = "/usr/" 7 | path = prefix + "local/bin" 8 | ) 9 | 10 | func main() { 11 | println(len(a)) 12 | } 13 | 14 | // Output: 15 | // 21 16 | -------------------------------------------------------------------------------- /_test/issue-1571.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type A struct { 4 | *B[string] 5 | } 6 | 7 | type B[T any] struct { 8 | data T 9 | } 10 | 11 | func main() { 12 | _ = &A{ 13 | B: &B[string]{}, 14 | } 15 | 16 | println("PASS") 17 | } 18 | 19 | // Output: 20 | // PASS 21 | -------------------------------------------------------------------------------- /_test/issue-1653.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func f(b uint) uint { 4 | return uint(1) + (0x1 >> b) 5 | } 6 | 7 | func main() { 8 | println(f(1)) 9 | } 10 | 11 | // Output: 12 | // 1 13 | -------------------------------------------------------------------------------- /_test/issue-782.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := []int{1, 2, 3, 4, 5, 6, 7, 8, 9} 7 | from := uint32(2) 8 | to := uint32(4) 9 | b := a[from:to] 10 | fmt.Print(b) 11 | } 12 | 13 | // Output: 14 | // [3 4] 15 | -------------------------------------------------------------------------------- /_test/issue-993.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var m map[string]int64 4 | 5 | func initVar() { 6 | m = make(map[string]int64) 7 | } 8 | 9 | func main() { 10 | initVar() 11 | println(len(m)) 12 | } 13 | 14 | // Output: 15 | // 0 16 | -------------------------------------------------------------------------------- /_test/l3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | //func myprint(i int) { println(i) } 4 | 5 | func main() { 6 | for a := 0; a < 20000000; a++ { 7 | if a&0x8ffff == 0x80000 { 8 | println(a) 9 | //myprint(a) 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /_test/l4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { println(f(5)) } 4 | func f(i int) int { return i + 1 } 5 | 6 | // Output: 7 | // 6 8 | -------------------------------------------------------------------------------- /_test/l5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | //func myprint(i int) { println(i) } 4 | 5 | func main() { 6 | for a := 0; a < 20000000; { 7 | if a&0x8ffff == 0x80000 { 8 | println(a) 9 | } 10 | a = a + 1 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /_test/len0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func f(a []int) interface{} { 4 | return len(a) 5 | } 6 | 7 | func main() { 8 | a := []int{1, 2} 9 | println(f(a).(int)) 10 | } 11 | 12 | // Output: 13 | // 2 14 | -------------------------------------------------------------------------------- /_test/m1/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func main() { 9 | fmt.Println("vim-go") 10 | } 11 | 12 | func TestWeird(t *testing.T) { 13 | fmt.Println("in TestWeird") 14 | } 15 | -------------------------------------------------------------------------------- /_test/m1/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "math/rand" 6 | "testing" 7 | ) 8 | 9 | func TestMain(t *testing.T) { 10 | fmt.Println("in test") 11 | } 12 | 13 | func BenchmarkMain(b *testing.B) { 14 | for i := 0; i < b.N; i++ { 15 | rand.Int() 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /_test/m2/m2_test.go: -------------------------------------------------------------------------------- 1 | package m2 2 | 3 | import "testing" 4 | 5 | func TestM2(t *testing.T) { 6 | t.Errorf("got %s, want %s", "AAA", "BBB") 7 | } 8 | -------------------------------------------------------------------------------- /_test/make.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | ) 7 | 8 | func main() { 9 | h := make(http.Header) 10 | fmt.Println("h:", h) 11 | } 12 | 13 | // Output: 14 | // h: map[] 15 | -------------------------------------------------------------------------------- /_test/make0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func f() interface{} { 4 | return make([]int, 2) 5 | } 6 | 7 | func main() { 8 | a := f() 9 | println(len(a.([]int))) 10 | } 11 | 12 | // Output: 13 | // 2 14 | -------------------------------------------------------------------------------- /_test/make1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func f() interface{} { 6 | return make(map[int]int) 7 | } 8 | 9 | func main() { 10 | a, ok := f().(map[int]int) 11 | fmt.Println(a, ok) 12 | } 13 | 14 | // Output: 15 | // map[] true 16 | -------------------------------------------------------------------------------- /_test/make2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var s uint = 4 7 | t := make([]int, s) 8 | fmt.Println(t) 9 | } 10 | 11 | // Output: 12 | // [0 0 0 0] 13 | -------------------------------------------------------------------------------- /_test/map.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Dict map[string]string 4 | 5 | func main() { 6 | dict := make(Dict) 7 | dict["truc"] = "machin" 8 | println(dict["truc"]) 9 | } 10 | 11 | // Output: 12 | // machin 13 | -------------------------------------------------------------------------------- /_test/map14.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | var m = map[string]float64{"foo": 1.0} 6 | 7 | func f(s string) bool { return m[s] > 0.0 } 8 | 9 | func main() { 10 | fmt.Println(f("foo"), f("bar")) 11 | } 12 | 13 | // Output: 14 | // true false 15 | -------------------------------------------------------------------------------- /_test/map15.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | users := make(map[string]string) 7 | 8 | v := users["a"] 9 | fmt.Println("v:", v) 10 | } 11 | 12 | // Output: 13 | // v: 14 | -------------------------------------------------------------------------------- /_test/map18.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | var foo = make([]int, 1) 6 | 7 | func main() { 8 | for _, v := range foo { 9 | fmt.Println(v) 10 | } 11 | } 12 | 13 | // Output: 14 | // 0 15 | -------------------------------------------------------------------------------- /_test/map19.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type cmap struct { 6 | servers map[int64]*server 7 | } 8 | 9 | type server struct { 10 | cm *cmap 11 | } 12 | 13 | func main() { 14 | m := cmap{} 15 | fmt.Println(m) 16 | } 17 | 18 | // Output: 19 | // {map[]} 20 | -------------------------------------------------------------------------------- /_test/map2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | dict := make(map[string]string) 5 | dict["truc"] = "machin" 6 | println(dict["truc"]) 7 | } 8 | 9 | // Output: 10 | // machin 11 | -------------------------------------------------------------------------------- /_test/map20.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var a = map[int]bool{1: true, 2: true} 4 | 5 | func main() { 6 | println(a[1] && true) 7 | } 8 | 9 | // Output: 10 | // true 11 | -------------------------------------------------------------------------------- /_test/map21.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var m = map[int]string{ 4 | 1: "foo", 5 | } 6 | 7 | func main() { 8 | var ok bool 9 | if _, ok = m[1]; ok { 10 | println("ok") 11 | } 12 | } 13 | 14 | // Output: 15 | // ok 16 | -------------------------------------------------------------------------------- /_test/map22.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var m = map[int]string{ 4 | 1: "foo", 5 | } 6 | 7 | func main() { 8 | var s string 9 | s, _ = m[1] 10 | println(s) 11 | } 12 | 13 | // Output: 14 | // foo 15 | -------------------------------------------------------------------------------- /_test/map23.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var m = map[int]string{ 4 | 1: "foo", 5 | } 6 | 7 | func main() { 8 | _, _ = m[1] 9 | println("ok") 10 | } 11 | 12 | // Output: 13 | // ok 14 | -------------------------------------------------------------------------------- /_test/map26.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var m = map[string]int{"foo": 1, "bar": 2} 4 | 5 | func main() { 6 | var a interface{} = m["foo"] 7 | println(a.(int)) 8 | } 9 | 10 | // Output: 11 | // 1 12 | -------------------------------------------------------------------------------- /_test/map3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | dict := map[string]string{} 5 | dict["truc"] = "machin" 6 | println(dict["truc"]) 7 | } 8 | 9 | // Output: 10 | // machin 11 | -------------------------------------------------------------------------------- /_test/map31.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | myMap := map[string]int{"a":2} 5 | 6 | for s, _ := range myMap { 7 | _ = s 8 | } 9 | println("ok") 10 | } 11 | 12 | // Output: 13 | // ok 14 | -------------------------------------------------------------------------------- /_test/map4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | dict := map[string]string{"bidule": "machin", "truc": "bidule"} 5 | dict["hello"] = "bonjour" 6 | println(dict["bidule"]) 7 | println(dict["hello"]) 8 | } 9 | 10 | // Output: 11 | // machin 12 | // bonjour 13 | -------------------------------------------------------------------------------- /_test/map6.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | dict := map[string]string{"bidule": "machin"} 5 | for k, v := range dict { 6 | println(k, v) 7 | } 8 | } 9 | 10 | // Output: 11 | // bidule machin 12 | -------------------------------------------------------------------------------- /_test/map7.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | dict := map[int32]int64{13: 733} 5 | for k, v := range dict { 6 | println(k, v) 7 | } 8 | } 9 | 10 | // Output: 11 | // 13 733 12 | -------------------------------------------------------------------------------- /_test/math0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "math" 6 | ) 7 | 8 | func main() { 9 | fmt.Println(math.Cos(math.Pi)) 10 | } 11 | 12 | // Output: 13 | // -1 14 | -------------------------------------------------------------------------------- /_test/math1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "math" 4 | 5 | func main() { 6 | var f float32 7 | if f < math.MaxFloat32 { 8 | println("ok") 9 | } 10 | } 11 | 12 | // Output: 13 | // ok 14 | -------------------------------------------------------------------------------- /_test/math2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const c uint64 = 2 4 | 5 | func main() { 6 | if c&(1<<(uint64(1))) > 0 { 7 | println("yes") 8 | } 9 | } 10 | 11 | // Output: 12 | // yes 13 | -------------------------------------------------------------------------------- /_test/method.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Coord struct { 4 | x, y int 5 | } 6 | 7 | func (c Coord) dist() int { return c.x*c.x + c.y*c.y } 8 | 9 | func main() { 10 | o := Coord{3, 4} 11 | println(o.dist()) 12 | } 13 | 14 | // Output: 15 | // 25 16 | -------------------------------------------------------------------------------- /_test/method12.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Coord struct { 4 | x, y int 5 | } 6 | 7 | func (c Coord) dist() int { return c.x*c.x + c.y*c.y } 8 | 9 | func main() { 10 | o := Coord{3, 4} 11 | f := o.dist 12 | println(f()) 13 | } 14 | 15 | // Output: 16 | // 25 17 | -------------------------------------------------------------------------------- /_test/method14.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | o := Coord{3, 4} 5 | println(o.dist()) 6 | } 7 | 8 | func (c *Coord) dist() int { return c.x*c.x + c.y*c.y } 9 | 10 | type Coord struct { 11 | x, y int 12 | } 13 | 14 | // Output: 15 | // 25 16 | -------------------------------------------------------------------------------- /_test/method15.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Coord struct { 4 | x, y int 5 | } 6 | 7 | func (c Coord) dist() int { return c.x*c.x + c.y*c.y } 8 | 9 | func main() { 10 | o := &Coord{3, 4} 11 | println(o.dist()) 12 | } 13 | 14 | // Output: 15 | // 25 16 | -------------------------------------------------------------------------------- /_test/method21.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type Hello struct{} 8 | 9 | func (*Hello) Hi() string { 10 | panic("implement me") 11 | } 12 | 13 | func main() { 14 | fmt.Println(&Hello{}) 15 | } 16 | 17 | // Output: 18 | // &{} 19 | -------------------------------------------------------------------------------- /_test/method22.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func Bar() { 4 | s := Obj.Foo() 5 | println(s) 6 | } 7 | 8 | var Obj = &T{} 9 | 10 | type T struct{} 11 | 12 | func (t *T) Foo() bool { return t != nil } 13 | 14 | func main() { 15 | Bar() 16 | } 17 | 18 | // Output: 19 | // true 20 | -------------------------------------------------------------------------------- /_test/method26.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func NewT(name string) *T { return &T{name} } 4 | 5 | var C = NewT("test") 6 | 7 | func (t *T) f() { println(t == C) } 8 | 9 | type T struct { 10 | Name string 11 | } 12 | 13 | func main() { 14 | C.f() 15 | } 16 | 17 | // Output: 18 | // true 19 | -------------------------------------------------------------------------------- /_test/method28.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type T struct { 6 | Name string 7 | } 8 | 9 | func (T) create() *T { 10 | return &T{"Hello"} 11 | } 12 | 13 | func main() { 14 | fmt.Println(T{}.create()) 15 | } 16 | 17 | // Output: 18 | // &{Hello} 19 | -------------------------------------------------------------------------------- /_test/method32.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func main() { 8 | var a = []func(string){bar} 9 | b := a[0] 10 | b("bar") 11 | } 12 | 13 | func bar(a string) { 14 | fmt.Println(a) 15 | } 16 | 17 | // Output: 18 | // bar 19 | -------------------------------------------------------------------------------- /_test/method35.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "strconv" 4 | 5 | func main() { 6 | var err error 7 | _, err = strconv.Atoi("erwer") 8 | if _, ok := err.(*strconv.NumError); ok { 9 | println("here") 10 | } 11 | } 12 | 13 | // Output: 14 | // here 15 | -------------------------------------------------------------------------------- /_test/method38.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/traefik/yaegi/_test/method38" 7 | ) 8 | 9 | func main() { 10 | fmt.Println(method38.Get()) 11 | } 12 | 13 | // Output: 14 | // &{[] {}} 15 | -------------------------------------------------------------------------------- /_test/method38/b.go: -------------------------------------------------------------------------------- 1 | package method38 2 | 3 | func (p Pool) Get() *Buffer { return &Buffer{} } 4 | -------------------------------------------------------------------------------- /_test/method9.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Coord struct { 4 | x, y int 5 | } 6 | 7 | func main() { 8 | o := Coord{3, 4} 9 | println(o.dist()) 10 | } 11 | 12 | func (c Coord) dist() int { return c.x*c.x + c.y*c.y } 13 | 14 | // Output: 15 | // 25 16 | -------------------------------------------------------------------------------- /_test/named1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type MyT T 6 | 7 | type T struct { 8 | Name string 9 | } 10 | 11 | func main() { 12 | fmt.Println(MyT{}) 13 | } 14 | 15 | // Output: 16 | // {} 17 | -------------------------------------------------------------------------------- /_test/named2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func (t MyT) Test() string { 6 | return "hello" 7 | } 8 | 9 | type MyT int 10 | 11 | func main() { 12 | t := MyT(1) 13 | 14 | fmt.Println(t.Test()) 15 | } 16 | 17 | // Output: 18 | // hello 19 | -------------------------------------------------------------------------------- /_test/neg0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := -1 7 | fmt.Println(a) 8 | } 9 | 10 | // Output: 11 | // -1 12 | -------------------------------------------------------------------------------- /_test/new0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := new(int) 5 | *a = 3 6 | println(*a) 7 | } 8 | 9 | // Output: 10 | // 3 11 | -------------------------------------------------------------------------------- /_test/new1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := [1]*int{} 7 | a[0] = new(int) 8 | *a[0] = 2 9 | fmt.Println(*a[0]) 10 | } 11 | 12 | // Output: 13 | // 2 14 | -------------------------------------------------------------------------------- /_test/new2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func f() interface{} { 4 | return new(int) 5 | } 6 | 7 | func main() { 8 | a := f() 9 | println(*(a.(*int))) 10 | } 11 | 12 | // Output: 13 | // 0 14 | -------------------------------------------------------------------------------- /_test/nil0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func f() (host, port string, err error) { 6 | return "", "", nil 7 | } 8 | 9 | func main() { 10 | h, p, err := f() 11 | fmt.Println(h, p, err) 12 | } 13 | 14 | // Output: 15 | // 16 | -------------------------------------------------------------------------------- /_test/nil1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a error = nil 5 | 6 | if a == nil || a.Error() == "nil" { 7 | println("a is nil") 8 | } 9 | } 10 | 11 | // Output: 12 | // a is nil 13 | -------------------------------------------------------------------------------- /_test/nil2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func test() error { return nil } 4 | 5 | func main() { 6 | if err := test(); nil == err { 7 | println("err is nil") 8 | } 9 | } 10 | 11 | // Output: 12 | // err is nil 13 | -------------------------------------------------------------------------------- /_test/not0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 0 5 | b := true 6 | c := false 7 | if b && c { 8 | a = 1 9 | } else { 10 | a = -1 11 | } 12 | println(a) 13 | } 14 | 15 | // Output: 16 | // -1 17 | -------------------------------------------------------------------------------- /_test/not1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 0 5 | b := true 6 | if (!b) { 7 | a = 1 8 | } else { 9 | a = -1 10 | } 11 | println(a) 12 | } 13 | 14 | // Output: 15 | // -1 16 | -------------------------------------------------------------------------------- /_test/not2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var b interface{} = !(1 == 2) 5 | println(b.(bool)) 6 | } 7 | 8 | // Output: 9 | // true 10 | -------------------------------------------------------------------------------- /_test/num0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Printf("%g\n", 1.0) 7 | } 8 | 9 | // Output: 10 | // 1 11 | -------------------------------------------------------------------------------- /_test/op0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var a, b, c uint16 7 | a = 64 8 | b = 64 9 | c = a * b 10 | fmt.Printf("c: %v %T", c, c) 11 | } 12 | 13 | // Output: 14 | // c: 4096 uint16 15 | -------------------------------------------------------------------------------- /_test/op1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a int = 3 5 | a += 1.3 6 | println(a) 7 | } 8 | 9 | // Error: 10 | // 5:2: invalid operation: mismatched types int and untyped float 11 | -------------------------------------------------------------------------------- /_test/op10.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | _ = 1 + 1 5 | println("ok") 6 | } 7 | 8 | // Output: 9 | // ok 10 | -------------------------------------------------------------------------------- /_test/op11.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a, b := 1, 2 5 | _ = a + b 6 | println("ok") 7 | } 8 | 9 | // Output: 10 | // ok 11 | -------------------------------------------------------------------------------- /_test/op3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := -1.2 7 | fmt.Printf("a: %v %T\n", a, a) 8 | b := -(2 + 1i) 9 | fmt.Printf("b: %v %T\n", b, b) 10 | } 11 | 12 | // Output: 13 | // a: -1.2 float64 14 | // b: (-2-1i) complex128 15 | -------------------------------------------------------------------------------- /_test/op4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | i := 102 5 | println(i % -1e2) 6 | } 7 | 8 | // Output: 9 | // 2 10 | -------------------------------------------------------------------------------- /_test/op5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | i := 100 7 | j := i % 1e2 8 | fmt.Printf("%T %v\n", j, j) 9 | } 10 | 11 | // Output: 12 | // int 0 13 | -------------------------------------------------------------------------------- /_test/op6.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T int 4 | 5 | func (t T) Error() string { return "T: error" } 6 | 7 | var invalidT T 8 | 9 | func main() { 10 | var err error 11 | if err != invalidT { 12 | println("ok") 13 | } 14 | } 15 | 16 | // Output: 17 | // ok 18 | -------------------------------------------------------------------------------- /_test/op9.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var i complex128 = 1i 5 | var f complex128 = 0.4i 6 | 7 | print(i > f) 8 | } 9 | 10 | // Error: 11 | // _test/op9.go:7:8: invalid operation: operator > not defined on complex128 12 | -------------------------------------------------------------------------------- /_test/or0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | c := false 5 | println(c || !c) 6 | } 7 | 8 | // Output: 9 | // true 10 | -------------------------------------------------------------------------------- /_test/or1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | c := false 5 | println(!c || c) 6 | } 7 | 8 | // Output: 9 | // true 10 | -------------------------------------------------------------------------------- /_test/or2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var a = false || true 4 | 5 | func main() { 6 | println(a) 7 | } 8 | 9 | // Output: 10 | // true 11 | -------------------------------------------------------------------------------- /_test/os0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | ) 7 | 8 | func main() { 9 | _, err := os.ReadFile("__NotExisting__") 10 | if err != nil { 11 | fmt.Println(err.Error()) 12 | } 13 | } 14 | 15 | // Output: 16 | // open __NotExisting__: no such file or directory 17 | -------------------------------------------------------------------------------- /_test/p1/s1.go: -------------------------------------------------------------------------------- 1 | package p1 2 | 3 | import "crypto/rand" 4 | 5 | var Prime = rand.Prime 6 | -------------------------------------------------------------------------------- /_test/p1/s2.go: -------------------------------------------------------------------------------- 1 | package p1 2 | 3 | import "math/rand" 4 | 5 | var Uint32 = rand.Uint32 6 | 7 | func init() { rand.Seed(1) } 8 | -------------------------------------------------------------------------------- /_test/p2/p2.go: -------------------------------------------------------------------------------- 1 | package p2 2 | 3 | type I interface { 4 | isI() 5 | } 6 | 7 | type T struct{} 8 | 9 | func (t *T) isI() {} 10 | -------------------------------------------------------------------------------- /_test/p3/empty: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/traefik/yaegi/d93266d013f393a20122ef0dd3f579d411a066be/_test/p3/empty -------------------------------------------------------------------------------- /_test/p4/p4.go: -------------------------------------------------------------------------------- 1 | package p4 2 | 3 | var Value1 = "value1" 4 | -------------------------------------------------------------------------------- /_test/p5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/traefik/yaegi/_test/p5" 4 | 5 | func main() { 6 | println(*p5.Value1) 7 | } 8 | 9 | // Output: 10 | // value1 11 | -------------------------------------------------------------------------------- /_test/p5/p5.go: -------------------------------------------------------------------------------- 1 | package p5 2 | 3 | import "github.com/traefik/yaegi/_test/p4" 4 | 5 | var ( 6 | Value1 = &val1 7 | val1 = p4.Value1 8 | ) 9 | -------------------------------------------------------------------------------- /_test/p6.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/traefik/yaegi/_test/p6" 7 | ) 8 | 9 | func main() { 10 | t := p6.IPPrefixSlice{} 11 | fmt.Println(t) 12 | b, e := t.MarshalJSON() 13 | fmt.Println(string(b), e) 14 | } 15 | -------------------------------------------------------------------------------- /_test/panic0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | foo() 5 | } 6 | 7 | func foo() { 8 | bar() 9 | } 10 | 11 | func bar() { 12 | baz() 13 | } 14 | 15 | func baz() { 16 | panic("stop!") 17 | } 18 | 19 | // Error: 20 | // stop! 21 | -------------------------------------------------------------------------------- /_test/pkgname2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "guthib.com/toto" // pkg name is actually titi 5 | ) 6 | 7 | func main() { 8 | println("Hello", titi.Quux()) 9 | } 10 | 11 | // GOPATH:testdata/redeclaration-global7 12 | // Output: 13 | // Hello bar 14 | -------------------------------------------------------------------------------- /_test/print0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | print("hello") 5 | } 6 | 7 | // Output: 8 | // hello 9 | -------------------------------------------------------------------------------- /_test/ptr0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type myint int 4 | 5 | func main() { 6 | var a myint = 2 7 | var b *myint = &a 8 | println(*b) 9 | } 10 | 11 | // Output: 12 | // 2 13 | -------------------------------------------------------------------------------- /_test/ptr1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a int = 2 5 | b := &a 6 | println(*b) 7 | } 8 | 9 | // Output: 10 | // 2 11 | -------------------------------------------------------------------------------- /_test/ptr2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func f(i *int) { 4 | *i = *i + 3 5 | } 6 | 7 | func main() { 8 | var a int = 2 9 | f(&a) 10 | println(a) 11 | } 12 | 13 | // Output: 14 | // 5 15 | -------------------------------------------------------------------------------- /_test/ptr3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func f(i *int) { 4 | *i++ 5 | } 6 | 7 | func main() { 8 | var a int = 2 9 | f(&a) 10 | println(a) 11 | } 12 | 13 | // Output: 14 | // 3 15 | -------------------------------------------------------------------------------- /_test/ptr4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Foo struct { 4 | val int 5 | } 6 | 7 | func f(p *Foo) { 8 | p.val = p.val + 2 9 | } 10 | 11 | func main() { 12 | var a = Foo{3} 13 | f(&a) 14 | println(a.val) 15 | } 16 | 17 | // Output: 18 | // 5 19 | -------------------------------------------------------------------------------- /_test/ptr5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Foo struct { 4 | val int 5 | } 6 | 7 | func main() { 8 | var a = &Foo{3} 9 | println(a.val) 10 | } 11 | 12 | // Output: 13 | // 3 14 | -------------------------------------------------------------------------------- /_test/ptr5a.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Foo struct { 4 | val int 5 | } 6 | 7 | func main() { 8 | var a = Foo{3} 9 | b := &a 10 | println(b.val) 11 | } 12 | 13 | // Output: 14 | // 3 15 | -------------------------------------------------------------------------------- /_test/ptr6.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Foo struct { 4 | val int 5 | } 6 | 7 | func main() { 8 | var a = Foo{3} 9 | b := &a 10 | println(b.val) 11 | } 12 | 13 | // Output: 14 | // 3 15 | -------------------------------------------------------------------------------- /_test/ptr8.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var a = func() *bool { b := true; return &b }() 4 | 5 | func main() { 6 | println(*a && true) 7 | } 8 | 9 | // Output: 10 | // true 11 | -------------------------------------------------------------------------------- /_test/ptr_array0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T [2]int 4 | 5 | func F0(t *T) int { return t[0] } 6 | 7 | func main() { 8 | t := &T{1, 2} 9 | println(F0(t)) 10 | } 11 | 12 | // Output: 13 | // 1 14 | -------------------------------------------------------------------------------- /_test/ptr_array1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T [3]int 4 | 5 | func F0(t *T) { 6 | for i, v := range t { 7 | println(i, v) 8 | } 9 | } 10 | 11 | func main() { 12 | t := &T{1, 2, 3} 13 | F0(t) 14 | } 15 | 16 | // Output: 17 | // 0 1 18 | // 1 2 19 | // 2 3 20 | -------------------------------------------------------------------------------- /_test/ptr_array2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type T [2]int 6 | 7 | func F1(t *T) { t[0] = 1 } 8 | 9 | func main() { 10 | t := &T{} 11 | F1(t) 12 | fmt.Println(t) 13 | } 14 | 15 | // Output: 16 | // &[1 0] 17 | -------------------------------------------------------------------------------- /_test/ptr_array3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := &[...]int{1, 2, 3} 7 | fmt.Println(a[:]) 8 | } 9 | 10 | // Output: 11 | // [1 2 3] 12 | -------------------------------------------------------------------------------- /_test/range0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | v := []int{1, 2, 3} 7 | for i := range v { 8 | v = append(v, i) 9 | } 10 | fmt.Println(v) 11 | } 12 | 13 | // Output: 14 | // [1 2 3 0 1 2] 15 | -------------------------------------------------------------------------------- /_test/range1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := [...]int{2, 1, 0} 7 | for _, v := range a { 8 | a[v] = v 9 | } 10 | fmt.Println(a) 11 | } 12 | 13 | // Output: 14 | // [0 1 2] 15 | -------------------------------------------------------------------------------- /_test/range2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := [...]int{2, 1, 0} 7 | for _, v := range &a { 8 | a[v] = v 9 | } 10 | fmt.Println(a) 11 | } 12 | 13 | // Output: 14 | // [2 1 2] 15 | -------------------------------------------------------------------------------- /_test/range3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | m := map[int]bool{1: true, 3: true, 5: true} 7 | for k := range m { 8 | m[k*2] = true 9 | } 10 | fmt.Println("ok") 11 | } 12 | 13 | // Output: 14 | // ok 15 | -------------------------------------------------------------------------------- /_test/range4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | m := map[int]bool{1: true, 3: true, 5: true} 7 | for _, v := range m { 8 | fmt.Println(v) 9 | } 10 | } 11 | 12 | // Output: 13 | // true 14 | // true 15 | // true 16 | -------------------------------------------------------------------------------- /_test/range5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | m := map[int]bool{1: true, 3: true, 5: true} 7 | var n int 8 | for range m { 9 | n++ 10 | } 11 | fmt.Println(n) 12 | } 13 | 14 | // Output: 15 | // 3 16 | -------------------------------------------------------------------------------- /_test/range8.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | for _ = range time.Tick(time.Millisecond) { 10 | fmt.Println("success") 11 | return 12 | } 13 | } 14 | 15 | // Output: 16 | // success 17 | -------------------------------------------------------------------------------- /_test/range9.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var c chan<- struct{} = make(chan struct{}) 5 | 6 | for _ = range c { 7 | } 8 | } 9 | 10 | // Error: 11 | // _test/range9.go:6:16: invalid operation: range c receive from send-only channel 12 | -------------------------------------------------------------------------------- /_test/real0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func f(c complex128) interface{} { return real(c) } 6 | 7 | func main() { 8 | c := complex(3, 2) 9 | a := f(c) 10 | fmt.Println(a.(float64)) 11 | } 12 | 13 | // Output: 14 | // 3 15 | -------------------------------------------------------------------------------- /_test/recover0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | println("hello") 7 | defer func() { 8 | r := recover() 9 | fmt.Println("recover:", r) 10 | }() 11 | println("world") 12 | } 13 | 14 | // Output: 15 | // hello 16 | // world 17 | // recover: 18 | -------------------------------------------------------------------------------- /_test/recover2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | println("hello") 5 | 6 | var r interface{} = 1 7 | r = recover() 8 | if r == nil { 9 | println("world") 10 | } 11 | } 12 | 13 | // Output: 14 | // hello 15 | // world 16 | -------------------------------------------------------------------------------- /_test/recurse1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type F func(a *A) 4 | 5 | type A struct { 6 | Name string 7 | F 8 | } 9 | 10 | func main() { 11 | a := &A{"Test", func(a *A) { println("in f", a.Name) }} 12 | a.F(a) 13 | } 14 | 15 | // Output: 16 | // in f Test 17 | -------------------------------------------------------------------------------- /_test/redeclaration-global1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var time int 4 | 5 | type time string 6 | 7 | func main() { 8 | var t time = "hello" 9 | println(t) 10 | } 11 | 12 | // TODO: expected redeclaration error. 13 | -------------------------------------------------------------------------------- /_test/redeclaration-global3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | var time string 8 | 9 | func main() { 10 | time = "hello" 11 | println(t) 12 | } 13 | 14 | // Error: 15 | // ../_test/redeclaration-global3.go:7:5: time redeclared in this block 16 | -------------------------------------------------------------------------------- /_test/redeclaration-global4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | type time string 8 | 9 | func main() { 10 | var t time = "hello" 11 | println(t) 12 | } 13 | 14 | // Error: 15 | // ../_test/redeclaration-global4.go:7:6: time redeclared in this block 16 | -------------------------------------------------------------------------------- /_test/redeclaration1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var foo string 5 | 6 | var foo int 7 | foo = 2 8 | println(foo) 9 | } 10 | 11 | // Error: 12 | // ../_test/redeclaration1.go:6:6: foo redeclared in this block 13 | -------------------------------------------------------------------------------- /_test/redeclaration3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var foo int 5 | foo = 2 6 | 7 | type foo struct{} 8 | var bar foo 9 | println(bar) 10 | } 11 | 12 | // Error: 13 | // ../_test/redeclaration3.go:7:7: foo redeclared in this block 14 | -------------------------------------------------------------------------------- /_test/redeclaration4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var foo struct{ 5 | yolo string 6 | } 7 | 8 | type foo struct{} 9 | var bar foo 10 | println(bar) 11 | } 12 | 13 | // Error: 14 | // ../_test/redeclaration4.go:8:7: foo redeclared in this block 15 | -------------------------------------------------------------------------------- /_test/redeclaration5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | type foo struct{ 5 | yolo string 6 | } 7 | 8 | type foo struct{} 9 | var bar foo 10 | println(bar) 11 | } 12 | 13 | // Error: 14 | // ../_test/redeclaration5.go:8:7: foo redeclared in this block 15 | -------------------------------------------------------------------------------- /_test/restricted2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | ) 7 | 8 | func main() { 9 | p, err := os.FindProcess(os.Getpid()) 10 | fmt.Println(p, err) 11 | } 12 | 13 | // Output: 14 | // restricted 15 | -------------------------------------------------------------------------------- /_test/ret1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func f(i int) (o int) { o = i + 1; return } 4 | 5 | func main() { println(f(4)) } 6 | 7 | // Output: 8 | // 5 9 | -------------------------------------------------------------------------------- /_test/ret2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func r2() (int, int) { return 1, 2 } 4 | 5 | func main() { 6 | a, b := r2() 7 | println(a, b) 8 | } 9 | 10 | // Output: 11 | // 1 2 12 | -------------------------------------------------------------------------------- /_test/ret3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func r2() (int, int) { return 1, 2 } 6 | 7 | func main() { 8 | fmt.Println(r2()) 9 | } 10 | 11 | // Output: 12 | // 1 2 13 | -------------------------------------------------------------------------------- /_test/ret4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func r() int { return 1 } 4 | 5 | func main() { 6 | a := r() 7 | println(a) 8 | } 9 | 10 | // Output: 11 | // 1 12 | -------------------------------------------------------------------------------- /_test/ret5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func r2() (int, int) { return 1, 2 } 4 | 5 | var a, b int = r2() 6 | 7 | func main() { println(a, b) } 8 | 9 | // Output: 10 | // 1 2 11 | -------------------------------------------------------------------------------- /_test/ret6.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type Foo struct{} 6 | 7 | func foo() *Foo { return nil } 8 | 9 | func main() { 10 | f := foo() 11 | fmt.Println(f) 12 | } 13 | 14 | // Output: 15 | // 16 | -------------------------------------------------------------------------------- /_test/ret7.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func one() uint { 4 | return 1 5 | } 6 | func main() { 7 | println(one()) 8 | } 9 | 10 | // Output: 11 | // 1 12 | -------------------------------------------------------------------------------- /_test/run0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func f() (int, int) { return 2, 3 } 6 | 7 | func main() { 8 | fmt.Println(f()) 9 | } 10 | 11 | // Output: 12 | // 2 3 13 | -------------------------------------------------------------------------------- /_test/run1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func f() (int, int) { return 2, 3 } 4 | 5 | func g(i, j int) int { return i + j } 6 | 7 | func main() { 8 | println(g(f())) 9 | } 10 | 11 | // Output: 12 | // 5 13 | -------------------------------------------------------------------------------- /_test/run10.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | func() { println("hello") }() 5 | } 6 | 7 | // Output: 8 | // hello 9 | -------------------------------------------------------------------------------- /_test/run11.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println(f()) 7 | } 8 | 9 | func f() (int, int) { return 2, 3 } 10 | 11 | // Output: 12 | // 2 3 13 | -------------------------------------------------------------------------------- /_test/run12.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func f(a int) (int, int) { 4 | return a + 1, a + 2 5 | } 6 | 7 | func main() { 8 | a, b := f(3) 9 | println(a, b) 10 | } 11 | 12 | // Output: 13 | // 4 5 14 | -------------------------------------------------------------------------------- /_test/run13.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a, b := f(3) 5 | println(a, b) 6 | } 7 | 8 | func f(a int) (int, int) { 9 | return a + 1, a + 2 10 | } 11 | 12 | // Output: 13 | // 4 5 14 | -------------------------------------------------------------------------------- /_test/run4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type fn func(int) 4 | 5 | func f1(i int) { println("f1", i) } 6 | 7 | func test(f fn, v int) { f(v) } 8 | 9 | func main() { test(f1, 21) } 10 | 11 | // Output: 12 | // f1 21 13 | -------------------------------------------------------------------------------- /_test/run5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type fn func(int) 4 | 5 | func test(f fn, v int) { f(v) } 6 | 7 | func main() { 8 | f1 := func(i int) { println("f1", i) } 9 | test(f1, 21) 10 | } 11 | 12 | // Output: 13 | // f1 21 14 | -------------------------------------------------------------------------------- /_test/run6.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type fn func(int) 4 | 5 | func test(f fn, v int) { f(v) } 6 | 7 | func main() { 8 | test(func(i int) { println("f1", i) }, 21) 9 | } 10 | 11 | // Output: 12 | // f1 21 13 | -------------------------------------------------------------------------------- /_test/run7.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type fn func(int) 4 | 5 | func test(f fn, v int) { f(v) } 6 | 7 | func main() { 8 | a := 3 9 | test(func(i int) { println("f1", i, a) }, 21) 10 | } 11 | 12 | // Output: 13 | // f1 21 3 14 | -------------------------------------------------------------------------------- /_test/run8.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 3 5 | f := func(i int) { println("f1", i, a) } 6 | f(21) 7 | } 8 | 9 | // Output: 10 | // f1 21 3 11 | -------------------------------------------------------------------------------- /_test/run9.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 3 5 | f := func(i int) int { println("f1", i, a); return i + 1 } 6 | b := f(21) 7 | println(b) 8 | } 9 | 10 | // Output: 11 | // f1 21 3 12 | // 22 13 | -------------------------------------------------------------------------------- /_test/rune1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | t := make([]byte, 2) 7 | t[0] = '$' 8 | fmt.Println(t) 9 | } 10 | 11 | // Output: 12 | // [36 0] 13 | -------------------------------------------------------------------------------- /_test/scope0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var a int = 1 4 | 5 | func main() { 6 | println(a) 7 | } 8 | 9 | // Output: 10 | // 1 11 | -------------------------------------------------------------------------------- /_test/scope1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func f(a int) int { 4 | return 2*a + 1 5 | } 6 | 7 | var b int = f(3) 8 | 9 | func main() { 10 | println(b) 11 | } 12 | 13 | // Output: 14 | // 7 15 | -------------------------------------------------------------------------------- /_test/scope2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var a int = 1 4 | 5 | func f() { println(a) } 6 | 7 | func main() { 8 | println(a) 9 | a := 2 10 | println(a) 11 | f() 12 | } 13 | 14 | // Output: 15 | // 1 16 | // 2 17 | // 1 18 | -------------------------------------------------------------------------------- /_test/scope3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 1 5 | if a := 2; a > 0 { 6 | println(a) 7 | } 8 | println(a) 9 | } 10 | 11 | // Output: 12 | // 2 13 | // 1 14 | -------------------------------------------------------------------------------- /_test/scope4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 1 5 | if a := 2; a > 0 { 6 | println(a) 7 | } 8 | { 9 | a := 3 10 | println(a) 11 | } 12 | println(a) 13 | } 14 | 15 | // Output: 16 | // 2 17 | // 3 18 | // 1 19 | -------------------------------------------------------------------------------- /_test/scope5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var a int = 1 4 | 5 | func f() { println(a) } 6 | 7 | func main() { 8 | println(a) 9 | a = 2 10 | println(a) 11 | f() 12 | } 13 | 14 | // Output: 15 | // 1 16 | // 2 17 | // 2 18 | -------------------------------------------------------------------------------- /_test/scope6.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | var a = [3]int{1, 2, 3} 6 | 7 | func f() { fmt.Println(a) } 8 | 9 | func main() { 10 | fmt.Println(a) 11 | a[1] = 5 12 | f() 13 | } 14 | 15 | // Output: 16 | // [1 2 3] 17 | // [1 5 3] 18 | -------------------------------------------------------------------------------- /_test/scope7.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | var a = []int{1, 2, 3} 6 | 7 | func f() { fmt.Println(a) } 8 | 9 | func main() { 10 | fmt.Println(a) 11 | a = []int{6, 7} 12 | f() 13 | } 14 | 15 | // Output: 16 | // [1 2 3] 17 | // [6 7] 18 | -------------------------------------------------------------------------------- /_test/select0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "time" 4 | 5 | func forever() { 6 | select {} // block forever 7 | println("end") 8 | } 9 | 10 | func main() { 11 | go forever() 12 | time.Sleep(1e4) 13 | println("bye") 14 | } 15 | 16 | // Output: 17 | // bye 18 | -------------------------------------------------------------------------------- /_test/select10.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | c := make(chan string) 5 | select { 6 | case <-c: 7 | println("unexpected") 8 | default: 9 | } 10 | println("bye") 11 | } 12 | 13 | // Output: 14 | // bye 15 | -------------------------------------------------------------------------------- /_test/select11.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | c := make(chan string) 5 | select { 6 | case <-c: 7 | println("unexpected") 8 | default: 9 | println("nothing received") 10 | } 11 | println("bye") 12 | } 13 | 14 | // Output: 15 | // nothing received 16 | // bye 17 | -------------------------------------------------------------------------------- /_test/select3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | select { 5 | default: 6 | println("no comm") 7 | } 8 | println("bye") 9 | } 10 | 11 | // Output: 12 | // no comm 13 | // bye 14 | -------------------------------------------------------------------------------- /_test/server4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | ) 6 | 7 | func main() { 8 | http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { 9 | w.Write([]byte("Welcome to my website!")) 10 | }) 11 | 12 | http.ListenAndServe(":8080", nil) 13 | } 14 | -------------------------------------------------------------------------------- /_test/server5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | ) 6 | 7 | var myHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 8 | w.Write([]byte("hello world")) 9 | }) 10 | 11 | func main() { 12 | http.ListenAndServe(":8080", myHandler) 13 | } 14 | -------------------------------------------------------------------------------- /_test/shift0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var rounds uint64 5 | var cost uint32 = 2 6 | rounds = 1 << cost 7 | println(rounds) 8 | } 9 | 10 | // Output: 11 | // 4 12 | -------------------------------------------------------------------------------- /_test/shift1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | const a1 = 0x7f8 >> 3 6 | 7 | func main() { 8 | fmt.Printf("%T %v\n", a1, a1) 9 | } 10 | 11 | // Output: 12 | // int 255 13 | -------------------------------------------------------------------------------- /_test/shift2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var u uint64 5 | var v uint32 6 | println(u << v) 7 | } 8 | 9 | // Output: 10 | // 0 11 | -------------------------------------------------------------------------------- /_test/shift3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const a = 1.0 4 | 5 | const b = a + 3 6 | 7 | func main() { println(b << (1)) } 8 | 9 | // Output: 10 | // 8 11 | -------------------------------------------------------------------------------- /_test/slice.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := [2][2]int{{0, 1}, {2, 3}} 7 | fmt.Println(a[0][0:]) 8 | } 9 | 10 | // Output: 11 | // [0 1] 12 | -------------------------------------------------------------------------------- /_test/str.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | println("hello world") 5 | } 6 | 7 | // Output: 8 | // hello world 9 | -------------------------------------------------------------------------------- /_test/str0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | const itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" 6 | 7 | func main() { 8 | fmt.Printf("%v %T\n", itoa64[2], itoa64[2]) 9 | } 10 | 11 | // Output: 12 | // 48 uint8 13 | -------------------------------------------------------------------------------- /_test/str1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" 4 | 5 | func main() { 6 | for i, r := range itoa64 { 7 | if r == '1' { 8 | println(i) 9 | } 10 | } 11 | } 12 | 13 | // Output: 14 | // 3 15 | -------------------------------------------------------------------------------- /_test/str2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | const itoa64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" 4 | 5 | func main() { 6 | if itoa64[3] == '1' { 7 | println("ok") 8 | } 9 | } 10 | 11 | // Output: 12 | // ok 13 | -------------------------------------------------------------------------------- /_test/str3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "strconv" 4 | 5 | func main() { 6 | str := strconv.Itoa(101) 7 | println(str[0] == '1') 8 | } 9 | 10 | // Output: 11 | // true 12 | -------------------------------------------------------------------------------- /_test/str4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "unicode/utf8" 4 | 5 | func main() { 6 | r, _ := utf8.DecodeRuneInString("Hello") 7 | println(r < utf8.RuneSelf) 8 | } 9 | 10 | // Output: 11 | // true 12 | -------------------------------------------------------------------------------- /_test/struct.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | f int 5 | g int 6 | } 7 | 8 | func main() { 9 | a := T{7, 8} 10 | println(a.f, a.g) 11 | } 12 | 13 | // Output: 14 | // 7 8 15 | -------------------------------------------------------------------------------- /_test/struct0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | f int 5 | g int 6 | } 7 | 8 | func main() { 9 | a := T{} 10 | println(a.f, a.g) 11 | } 12 | 13 | // Output: 14 | // 0 0 15 | -------------------------------------------------------------------------------- /_test/struct0a.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | f int 5 | } 6 | 7 | func main() { 8 | a := T{} 9 | println(a.f) 10 | a.f = 8 11 | println(a.f) 12 | } 13 | 14 | // Output: 15 | // 0 16 | // 8 17 | -------------------------------------------------------------------------------- /_test/struct1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | f int 5 | g struct { 6 | h int 7 | } 8 | } 9 | 10 | func main() { 11 | a := T{} 12 | a.g.h = 3 + 2 13 | println("a.g.h", a.g.h) 14 | } 15 | 16 | // Output: 17 | // a.g.h 5 18 | -------------------------------------------------------------------------------- /_test/struct10.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | f int 5 | g int64 6 | } 7 | 8 | func main() { 9 | a := T{g: 8} 10 | println(a.f, a.g) 11 | } 12 | 13 | // Output: 14 | // 0 8 15 | -------------------------------------------------------------------------------- /_test/struct12.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type S1 struct { 6 | Name string 7 | } 8 | 9 | type S2 struct { 10 | *S1 11 | } 12 | 13 | func main() { 14 | fmt.Println(S2{}) 15 | } 16 | 17 | // Output: 18 | // {} 19 | -------------------------------------------------------------------------------- /_test/struct13.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | ) 7 | 8 | type Fromage struct { 9 | http.Server 10 | } 11 | 12 | func main() { 13 | a := Fromage{} 14 | fmt.Println(a.Server.WriteTimeout) 15 | } 16 | 17 | // Output: 18 | // 0s 19 | -------------------------------------------------------------------------------- /_test/struct14.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | ) 7 | 8 | type Fromage struct { 9 | *http.Server 10 | } 11 | 12 | func main() { 13 | a := Fromage{} 14 | fmt.Println(a.Server) 15 | } 16 | 17 | // Output: 18 | // 19 | -------------------------------------------------------------------------------- /_test/struct16.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type S1 struct { 4 | Name string 5 | } 6 | 7 | type S2 struct { 8 | *S1 9 | } 10 | 11 | func main() { 12 | s1 := S1{"foo"} 13 | s2 := S2{&s1} 14 | println(s2.Name) 15 | } 16 | 17 | // Output: 18 | // foo 19 | -------------------------------------------------------------------------------- /_test/struct17.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type S1 struct { 4 | Name string 5 | } 6 | 7 | type S2 struct { 8 | *S1 9 | } 10 | 11 | func main() { 12 | s1 := &S1{"foo"} 13 | s2 := S2{s1} 14 | println(s2.Name) 15 | } 16 | 17 | // Output: 18 | // foo 19 | -------------------------------------------------------------------------------- /_test/struct2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | f int 5 | g int 6 | } 7 | 8 | func main() { 9 | a := T{g: 8, f: 7} 10 | println(a.f, a.g) 11 | } 12 | 13 | // Output: 14 | // 7 8 15 | -------------------------------------------------------------------------------- /_test/struct22.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type S struct { 4 | Child *S 5 | Name string 6 | } 7 | 8 | func main() { 9 | s := &S{Name: "root"} 10 | s.Child = &S{Name: "child"} 11 | println(s.Child.Name) 12 | } 13 | 14 | // Output: 15 | // child 16 | -------------------------------------------------------------------------------- /_test/struct24.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var a = &T{} 4 | 5 | type T struct{} 6 | 7 | func main() { 8 | println(a != nil) 9 | } 10 | 11 | // Output: 12 | // true 13 | -------------------------------------------------------------------------------- /_test/struct25.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | var a = T{} 6 | 7 | type T struct{} 8 | 9 | func main() { 10 | fmt.Println(a) 11 | } 12 | 13 | // Output: 14 | // {} 15 | -------------------------------------------------------------------------------- /_test/struct26.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func newT2() *T2 { return &T2{} } 6 | 7 | type T2 struct { 8 | T1 9 | } 10 | 11 | type T1 struct { 12 | bs []byte 13 | } 14 | 15 | func main() { 16 | fmt.Println(newT2()) 17 | } 18 | 19 | // Output: 20 | // &{{[]}} 21 | -------------------------------------------------------------------------------- /_test/struct28.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type T1 struct { 6 | T2 7 | } 8 | 9 | type T2 struct { 10 | *T1 11 | } 12 | 13 | func main() { 14 | t := T1{} 15 | fmt.Println(t) 16 | } 17 | 18 | // Output: 19 | // {{}} 20 | -------------------------------------------------------------------------------- /_test/struct29.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T1 struct { 4 | A []T2 5 | B []T2 6 | } 7 | 8 | type T2 struct { 9 | name string 10 | } 11 | 12 | var t = T1{} 13 | 14 | func main() { 15 | println("ok") 16 | } 17 | 18 | // Output: 19 | // ok 20 | -------------------------------------------------------------------------------- /_test/struct3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | f int 5 | g int 6 | h struct { 7 | k int 8 | } 9 | } 10 | 11 | func f(i int) int { return i + 3 } 12 | 13 | func main() { 14 | a := T{} 15 | a.h.k = f(4) 16 | println(a.h.k) 17 | } 18 | 19 | // Output: 20 | // 7 21 | -------------------------------------------------------------------------------- /_test/struct30.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T1 struct { 4 | A []T2 5 | M map[uint64]T2 6 | } 7 | 8 | type T2 struct { 9 | name string 10 | } 11 | 12 | var t = T1{} 13 | 14 | func main() { 15 | println("ok") 16 | } 17 | 18 | // Output: 19 | // ok 20 | -------------------------------------------------------------------------------- /_test/struct31.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | bool 5 | } 6 | 7 | var t = T{true} 8 | 9 | func main() { 10 | println(t.bool && true) 11 | } 12 | 13 | // Output: 14 | // true 15 | -------------------------------------------------------------------------------- /_test/struct34.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | f func(*T) 5 | } 6 | 7 | func f1(t *T) { t.f = f2 } 8 | 9 | func f2(t *T) { t.f = f1 } 10 | 11 | func main() { 12 | println("ok") 13 | } 14 | 15 | // Output: 16 | // ok 17 | -------------------------------------------------------------------------------- /_test/struct35.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | f func(*T) 5 | } 6 | 7 | func f1(t *T) { t.f = f1 } 8 | 9 | func main() { 10 | t := &T{} 11 | f1(t) 12 | println(t.f != nil) 13 | } 14 | 15 | // Output: 16 | // true 17 | -------------------------------------------------------------------------------- /_test/struct39.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | t *T1 5 | y *xxx 6 | } 7 | 8 | type T1 struct { 9 | T 10 | } 11 | 12 | var x = &T1{} 13 | var t = &T{} 14 | 15 | type xxx struct{} 16 | 17 | func main() { 18 | println("ok") 19 | } 20 | 21 | // Output: 22 | // ok 23 | -------------------------------------------------------------------------------- /_test/struct42.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | t func(*T) 5 | y *xxx 6 | } 7 | 8 | func f(t *T) { println("in f") } 9 | 10 | var x = &T{t: f} 11 | 12 | type xxx struct{} 13 | 14 | func main() { 15 | println("ok") 16 | } 17 | 18 | // Output: 19 | // ok 20 | -------------------------------------------------------------------------------- /_test/struct43.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | t func(*T) 5 | y *xxx 6 | } 7 | 8 | func f(t *T) { println("in f") } 9 | 10 | type xxx struct{} 11 | 12 | func main() { 13 | x := &T{} 14 | x.t = f 15 | println("ok") 16 | } 17 | 18 | // Output: 19 | // ok 20 | -------------------------------------------------------------------------------- /_test/struct45.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | b bool 5 | } 6 | 7 | type T1 struct { 8 | T 9 | } 10 | 11 | func main() { 12 | t := &T1{} 13 | t.b = true 14 | println(t.b) 15 | } 16 | 17 | // Output: 18 | // true 19 | -------------------------------------------------------------------------------- /_test/struct5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | f int 5 | g int 6 | } 7 | 8 | func f(i int) int { return i * i } 9 | 10 | func main() { 11 | a := T{7, f(4)} 12 | println(a.f, a.g) 13 | } 14 | 15 | // Output: 16 | // 7 16 17 | -------------------------------------------------------------------------------- /_test/struct6.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | f, g int 5 | } 6 | 7 | func main() { 8 | a := T{7, 8} 9 | println(a.f, a.g) 10 | } 11 | 12 | // Output: 13 | // 7 8 14 | -------------------------------------------------------------------------------- /_test/struct60.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type data struct { 8 | S string 9 | } 10 | 11 | func render(v interface{}) { 12 | fmt.Println(v) 13 | } 14 | 15 | func main() { 16 | render(data{}) 17 | } 18 | 19 | // Output: 20 | // {} 21 | -------------------------------------------------------------------------------- /_test/struct62.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | type A struct{ *A } 5 | v := &A{} 6 | v.A = v 7 | println("v.A.A = v", v.A.A == v) 8 | } 9 | 10 | // Output: 11 | // v.A.A = v true 12 | -------------------------------------------------------------------------------- /_test/struct7.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Opt struct { 4 | b bool 5 | } 6 | 7 | type T struct { 8 | i int 9 | opt Opt 10 | } 11 | 12 | func main() { 13 | a := T{} 14 | println(a.i, a.opt.b) 15 | } 16 | 17 | // Output: 18 | // 0 false 19 | -------------------------------------------------------------------------------- /_test/struct9.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | f int 5 | g int64 6 | } 7 | 8 | func main() { 9 | a := T{7, 8} 10 | println(a.f, a.g) 11 | } 12 | 13 | // Output: 14 | // 7 8 15 | -------------------------------------------------------------------------------- /_test/switch.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 3 5 | switch a { 6 | case 0: 7 | println(200) 8 | default: 9 | println(a) 10 | case 3: 11 | println(100) 12 | } 13 | } 14 | 15 | // Output: 16 | // 100 17 | -------------------------------------------------------------------------------- /_test/switch1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | i := 1 5 | 6 | switch i { 7 | case 0: 8 | println(i) 9 | default: 10 | println("not nul") 11 | } 12 | } 13 | 14 | // Output: 15 | // not nul 16 | -------------------------------------------------------------------------------- /_test/switch10.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var i interface{} = "truc" 5 | 6 | switch a := i.(type) { 7 | case string: 8 | println("string", a+" ok") 9 | default: 10 | println("unknown") 11 | } 12 | } 13 | 14 | // Output: 15 | // string truc ok 16 | -------------------------------------------------------------------------------- /_test/switch11.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var i interface{} = "truc" 5 | 6 | switch b := 2; a := i.(type) { 7 | case string: 8 | println("string", a+" ok") 9 | default: 10 | println("unknown", b) 11 | } 12 | } 13 | 14 | // Output: 15 | // string truc ok 16 | -------------------------------------------------------------------------------- /_test/switch2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | i := 1 5 | 6 | switch i { 7 | case 0, 1, 2: 8 | println(i) 9 | default: 10 | println("not nul") 11 | } 12 | } 13 | 14 | // Output: 15 | // 1 16 | -------------------------------------------------------------------------------- /_test/switch20.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | i := 1 5 | 6 | switch i { 7 | case 1: 8 | // nothing to do 9 | default: 10 | println("not run") 11 | } 12 | println("bye") 13 | } 14 | 15 | // Output: 16 | // bye 17 | -------------------------------------------------------------------------------- /_test/switch21.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var err error 7 | 8 | switch v := err.(type) { 9 | case fmt.Formatter: 10 | println("formatter") 11 | default: 12 | fmt.Println(v) 13 | } 14 | } 15 | 16 | // Output: 17 | // 18 | -------------------------------------------------------------------------------- /_test/switch23.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func getType() string { return "T1" } 4 | 5 | func main() { 6 | switch getType() { 7 | case "T1": 8 | println("T1") 9 | default: 10 | println("default") 11 | } 12 | } 13 | 14 | // Output: 15 | // T1 16 | -------------------------------------------------------------------------------- /_test/switch24.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 3 5 | switch a + 2 { 6 | case 5: 7 | println(5) 8 | default: 9 | println("default") 10 | } 11 | println("bye") 12 | } 13 | 14 | // Output: 15 | // 5 16 | // bye 17 | -------------------------------------------------------------------------------- /_test/switch25.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 2 5 | switch { 6 | case a == 1: 7 | println(1) 8 | case a == 2: 9 | println(2) 10 | default: 11 | println("default") 12 | } 13 | println("bye") 14 | } 15 | 16 | // Output: 17 | // 2 18 | // bye 19 | -------------------------------------------------------------------------------- /_test/switch26.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 1 5 | switch a := 2; { 6 | case a == 1: 7 | println(1) 8 | case a == 2: 9 | println(2) 10 | default: 11 | println("default") 12 | } 13 | println(a) 14 | } 15 | 16 | // Output: 17 | // 2 18 | // 1 19 | -------------------------------------------------------------------------------- /_test/switch27.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | //a := false 5 | switch false { 6 | case true: 7 | println("true") 8 | case false: 9 | println("false") 10 | } 11 | println("bye") 12 | } 13 | 14 | // Output: 15 | // false 16 | // bye 17 | -------------------------------------------------------------------------------- /_test/switch28.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | switch { 5 | case true: 6 | println("true") 7 | case false: 8 | println("false") 9 | } 10 | println("bye") 11 | } 12 | 13 | // Output: 14 | // true 15 | // bye 16 | -------------------------------------------------------------------------------- /_test/switch29.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 3 5 | switch a { 6 | case 3: 7 | println("three") 8 | } 9 | println("bye") 10 | } 11 | 12 | // Output: 13 | // three 14 | // bye 15 | -------------------------------------------------------------------------------- /_test/switch3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 3 5 | switch a { 6 | case 0: 7 | println(200) 8 | case 3: 9 | println(100) 10 | fallthrough 11 | default: 12 | println(a) 13 | } 14 | } 15 | 16 | // Output: 17 | // 100 18 | // 3 19 | -------------------------------------------------------------------------------- /_test/switch30.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 3 5 | switch a { 6 | default: 7 | //println("default") 8 | case 3: 9 | println("three") 10 | } 11 | println("bye") 12 | } 13 | 14 | // Output: 15 | // three 16 | // bye 17 | -------------------------------------------------------------------------------- /_test/switch31.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | switch { 5 | } 6 | println("bye") 7 | } 8 | 9 | // Output: 10 | // bye 11 | -------------------------------------------------------------------------------- /_test/switch32.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 1 5 | switch a { 6 | } 7 | println("bye", a) 8 | } 9 | 10 | // Output: 11 | // bye 1 12 | -------------------------------------------------------------------------------- /_test/switch33.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a interface{} 5 | switch a.(type) { 6 | } 7 | println("bye") 8 | } 9 | 10 | // Output: 11 | // bye 12 | -------------------------------------------------------------------------------- /_test/switch35.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 2 5 | switch { 6 | case a == 1: 7 | println(1) 8 | case a == 2: 9 | println(2) 10 | default: 11 | } 12 | println("bye") 13 | } 14 | 15 | // Output: 16 | // 2 17 | // bye 18 | -------------------------------------------------------------------------------- /_test/switch36.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 2 5 | switch { 6 | case a == 1: 7 | println(1) 8 | case a == 2: 9 | } 10 | println("bye") 11 | } 12 | 13 | // Output: 14 | // bye 15 | -------------------------------------------------------------------------------- /_test/switch37.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 2 5 | switch { 6 | case a == 1: 7 | println(1) 8 | case a == 3: 9 | default: 10 | } 11 | println("bye") 12 | } 13 | 14 | // Output: 15 | // bye 16 | -------------------------------------------------------------------------------- /_test/switch4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 3 5 | switch b := "foo"; a { 6 | case 0: 7 | println(200) 8 | case 3: 9 | println(100) 10 | fallthrough 11 | default: 12 | println(a, b) 13 | } 14 | } 15 | 16 | // Output: 17 | // 100 18 | // 3 foo 19 | -------------------------------------------------------------------------------- /_test/switch5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | i := 1 5 | 6 | switch i { 7 | case 0, 1, 2: 8 | if i == 1 { 9 | println("one") 10 | break 11 | } 12 | println(i) 13 | default: 14 | println("not nul") 15 | } 16 | } 17 | 18 | // Output: 19 | // one 20 | -------------------------------------------------------------------------------- /_test/switch6.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | a := 3 5 | switch b := "foo"; { 6 | case a == 0: 7 | println(200) 8 | case a == 3: 9 | println(100) 10 | fallthrough 11 | default: 12 | println(a, b) 13 | } 14 | } 15 | 16 | // Output: 17 | // 100 18 | // 3 foo 19 | -------------------------------------------------------------------------------- /_test/switch7.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var i interface{} = "truc" 5 | 6 | switch i.(type) { 7 | case string: 8 | println("string") 9 | default: 10 | println("unknown") 11 | } 12 | } 13 | 14 | // Output: 15 | // string 16 | -------------------------------------------------------------------------------- /_test/switch8.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | println("hello") 5 | fallthrough 6 | println("world") 7 | } 8 | 9 | // Error: 10 | // 5:2: fallthrough statement out of place 11 | -------------------------------------------------------------------------------- /_test/testdata/redeclaration-global7/src/guthib.com/bar/quux.go: -------------------------------------------------------------------------------- 1 | package quux 2 | 3 | func Quux() string { 4 | return "bar" 5 | } 6 | -------------------------------------------------------------------------------- /_test/testdata/redeclaration-global7/src/guthib.com/baz/quux.go: -------------------------------------------------------------------------------- 1 | package quux 2 | 3 | func Quux() string { 4 | return "baz" 5 | } 6 | -------------------------------------------------------------------------------- /_test/testdata/redeclaration-global7/src/guthib.com/tata/tutu.go: -------------------------------------------------------------------------------- 1 | package tutu 2 | 3 | import "guthib.com/baz" 4 | 5 | func Quux() string { 6 | return quux.Quux() 7 | } 8 | -------------------------------------------------------------------------------- /_test/testdata/redeclaration-global7/src/guthib.com/toto/titi.go: -------------------------------------------------------------------------------- 1 | package titi 2 | 3 | import "guthib.com/bar" 4 | 5 | func Quux() string { 6 | return quux.Quux() 7 | } 8 | -------------------------------------------------------------------------------- /_test/time0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | fmt.Println(time.Now()) 10 | } 11 | -------------------------------------------------------------------------------- /_test/time1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | t := time.Date(2009, time.November, 10, 23, 4, 5, 0, time.UTC) 10 | m := t.Minute() 11 | fmt.Println(t, m) 12 | } 13 | 14 | // Output: 15 | // 2009-11-10 23:04:05 +0000 UTC 4 16 | -------------------------------------------------------------------------------- /_test/time10.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "time" 4 | 5 | var UnixTime func(int64, int64) time.Time 6 | 7 | func main() { 8 | UnixTime = time.Unix 9 | println(UnixTime(1e9, 0).In(time.UTC).Minute()) 10 | } 11 | 12 | // Output: 13 | // 46 14 | -------------------------------------------------------------------------------- /_test/time11.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | const df = time.Minute * 30 9 | 10 | func main() { 11 | fmt.Printf("df: %v %T\n", df, df) 12 | } 13 | 14 | // Output: 15 | // df: 30m0s time.Duration 16 | -------------------------------------------------------------------------------- /_test/time12.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | var twentyFourHours = time.Duration(24 * time.Hour) 9 | 10 | func main() { 11 | fmt.Println(twentyFourHours.Hours()) 12 | } 13 | 14 | // Output: 15 | // 24 16 | -------------------------------------------------------------------------------- /_test/time14.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | var t time.Time 9 | 10 | func f() time.Time { 11 | time := t 12 | return time 13 | } 14 | 15 | func main() { 16 | fmt.Println(f()) 17 | } 18 | 19 | // Output: 20 | // 0001-01-01 00:00:00 +0000 UTC 21 | -------------------------------------------------------------------------------- /_test/time15.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "time" 4 | 5 | type TimeValue time.Time 6 | 7 | func (v *TimeValue) decode() { println("in decode") } 8 | 9 | func main() { 10 | var tv TimeValue 11 | tv.decode() 12 | } 13 | 14 | // Output: 15 | // in decode 16 | -------------------------------------------------------------------------------- /_test/time16.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "time" 4 | 5 | func main() { 6 | localTime := time.ANSIC 7 | println(localTime) 8 | } 9 | 10 | // Output: 11 | // Mon Jan _2 15:04:05 2006 12 | -------------------------------------------------------------------------------- /_test/time2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | t := time.Date(2009, time.November, 10, 23, 4, 5, 0, time.UTC) 10 | h, m, s := t.Clock() 11 | fmt.Println(h, m, s) 12 | } 13 | 14 | // Output: 15 | // 23 4 5 16 | -------------------------------------------------------------------------------- /_test/time3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | // FIXME related to named returns 9 | func main() { 10 | t := time.Date(2009, time.November, 10, 23, 4, 5, 0, time.UTC) 11 | fmt.Println(t.Clock()) 12 | } 13 | 14 | // Output: 15 | // 23 4 5 16 | -------------------------------------------------------------------------------- /_test/time4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | var m time.Month 10 | m = 9 11 | fmt.Println(m) 12 | } 13 | 14 | // Output: 15 | // September 16 | -------------------------------------------------------------------------------- /_test/time5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | t := time.Unix(1e9, 0).In(time.UTC) 10 | fmt.Println(t.Minute()) 11 | } 12 | 13 | // Output: 14 | // 46 15 | -------------------------------------------------------------------------------- /_test/time6.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | t := &time.Time{} 10 | t.UnmarshalText([]byte("1985-04-12T23:20:50.52Z")) 11 | 12 | fmt.Println(t) 13 | } 14 | 15 | // Output: 16 | // 1985-04-12 23:20:50.52 +0000 UTC 17 | -------------------------------------------------------------------------------- /_test/time7.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | var d = 2 * time.Second 9 | 10 | func main() { fmt.Println(d) } 11 | 12 | // Output: 13 | // 2s 14 | -------------------------------------------------------------------------------- /_test/time9.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | fmt.Println((5 * time.Minute).Seconds()) 10 | } 11 | 12 | // Output: 13 | // 300 14 | -------------------------------------------------------------------------------- /_test/type0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type newInt int 4 | 5 | func main() { 6 | var a newInt 7 | println(a) 8 | } 9 | 10 | // Output: 11 | // 0 12 | -------------------------------------------------------------------------------- /_test/type1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var i interface{} = "hello" 7 | s := i.(string) 8 | fmt.Println(s) 9 | } 10 | 11 | // Output: 12 | // hello 13 | -------------------------------------------------------------------------------- /_test/type13.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var a = &T{} 4 | 5 | type T struct{} 6 | 7 | func main() { 8 | println(a != nil) 9 | } 10 | 11 | // Output: 12 | // true 13 | -------------------------------------------------------------------------------- /_test/type14.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | var a = T{} 6 | 7 | type T struct{} 8 | 9 | func main() { 10 | fmt.Println(a) 11 | } 12 | 13 | // Output: 14 | // {} 15 | -------------------------------------------------------------------------------- /_test/type15.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | err := error(nil) 5 | println(err == nil) 6 | } 7 | 8 | // Output: 9 | // true 10 | -------------------------------------------------------------------------------- /_test/type16.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := uint8(15) ^ byte(0) 7 | fmt.Printf("%T %v\n", a, a) 8 | } 9 | 10 | // Output: 11 | // uint8 15 12 | -------------------------------------------------------------------------------- /_test/type17.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | a := int32(15) ^ rune(0) 7 | fmt.Printf("%T %v\n", a, a) 8 | } 9 | 10 | // Output: 11 | // int32 15 12 | -------------------------------------------------------------------------------- /_test/type18.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T struct { 4 | name string 5 | size int 6 | } 7 | 8 | var table = []*T{{ 9 | name: "foo", 10 | size: 2, 11 | }} 12 | 13 | var s = table[0].size 14 | 15 | func main() { 16 | println(s) 17 | } 18 | 19 | // Output: 20 | // 2 21 | -------------------------------------------------------------------------------- /_test/type22.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type T1 T 4 | 5 | func foo() T1 { 6 | return T1(T{"foo"}) 7 | } 8 | 9 | type T struct { 10 | Name string 11 | } 12 | 13 | func main() { 14 | println(foo().Name) 15 | } 16 | 17 | // Output: 18 | // foo 19 | -------------------------------------------------------------------------------- /_test/type29.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var Foo int 4 | 5 | func (f Foo) Bar() int { 6 | return 1 7 | } 8 | 9 | func main() {} 10 | 11 | // Error: 12 | // 5:1: cannot define new methods on non-local type int 13 | -------------------------------------------------------------------------------- /_test/type3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type S1 string 6 | 7 | func main() { 8 | s := S1("Hello") 9 | fmt.Println(s) 10 | } 11 | 12 | // Output: 13 | // Hello 14 | -------------------------------------------------------------------------------- /_test/type30.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var Foo *int 4 | 5 | func (f Foo) Bar() int { 6 | return 1 7 | } 8 | 9 | func main() {} 10 | 11 | // Error: 12 | // 5:1: cannot define new methods on non-local type int 13 | -------------------------------------------------------------------------------- /_test/type33.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func (f *Foo) Bar() int { 4 | return *f * *f 5 | } 6 | 7 | func main() { 8 | } 9 | 10 | // Error: 11 | // 3:1: undefined: Foo 12 | -------------------------------------------------------------------------------- /_test/type34.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type original struct { 4 | Field string 5 | } 6 | 7 | func main() { 8 | type alias original 9 | type alias2 alias 10 | var a = &alias2{ 11 | Field: "test", 12 | } 13 | println(a.Field) 14 | } 15 | 16 | // Output: 17 | // test 18 | -------------------------------------------------------------------------------- /_test/type4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | ) 7 | 8 | func main() { 9 | a := int32(12) 10 | fmt.Println(reflect.TypeOf(a)) 11 | } 12 | 13 | // Output: 14 | // int32 15 | -------------------------------------------------------------------------------- /_test/type5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | ) 7 | 8 | type T int 9 | 10 | func main() { 11 | a := T(12) 12 | fmt.Println(reflect.TypeOf(a)) 13 | } 14 | 15 | // Output: 16 | // int 17 | -------------------------------------------------------------------------------- /_test/type6.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | ) 7 | 8 | func main() { 9 | a := T(12) 10 | fmt.Println(reflect.TypeOf(a)) 11 | } 12 | 13 | type T int 14 | 15 | // Output: 16 | // int 17 | -------------------------------------------------------------------------------- /_test/type7.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var i interface{} = "hello" 7 | if s, ok := i.(string); ok { 8 | fmt.Println(s, ok) 9 | } 10 | } 11 | 12 | // Output: 13 | // hello true 14 | -------------------------------------------------------------------------------- /_test/type8.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | v := (*time.Time)(nil) 10 | fmt.Println(v) 11 | } 12 | 13 | // Output: 14 | // 15 | -------------------------------------------------------------------------------- /_test/type9.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type Hello struct { 6 | Goodbye GoodbyeProvider 7 | } 8 | 9 | func main() { 10 | a := &Hello{} 11 | 12 | fmt.Println(a) 13 | } 14 | 15 | type GoodbyeProvider func(message string) string 16 | 17 | // Output: 18 | // &{} 19 | -------------------------------------------------------------------------------- /_test/unsafe0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "unsafe" 4 | 5 | func main() { 6 | str := "foobar" 7 | 8 | p := unsafe.Pointer(&str) 9 | str2 := *(*string)(p) 10 | 11 | println(str2) 12 | } 13 | 14 | // Output: 15 | // foobar 16 | -------------------------------------------------------------------------------- /_test/unsafe1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "unsafe" 4 | 5 | type S struct { 6 | Name string 7 | } 8 | 9 | func main() { 10 | s := &S{Name: "foobar"} 11 | 12 | p := unsafe.Pointer(s) 13 | 14 | s2 := (*S)(p) 15 | 16 | println(s2.Name) 17 | } 18 | 19 | // Output: 20 | // foobar 21 | -------------------------------------------------------------------------------- /_test/unsafe10.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "unsafe" 4 | 5 | type T struct { 6 | X uint64 7 | Y uint64 8 | } 9 | 10 | func f(off uintptr) { println(off) } 11 | 12 | func main() { 13 | f(unsafe.Offsetof(T{}.Y)) 14 | } 15 | 16 | // Output: 17 | // 8 18 | -------------------------------------------------------------------------------- /_test/unsafe7.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "unsafe" 6 | ) 7 | 8 | type S struct { 9 | X int 10 | Y int 11 | Z int 12 | } 13 | 14 | func main() { 15 | x := [2]S{{Z: 5}, {Z: 10}} 16 | 17 | s := unsafe.Slice(&x[0], 2) 18 | 19 | fmt.Println(s) 20 | } 21 | -------------------------------------------------------------------------------- /_test/unsafe8.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "unsafe" 4 | 5 | type T struct { 6 | i uint64 7 | } 8 | 9 | var d T 10 | 11 | var b [unsafe.Sizeof(d)]byte 12 | 13 | func main() { 14 | println(len(b)) 15 | } 16 | 17 | // Output: 18 | // 8 19 | -------------------------------------------------------------------------------- /_test/var.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a, b, c int 5 | println(a, b, c) 6 | } 7 | 8 | // Output: 9 | // 0 0 0 10 | -------------------------------------------------------------------------------- /_test/var10.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var _ = true 4 | var _ = "hello" 5 | 6 | func main() { 7 | println("hello") 8 | } 9 | 10 | // Output: 11 | // hello 12 | -------------------------------------------------------------------------------- /_test/var11.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var a, _, _, b = 1, true, "foo", 2 4 | 5 | func main() { 6 | println(a, b) 7 | } 8 | 9 | // Output: 10 | // 1 2 11 | -------------------------------------------------------------------------------- /_test/var12.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var ( 4 | a = b 5 | b = "hello" 6 | ) 7 | 8 | func main() { 9 | println(a) 10 | } 11 | 12 | // Output: 13 | // hello 14 | -------------------------------------------------------------------------------- /_test/var14.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/traefik/yaegi/_test/vars" 4 | 5 | func main() { 6 | println(vars.A) 7 | } 8 | 9 | // Output: 10 | // hello world! 11 | -------------------------------------------------------------------------------- /_test/var15.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var a int = 2 4 | 5 | func inca() { 6 | a = a + 1 7 | } 8 | 9 | func main() { 10 | inca() 11 | println(a) 12 | } 13 | 14 | // Output: 15 | // 3 16 | -------------------------------------------------------------------------------- /_test/var2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a int = 2 5 | println(a) 6 | } 7 | 8 | // Output: 9 | // 2 10 | -------------------------------------------------------------------------------- /_test/var3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a, b int = 2, 3 5 | println(a, b) 6 | } 7 | 8 | // Output: 9 | // 2 3 10 | -------------------------------------------------------------------------------- /_test/var4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a, b = 2, 3 5 | println(a, b) 6 | } 7 | 8 | // Output: 9 | // 2 3 10 | -------------------------------------------------------------------------------- /_test/var5.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var a int64 = 64 7 | fmt.Printf("a: %v %T", a, a) 8 | fmt.Println() 9 | } 10 | 11 | // Output: 12 | // a: 64 int64 13 | -------------------------------------------------------------------------------- /_test/var7.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type T struct { 8 | Name string 9 | } 10 | 11 | var m = make(map[string]*T) 12 | 13 | func main() { 14 | fmt.Println(m) 15 | } 16 | 17 | // Output: 18 | // map[] 19 | -------------------------------------------------------------------------------- /_test/var9.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var a = "sdofjsdfj" 4 | var z = a[0:2] 5 | 6 | func main() { 7 | println(z) 8 | } 9 | 10 | // Output: 11 | // sd 12 | -------------------------------------------------------------------------------- /_test/variadic.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func f(a ...int) { 6 | fmt.Println(a) 7 | } 8 | 9 | func main() { 10 | f(1, 2, 3, 4) 11 | } 12 | 13 | // Output: 14 | // [1 2 3 4] 15 | -------------------------------------------------------------------------------- /_test/variadic0.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func f(s string, a ...int) { 6 | fmt.Println(s, a) 7 | } 8 | 9 | func main() { 10 | f("hello") 11 | } 12 | 13 | // Output: 14 | // hello [] 15 | -------------------------------------------------------------------------------- /_test/variadic1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func f(s string, a ...int32) { 6 | fmt.Println(s, a) 7 | } 8 | 9 | func main() { 10 | f("hello", 1, 2, 3) 11 | } 12 | 13 | // Output: 14 | // hello [1 2 3] 15 | -------------------------------------------------------------------------------- /_test/variadic2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func f(a ...int) { 6 | if len(a) > 2 { 7 | fmt.Println(a[2]) 8 | } 9 | } 10 | 11 | func main() { 12 | f(1, 2, 3, 4) 13 | } 14 | 15 | // Output: 16 | // 3 17 | -------------------------------------------------------------------------------- /_test/variadic4.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func variadic(s ...string) {} 4 | 5 | func f(s string) { println(s + "bar") } 6 | 7 | func main() { f("foo") } 8 | 9 | // Output: 10 | // foobar 11 | -------------------------------------------------------------------------------- /_test/variadic8.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | fn1 := func(args ...*time.Duration) string { 10 | return "" 11 | } 12 | 13 | fmt.Printf("%T\n", fn1) 14 | } 15 | 16 | // Output: 17 | // func(...*time.Duration) string 18 | -------------------------------------------------------------------------------- /_test/variadic9.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func Sprintf(format string, a ...interface{}) string { 6 | return fmt.Sprintf(format, a...) 7 | } 8 | 9 | func main() { 10 | fmt.Println(Sprintf("Hello %s", "World!")) 11 | } 12 | 13 | // Output: 14 | // Hello World! 15 | -------------------------------------------------------------------------------- /_test/vars/first.go: -------------------------------------------------------------------------------- 1 | package vars 2 | 3 | var ( 4 | A = concat("hello", B) 5 | C = D 6 | ) 7 | 8 | func concat(a ...string) string { 9 | var s string 10 | for _, ss := range a { 11 | s += ss 12 | } 13 | return s 14 | } 15 | -------------------------------------------------------------------------------- /_test/vars/second.go: -------------------------------------------------------------------------------- 1 | package vars 2 | 3 | var ( 4 | B = concat(" ", C, "!") 5 | D = "world" 6 | ) 7 | -------------------------------------------------------------------------------- /doc/images/yaegi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/traefik/yaegi/d93266d013f393a20122ef0dd3f579d411a066be/doc/images/yaegi.png -------------------------------------------------------------------------------- /example/getfunc/_gopath/src/github.com/foo/bar/foobar.go: -------------------------------------------------------------------------------- 1 | package bar 2 | 3 | type Foo struct { 4 | A string 5 | } 6 | 7 | func NewFoo() *Foo { 8 | return &Foo{A: "test"} 9 | } 10 | -------------------------------------------------------------------------------- /example/pkg/_pkg/src/github.com/foo/pkg/vendor/guthib.com/traefik/fromage/fromage.go: -------------------------------------------------------------------------------- 1 | package fromage 2 | 3 | import "fmt" 4 | 5 | func Hello() string { 6 | return fmt.Sprint("Fromage") 7 | } 8 | -------------------------------------------------------------------------------- /example/pkg/_pkg0/src/github.com/foo/pkg/fromage/cheese/cheese.go: -------------------------------------------------------------------------------- 1 | package cheese 2 | 3 | import "fmt" 4 | 5 | func Hello() string { 6 | return fmt.Sprint("Cheese") 7 | } 8 | -------------------------------------------------------------------------------- /example/pkg/_pkg0/src/github.com/foo/pkg/fromage/fromage.go: -------------------------------------------------------------------------------- 1 | package fromage 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/foo/pkg/fromage/cheese" 7 | ) 8 | 9 | func Hello() string { 10 | return fmt.Sprintf("Fromage %s", cheese.Hello()) 11 | } 12 | -------------------------------------------------------------------------------- /example/pkg/_pkg1/src/github.com/foo/pkg/fromage/fromage.go: -------------------------------------------------------------------------------- 1 | package fromage 2 | 3 | import "fmt" 4 | 5 | func Hello() string { 6 | return fmt.Sprint("Fromage!") 7 | } 8 | -------------------------------------------------------------------------------- /example/pkg/_pkg10/src/github.com/foo/vendor/guthib.com/traefik/fromage/fromage.go: -------------------------------------------------------------------------------- 1 | package fromage 2 | 3 | import "fmt" 4 | 5 | func Hello() string { 6 | return fmt.Sprint("Fromage") 7 | } 8 | -------------------------------------------------------------------------------- /example/pkg/_pkg11/src/foo/foo.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "guthib.com/traefik/fromage" 7 | ) 8 | 9 | func main() { 10 | fmt.Print(fromage.Hello()) 11 | } 12 | -------------------------------------------------------------------------------- /example/pkg/_pkg11/src/foo/vendor/guthib.com/traefik/fromage/fromage.go: -------------------------------------------------------------------------------- 1 | package fromage 2 | 3 | import "fmt" 4 | 5 | func Hello() string { 6 | return fmt.Sprint("Fromage") 7 | } 8 | -------------------------------------------------------------------------------- /example/pkg/_pkg12/src/guthib.com/foo/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "guthib.com/foo/pkg" 7 | ) 8 | 9 | func main() { 10 | fmt.Printf("%s", pkg.NewSample()()) 11 | } 12 | -------------------------------------------------------------------------------- /example/pkg/_pkg12/src/guthib.com/foo/vendor/guthib.com/bar/bar.go: -------------------------------------------------------------------------------- 1 | package bar 2 | 3 | // Bar is bar 4 | func Bar() string { 5 | return "Yo" 6 | } 7 | -------------------------------------------------------------------------------- /example/pkg/_pkg13/src/guthib.com/foo/bar/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "guthib.com/bat/baz" 7 | ) 8 | 9 | func main() { 10 | t := baz.NewT() 11 | 12 | fmt.Printf("%s", t.A3) 13 | } 14 | -------------------------------------------------------------------------------- /example/pkg/_pkg2/src/github.com/foo/pkg/vendor/guthib.com/traefik/fromage/fromage.go: -------------------------------------------------------------------------------- 1 | package fromage 2 | 3 | import ( 4 | "fmt" 5 | 6 | "guthib.com/traefik/cheese" 7 | ) 8 | 9 | func Hello() string { 10 | return fmt.Sprintf("Fromage %s", cheese.Hello()) 11 | } 12 | -------------------------------------------------------------------------------- /example/pkg/_pkg2/src/github.com/foo/pkg/vendor/guthib.com/traefik/fromage/vendor/guthib.com/traefik/cheese/fromage.go: -------------------------------------------------------------------------------- 1 | package cheese 2 | 3 | import "fmt" 4 | 5 | func Hello() string { 6 | return fmt.Sprint("Cheese!") 7 | } -------------------------------------------------------------------------------- /example/pkg/_pkg3/src/github.com/foo/pkg/vendor/guthib.com/traefik/fromage/couteau/couteau.go: -------------------------------------------------------------------------------- 1 | package couteau 2 | 3 | import "fmt" 4 | 5 | func Hello() string { 6 | return fmt.Sprint("Couteau") 7 | } -------------------------------------------------------------------------------- /example/pkg/_pkg3/src/github.com/foo/pkg/vendor/guthib.com/traefik/fromage/vendor/guthib.com/traefik/cheese/fromage.go: -------------------------------------------------------------------------------- 1 | package cheese 2 | 3 | import "fmt" 4 | 5 | func Hello() string { 6 | return fmt.Sprint("Cheese!") 7 | } -------------------------------------------------------------------------------- /example/pkg/_pkg4/src/github.com/foo/pkg/vendor/guthib.com/traefik/fromage/couteau/couteau.go: -------------------------------------------------------------------------------- 1 | package couteau 2 | 3 | import "fmt" 4 | 5 | func Hello() string { 6 | return fmt.Sprint("Couteau") 7 | } 8 | -------------------------------------------------------------------------------- /example/pkg/_pkg4/src/github.com/foo/pkg/vendor/guthib.com/traefik/fromage/vendor/guthib.com/traefik/cheese/vin/vin.go: -------------------------------------------------------------------------------- 1 | package vin 2 | 3 | import "fmt" 4 | 5 | func Hello() string { 6 | return fmt.Sprint("Vin!") 7 | } 8 | -------------------------------------------------------------------------------- /example/pkg/_pkg5/src/github.com/foo/pkg/vendor/guthib.com/traefik/cheese/cheese.go: -------------------------------------------------------------------------------- 1 | package cheese 2 | 3 | import ( 4 | "fmt" 5 | 6 | "guthib.com/traefik/cheese/vin" 7 | ) 8 | 9 | func Hello() string { 10 | return fmt.Sprintf("Cheese %s", vin.Hello()) 11 | } 12 | -------------------------------------------------------------------------------- /example/pkg/_pkg5/src/github.com/foo/pkg/vendor/guthib.com/traefik/cheese/vin/vin.go: -------------------------------------------------------------------------------- 1 | package vin 2 | 3 | import "fmt" 4 | 5 | func Hello() string { 6 | return fmt.Sprint("Vin!") 7 | } 8 | -------------------------------------------------------------------------------- /example/pkg/_pkg5/src/github.com/foo/pkg/vendor/guthib.com/traefik/fromage/couteau/couteau.go: -------------------------------------------------------------------------------- 1 | package couteau 2 | 3 | import "fmt" 4 | 5 | func Hello() string { 6 | return fmt.Sprint("Couteau") 7 | } 8 | -------------------------------------------------------------------------------- /example/pkg/_pkg6/src/github.com/foo/pkg/vendor/guthib.com/traefik/fromage/couteau/couteau.go: -------------------------------------------------------------------------------- 1 | package couteau 2 | 3 | import "fmt" 4 | 5 | func Hello() string { 6 | return fmt.Sprint("Couteau") 7 | } 8 | -------------------------------------------------------------------------------- /example/pkg/_pkg6/src/guthib.com/traefik/cheese/cheese.go: -------------------------------------------------------------------------------- 1 | package cheese 2 | 3 | import ( 4 | "fmt" 5 | 6 | "guthib.com/traefik/cheese/vin" 7 | ) 8 | 9 | func Hello() string { 10 | return fmt.Sprintf("Cheese %s", vin.Hello()) 11 | } 12 | -------------------------------------------------------------------------------- /example/pkg/_pkg6/src/guthib.com/traefik/cheese/vin/vin.go: -------------------------------------------------------------------------------- 1 | package vin 2 | 3 | import "fmt" 4 | 5 | func Hello() string { 6 | return fmt.Sprint("Vin!") 7 | } 8 | -------------------------------------------------------------------------------- /example/pkg/_pkg7/src/github.com/foo/pkg/vendor/guthib.com/traefik/fromage/fromage.go: -------------------------------------------------------------------------------- 1 | package fromage 2 | 3 | import "fmt" 4 | 5 | func Hello() string { 6 | return fmt.Sprint("fromage") 7 | } 8 | -------------------------------------------------------------------------------- /example/pkg/_pkg7/src/github.com/foo/pkg/vendor/guthib.com/traefik/vin/vin.go: -------------------------------------------------------------------------------- 1 | package vin 2 | 3 | import ( 4 | "fmt" 5 | 6 | "guthib.com/traefik/cheese" 7 | ) 8 | 9 | func Hello() string { 10 | return fmt.Sprintf("vin %s", cheese.Hello()) 11 | } 12 | -------------------------------------------------------------------------------- /example/pkg/_pkg8/src/github.com/foo/pkg/fromage/fromage.go: -------------------------------------------------------------------------------- 1 | package fromage 2 | 3 | import "fmt" 4 | 5 | func Hello() string { 6 | return fmt.Sprint("Fromage!") 7 | } 8 | -------------------------------------------------------------------------------- /example/pkg/_pkg9/src/github.com/foo/pkg/fromage/fromage.go: -------------------------------------------------------------------------------- 1 | package fromage 2 | 3 | import "fmt" 4 | 5 | func Hello() string { 6 | return fmt.Sprint("Fromage!") 7 | } 8 | -------------------------------------------------------------------------------- /extract/testdata/1/src/guthib.com/bar/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "guthib.com/baz" 5 | ) 6 | 7 | func main() { 8 | baz.Hello() 9 | } 10 | -------------------------------------------------------------------------------- /extract/testdata/1/src/guthib.com/baz/baz.go: -------------------------------------------------------------------------------- 1 | package baz 2 | 3 | func Hello() { 4 | println("HELLO") 5 | } 6 | -------------------------------------------------------------------------------- /extract/testdata/1/src/guthib.com/baz/go.mod: -------------------------------------------------------------------------------- 1 | module guthib.com/baz 2 | 3 | go 1.14 4 | -------------------------------------------------------------------------------- /extract/testdata/2/src/guthib.com/bar/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "guthib.com/baz" 5 | ) 6 | 7 | func main() { 8 | baz.Hello() 9 | } 10 | -------------------------------------------------------------------------------- /extract/testdata/2/src/guthib.com/baz/baz.go: -------------------------------------------------------------------------------- 1 | package baz 2 | 3 | func Hello() { 4 | println("HELLO") 5 | } 6 | -------------------------------------------------------------------------------- /extract/testdata/3/src/guthib.com/bar/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "guthib.com/baz" 5 | ) 6 | 7 | func main() { 8 | baz.Hello() 9 | } 10 | -------------------------------------------------------------------------------- /extract/testdata/3/src/guthib.com/baz/baz.go: -------------------------------------------------------------------------------- 1 | package baz 2 | 3 | func Hello() { 4 | println("HELLO") 5 | } 6 | -------------------------------------------------------------------------------- /extract/testdata/3/src/guthib.com/baz/go.mod: -------------------------------------------------------------------------------- 1 | module should.not/be/used 2 | 3 | go 1.14 4 | -------------------------------------------------------------------------------- /extract/testdata/4/src/guthib.com/bar/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "guthib.com/baz" 5 | ) 6 | 7 | func main() { 8 | baz.Hello() 9 | } 10 | -------------------------------------------------------------------------------- /extract/testdata/4/src/guthib.com/bar/vendor/guthib.com/baz/baz.go: -------------------------------------------------------------------------------- 1 | package baz 2 | 3 | func Hello() { 4 | println("HELLO") 5 | } 6 | -------------------------------------------------------------------------------- /extract/testdata/4/src/guthib.com/bar/vendor/guthib.com/baz/go.mod: -------------------------------------------------------------------------------- 1 | module guthib.com/baz 2 | 3 | go 1.14 4 | -------------------------------------------------------------------------------- /extract/testdata/5/src/guthib.com/bar/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "guthib.com/baz" 5 | ) 6 | 7 | func main() { 8 | baz.Hello() 9 | } 10 | -------------------------------------------------------------------------------- /extract/testdata/5/src/guthib.com/bar/vendor/guthib.com/baz/baz.go: -------------------------------------------------------------------------------- 1 | package baz 2 | 3 | func Hello() { 4 | println("HELLO") 5 | } 6 | -------------------------------------------------------------------------------- /extract/testdata/6/src/guthib.com/bar/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "guthib.com/baz" 5 | ) 6 | 7 | func main() { 8 | baz.Hello() 9 | } 10 | -------------------------------------------------------------------------------- /extract/testdata/6/src/guthib.com/baz-baz/baz.go: -------------------------------------------------------------------------------- 1 | package baz 2 | 3 | func Hello() { 4 | println("HELLO") 5 | } 6 | -------------------------------------------------------------------------------- /extract/testdata/6/src/guthib.com/baz-baz/go.mod: -------------------------------------------------------------------------------- 1 | module guthib.com/baz-baz -------------------------------------------------------------------------------- /extract/testdata/7/src/guthib.com/variadic/go.mod: -------------------------------------------------------------------------------- 1 | module guthib.com/baz-baz/variadic -------------------------------------------------------------------------------- /extract/testdata/7/src/guthib.com/variadic/variadic.go: -------------------------------------------------------------------------------- 1 | package variadic 2 | 3 | type Variadic interface { 4 | Call(method string, args ...[]interface{}) (interface{}, error) 5 | } 6 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/traefik/yaegi 2 | 3 | go 1.21 4 | -------------------------------------------------------------------------------- /interp/testdata/concurrent/hello1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "time" 4 | 5 | func main() { 6 | go func() { 7 | time.Sleep(3 * time.Second) 8 | println("hello world1") 9 | }() 10 | } 11 | -------------------------------------------------------------------------------- /interp/testdata/concurrent/hello2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "time" 4 | 5 | func main() { 6 | go func() { 7 | time.Sleep(3 * time.Second) 8 | println("hello world2") 9 | }() 10 | } 11 | -------------------------------------------------------------------------------- /interp/testdata/multi/731/sample1.go: -------------------------------------------------------------------------------- 1 | package subpkg 2 | 3 | import "fmt" 4 | 5 | func PrintA() { 6 | fmt.Println("A") 7 | } 8 | -------------------------------------------------------------------------------- /interp/testdata/multi/731/sample2.go: -------------------------------------------------------------------------------- 1 | package subpkg 2 | 3 | import "fmt" 4 | 5 | func PrintB() { 6 | fmt.Println("B") 7 | } 8 | -------------------------------------------------------------------------------- /interp/testdata/multi/731/sample3.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "subpkg" 4 | 5 | func main() { 6 | subpkg.PrintA() 7 | subpkg.PrintB() 8 | } 9 | -------------------------------------------------------------------------------- /interp/testdata/src/github.com/foo/bar/baz/baz.go: -------------------------------------------------------------------------------- 1 | package baz 2 | -------------------------------------------------------------------------------- /interp/testdata/src/github.com/foo/vendor/whatever/whatever.go: -------------------------------------------------------------------------------- 1 | package whatever 2 | -------------------------------------------------------------------------------- /stdlib/go1_22_cmp.go: -------------------------------------------------------------------------------- 1 | // Code generated by 'yaegi extract cmp'. DO NOT EDIT. 2 | 3 | //go:build go1.22 4 | // +build go1.22 5 | 6 | package stdlib 7 | 8 | import ( 9 | "reflect" 10 | ) 11 | 12 | func init() { 13 | Symbols["cmp/cmp"] = map[string]reflect.Value{} 14 | } 15 | -------------------------------------------------------------------------------- /stdlib/go1_22_maps.go: -------------------------------------------------------------------------------- 1 | // Code generated by 'yaegi extract maps'. DO NOT EDIT. 2 | 3 | //go:build go1.22 4 | // +build go1.22 5 | 6 | package stdlib 7 | 8 | import ( 9 | "reflect" 10 | ) 11 | 12 | func init() { 13 | Symbols["maps/maps"] = map[string]reflect.Value{} 14 | } 15 | -------------------------------------------------------------------------------- /stdlib/go1_22_slices.go: -------------------------------------------------------------------------------- 1 | // Code generated by 'yaegi extract slices'. DO NOT EDIT. 2 | 3 | //go:build go1.22 4 | // +build go1.22 5 | 6 | package stdlib 7 | 8 | import ( 9 | "reflect" 10 | ) 11 | 12 | func init() { 13 | Symbols["slices/slices"] = map[string]reflect.Value{} 14 | } 15 | -------------------------------------------------------------------------------- /stdlib/stdlib-go1.22.go: -------------------------------------------------------------------------------- 1 | //go:build go1.22 2 | 3 | package stdlib 4 | 5 | //go:generate ../internal/cmd/extract/extract go/version math/rand/v2 6 | --------------------------------------------------------------------------------