├── README.md ├── go.mod ├── gobook ├── gobook-1.0.tar.gz └── goeg │ ├── LICENSE-2.0.txt │ ├── README.txt │ ├── build.sh │ ├── gopath.sh │ └── src │ ├── americanise │ ├── americanise.go │ ├── americanise_test.go │ ├── british-american.txt │ ├── expected.txt │ └── input.txt │ ├── apachereport1 │ └── apachereport.go │ ├── apachereport2 │ └── apachereport.go │ ├── apachereport3 │ └── apachereport.go │ ├── apachereport4 │ └── apachereport.go │ ├── apachereport5 │ └── apachereport.go │ ├── archive_file_list │ └── archive_file_list.go │ ├── archive_file_list_ans │ └── archive_file_list.go │ ├── bigdigits │ ├── 0123456789.txt │ ├── bigdigits.go │ └── bigdigits_test.go │ ├── bigdigits_ans │ ├── 0123456789.txt │ ├── bigdigits.go │ └── bigdigits_test.go │ ├── cgrep1 │ └── cgrep.go │ ├── cgrep2 │ └── cgrep.go │ ├── cgrep3 │ ├── cgrep.go │ ├── util_darwin.go │ ├── util_freebsd.go │ ├── util_linux.go │ └── util_windows.go │ ├── chap4_ans │ └── chap4_ans.go │ ├── common_prefix │ └── common_prefix.go │ ├── contains │ └── contains.go │ ├── filter │ └── filter.go │ ├── findduplicates │ └── findduplicates.go │ ├── font │ ├── font.go │ └── font_test.go │ ├── fuzzy │ ├── fuzzy.go │ └── fuzzybool │ │ └── fuzzybool.go │ ├── fuzzy_immutable │ ├── fuzzybool │ │ └── fuzzybool.go │ └── immutable_fuzzy.go │ ├── fuzzy_mutable │ ├── fuzzybool │ │ └── fuzzybool.go │ └── mutable_fuzzy.go │ ├── fuzzy_value │ ├── fuzzy.go │ └── fuzzybool │ │ └── fuzzybool.go │ ├── guess_separator │ └── guess_separator.go │ ├── hello │ └── hello.go │ ├── imagetag1 │ └── imagetag1.go │ ├── imagetag2 │ └── imagetag2.go │ ├── indent_sort │ └── indent_sort.go │ ├── invoicedata │ ├── gob.go │ ├── inv.go │ ├── invoicedata.go │ ├── invoices.gob.gz │ ├── jsn.go │ ├── txt.go │ └── xml.go │ ├── invoicedata_ans │ ├── gob.go │ ├── inv.go │ ├── invoicedata.go │ ├── jsn.go │ ├── txt.go │ └── xml.go │ ├── linkcheck │ ├── linkcheck.go │ └── linkutil │ │ ├── index.html │ │ ├── index.links │ │ ├── linkutil.go │ │ └── linkutil_test.go │ ├── m3u2pls │ ├── David-Bowie-Singles.m3u │ ├── David-Bowie-Singles.pls │ ├── m3u2pls.go │ └── m3u2pls_test.go │ ├── memoize │ └── memoize.go │ ├── ordered_map │ └── ordered_map.go │ ├── oslice │ ├── oslice.go │ └── oslice_test.go │ ├── pack │ └── pack.go │ ├── palindrome │ └── palindrome.go │ ├── palindrome_ans │ └── palindrome.go │ ├── pi_by_digits │ └── pi_by_digits.go │ ├── playlist │ ├── David-Bowie-Singles.m3u │ ├── David-Bowie-Singles.pls │ └── playlist.go │ ├── polar2cartesian │ └── polar2cartesian.go │ ├── qtrac.eu │ └── omap │ │ ├── omap.go │ │ └── omap_test.go │ ├── quadratic_ans1 │ └── quadratic.go │ ├── quadratic_ans2 │ └── quadratic.go │ ├── safemap │ ├── safemap.go │ └── safemap_test.go │ ├── safeslice │ ├── safeslice.go │ └── safeslice_test.go │ ├── shaper1 │ ├── shaper1.go │ └── shapes │ │ └── shapes.go │ ├── shaper2 │ ├── shaper2.go │ └── shapes │ │ └── shapes.go │ ├── shaper3 │ ├── shaper3.go │ └── shapes │ │ └── shapes.go │ ├── shaper_ans1 │ ├── shaper1.go │ └── shapes │ │ └── shapes.go │ ├── shaper_ans2 │ ├── shaper2.go │ └── shapes │ │ └── shapes.go │ ├── shaper_ans3 │ ├── shaper3.go │ └── shapes │ │ └── shapes.go │ ├── sizeimages1 │ └── sizeimages1.go │ ├── sizeimages2 │ └── sizeimages2.go │ ├── soundex │ ├── soundex-test-data.txt │ └── soundex.go │ ├── stacker │ ├── stack │ │ ├── stack.go │ │ └── stack_test.go │ └── stacker.go │ ├── statistics │ └── statistics.go │ ├── statistics_ans │ └── statistics.go │ ├── statistics_nonstop │ └── statistics.go │ ├── statistics_nonstop2 │ └── statistics.go │ ├── unpack │ └── unpack.go │ ├── unpack_ans │ └── unpack.go │ ├── utf16-to-utf8 │ ├── utf-16-be.txt │ ├── utf-16-le.txt │ └── utf16-to-utf8.go │ └── wordfrequency │ └── wordfrequency.go ├── helloworld ├── HowToWriteGoCode.md ├── README.md ├── go.mod ├── go.sum ├── greetings │ ├── go.mod │ ├── greetings.go │ └── greetings_test.go └── hello.go ├── module ├── README.md └── hello │ ├── go.mod │ ├── go.sum │ ├── hello.go │ ├── hello_test.go │ └── world │ ├── world.go │ └── world_test.go ├── performance ├── test1 │ ├── go.mod │ ├── heap.out │ ├── main.go │ └── test1 └── test2 │ ├── go.mod │ └── main.go ├── programming_in_go ├── bin │ └── file_demo ├── pkg │ └── darwin_amd64 │ │ ├── github.com │ │ ├── astaxie │ │ │ └── bat │ │ │ │ └── httplib.a │ │ └── tools │ │ │ └── godep │ │ │ └── Godeps │ │ │ └── _workspace │ │ │ └── src │ │ │ ├── github.com │ │ │ ├── kr │ │ │ │ ├── fs.a │ │ │ │ ├── pretty.a │ │ │ │ └── text.a │ │ │ └── pmezard │ │ │ │ └── go-difflib │ │ │ │ └── difflib.a │ │ │ └── golang.org │ │ │ └── x │ │ │ └── tools │ │ │ └── go │ │ │ └── vcs.a │ │ └── stacker │ │ └── stack.a └── src │ ├── americanise │ ├── americanise.go │ ├── americanise_test.go │ ├── british-american.txt │ ├── expected.txt │ └── input.txt │ ├── bigdigits │ ├── 0123456789.txt │ ├── bigdigits.go │ └── bigdigits_test.go │ ├── hello │ └── hello.go │ └── stacker │ ├── stack │ ├── stack.go │ └── stack_test.go │ └── stacker.go ├── src ├── MySQL │ └── mysql_client │ │ └── src │ │ ├── demo.go │ │ ├── github.com │ │ ├── go-sql-driver │ │ │ └── mysql │ │ │ │ ├── .github │ │ │ │ ├── ISSUE_TEMPLATE.md │ │ │ │ └── PULL_REQUEST_TEMPLATE.md │ │ │ │ ├── .gitignore │ │ │ │ ├── .travis.yml │ │ │ │ ├── AUTHORS │ │ │ │ ├── CHANGELOG.md │ │ │ │ ├── CONTRIBUTING.md │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── appengine.go │ │ │ │ ├── benchmark_test.go │ │ │ │ ├── buffer.go │ │ │ │ ├── collations.go │ │ │ │ ├── connection.go │ │ │ │ ├── connection_test.go │ │ │ │ ├── const.go │ │ │ │ ├── driver.go │ │ │ │ ├── driver_test.go │ │ │ │ ├── dsn.go │ │ │ │ ├── dsn_test.go │ │ │ │ ├── errors.go │ │ │ │ ├── errors_test.go │ │ │ │ ├── infile.go │ │ │ │ ├── packets.go │ │ │ │ ├── packets_test.go │ │ │ │ ├── result.go │ │ │ │ ├── rows.go │ │ │ │ ├── statement.go │ │ │ │ ├── transaction.go │ │ │ │ ├── utils.go │ │ │ │ └── utils_test.go │ │ └── readline │ │ │ ├── .travis.yml │ │ │ ├── CHANGELOG.md │ │ │ ├── README.md │ │ │ ├── readline.go │ │ │ └── readline_test.go │ │ └── init.sh ├── NoSQL │ └── ssdb_client │ │ ├── README.md │ │ ├── v1 │ │ ├── Doxyfile │ │ ├── README.md │ │ ├── ssdb │ │ │ └── ssdb.go │ │ └── test.go │ │ └── v2 │ │ ├── README.md │ │ ├── ssdb │ │ └── ssdb.go │ │ └── ssdb_client.go ├── cgo │ ├── inc │ │ └── hello.h │ └── src │ │ ├── Makefile │ │ ├── hello.c │ │ ├── hello.go │ │ └── main.c ├── channel │ ├── channel_buf.go │ └── channel_nobuf.go ├── exec │ ├── go.mod │ └── main.go ├── file_scp │ ├── README │ ├── data.txt │ ├── file_rcv.go │ └── file_snd.go ├── godep_test │ └── src │ │ ├── app │ │ └── main.go │ │ └── lib │ │ └── foolib │ │ └── foo.go ├── goleveldb │ ├── demo.go │ └── leveldb_test.py ├── goroutine │ └── routine_ex.go ├── http │ ├── README.md │ ├── cert │ │ ├── README.md │ │ ├── server.crt │ │ └── server.key │ ├── http_svr │ │ ├── http_svr_v1.go │ │ └── http_svr_v2.go │ ├── https_client │ │ ├── README.md │ │ └── https_client.go │ ├── https_proxy │ │ ├── README.md │ │ ├── gen_self_signed_cert.sh │ │ └── https_proxy_hijacker.go │ └── https_server │ │ ├── https_server.go │ │ ├── https_server_v2.go │ │ └── https_server_v3.go ├── int64_bytes_convert │ └── int64_bytes_convert.go ├── log4go │ ├── README.md │ └── src │ │ ├── log4go │ │ ├── .hg │ │ │ ├── 00changelog.i │ │ │ ├── branch │ │ │ ├── cache │ │ │ │ ├── branchheads │ │ │ │ └── tags │ │ │ ├── dirstate │ │ │ ├── hgrc │ │ │ ├── requires │ │ │ ├── store │ │ │ │ ├── 00changelog.i │ │ │ │ ├── 00manifest.i │ │ │ │ ├── data │ │ │ │ │ ├── _l_i_c_e_n_s_e.i │ │ │ │ │ ├── _makefile.i │ │ │ │ │ ├── _r_e_a_d_m_e.i │ │ │ │ │ ├── config.go.i │ │ │ │ │ ├── elog.go.i │ │ │ │ │ ├── elog__config.go.i │ │ │ │ │ ├── elog__filelog.go.i │ │ │ │ │ ├── elog__socklog.go.i │ │ │ │ │ ├── elog__test.go.i │ │ │ │ │ ├── example.xml.i │ │ │ │ │ ├── examples │ │ │ │ │ │ ├── _console_log_writer___manual.go.i │ │ │ │ │ │ ├── _file_log_writer___manual.go.i │ │ │ │ │ │ ├── _simple_net_log_server.go.i │ │ │ │ │ │ ├── _socket_log_writer___manual.go.i │ │ │ │ │ │ ├── _x_m_l_configuration_example.go.i │ │ │ │ │ │ └── example.xml.i │ │ │ │ │ ├── filelog.go.i │ │ │ │ │ ├── log4go.go.i │ │ │ │ │ ├── log4go │ │ │ │ │ │ ├── _makefile.i │ │ │ │ │ │ ├── elog.go.i │ │ │ │ │ │ ├── elog__config.go.i │ │ │ │ │ │ ├── elog__filelog.go.i │ │ │ │ │ │ ├── elog__socklog.go.i │ │ │ │ │ │ ├── elog__test.go.i │ │ │ │ │ │ ├── log4go.go.i │ │ │ │ │ │ ├── log4go__config.go.i │ │ │ │ │ │ ├── log4go__filelog.go.i │ │ │ │ │ │ ├── log4go__socklog.go.i │ │ │ │ │ │ ├── log4go__termlog.go.i │ │ │ │ │ │ ├── log4go__test.go.i │ │ │ │ │ │ └── log4go__wrapper.go.i │ │ │ │ │ ├── log4go__test.go.i │ │ │ │ │ ├── pattlog.go.i │ │ │ │ │ ├── socklog.go.i │ │ │ │ │ ├── src │ │ │ │ │ │ ├── _makefile.i │ │ │ │ │ │ ├── elog.go.i │ │ │ │ │ │ ├── elog__config.go.i │ │ │ │ │ │ ├── elog__filelog.go.i │ │ │ │ │ │ ├── elog__socklog.go.i │ │ │ │ │ │ ├── elog__test.go.i │ │ │ │ │ │ └── example.xml.i │ │ │ │ │ ├── termlog.go.i │ │ │ │ │ ├── wrapper.go.i │ │ │ │ │ ├── xmllog.go.i │ │ │ │ │ └── ~2ehgtags.i │ │ │ │ ├── fncache │ │ │ │ ├── phaseroots │ │ │ │ ├── undo │ │ │ │ └── undo.phaseroots │ │ │ ├── undo.bookmarks │ │ │ ├── undo.branch │ │ │ ├── undo.desc │ │ │ └── undo.dirstate │ │ ├── .hgtags │ │ ├── LICENSE │ │ ├── README │ │ ├── config.go │ │ ├── examples │ │ │ ├── ConsoleLogWriter_Manual.go │ │ │ ├── FileLogWriter_Manual.go │ │ │ ├── SimpleNetLogServer.go │ │ │ ├── SocketLogWriter_Manual.go │ │ │ ├── XMLConfigurationExample.go │ │ │ └── example.xml │ │ ├── filelog.go │ │ ├── log4go.go │ │ ├── log4go_test.go │ │ ├── pattlog.go │ │ ├── socklog.go │ │ ├── termlog.go │ │ └── wrapper.go │ │ └── source-archive.zip ├── race_check │ ├── README.md │ ├── build.sh │ └── main.go ├── reflect │ ├── demo1_test.go │ ├── demo2_test.go │ ├── demo3_test.go │ └── go.mod ├── rsa │ └── src │ │ ├── README.md │ │ ├── billing_sign.go │ │ ├── demo.go │ │ └── rsa_tools │ │ └── rsa_tools.go ├── socket │ ├── ip.go │ ├── tcpechov1 │ │ ├── README │ │ ├── tcpclient.go │ │ └── tcpsvr.go │ ├── tcpechov2 │ │ ├── README │ │ ├── tcpclient.go │ │ └── tcpsvr.go │ ├── tcpechov3 │ │ ├── README │ │ ├── tcpclient.go │ │ └── tcpsvr.go │ └── tcpechov4 │ │ ├── README │ │ ├── tcpclient.go │ │ └── tcpsvr.go ├── tcp │ └── test │ │ ├── go.mod │ │ └── main.go ├── template │ ├── demo1 │ │ ├── demo1.go │ │ └── go.mod │ └── demo2 │ │ ├── demo2.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── meta.yaml │ │ └── test.cfg └── utils │ └── time │ └── time.go └── tools ├── README.md ├── errcheck ├── .travis.yml ├── LICENSE ├── README.md ├── example │ ├── main.go │ └── main2.go ├── lib │ ├── errcheck.go │ ├── errcheck_test.go │ └── util.go └── main.go ├── gocode ├── .gitignore ├── LICENSE ├── README.md ├── _gccgo │ └── package.go ├── _goremote │ └── goremote.go ├── _testing │ ├── DESC │ ├── README │ ├── all.bash │ ├── run.py │ ├── run.rb │ ├── run.tcl │ ├── test.0001 │ │ ├── cursor.47 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0002 │ │ ├── cursor.105 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0003 │ │ ├── cursor.552 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0004 │ │ ├── cursor.1348 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0005 │ │ ├── b.go │ │ ├── cursor.327 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0006 │ │ ├── b.go │ │ ├── cursor.286 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0007 │ │ ├── cursor.58 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0008 │ │ ├── cursor.120 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0009 │ │ ├── cursor.126 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0010 │ │ ├── cursor.104 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0011 │ │ ├── cursor.76 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0012 │ │ ├── cursor.114 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0013 │ │ ├── cursor.359 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0014 │ │ ├── cursor.191 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0015 │ │ ├── cursor.130 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0016 │ │ ├── cursor.122 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0017 │ │ ├── cursor.70 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0018 │ │ ├── cursor.355 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0019 │ │ ├── cursor.72 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0020 │ │ ├── cursor.174 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0021 │ │ ├── cursor.82 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0022 │ │ ├── cursor.79 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0023 │ │ ├── cursor.88 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0024 │ │ ├── cursor.71 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0025 │ │ ├── cursor.53 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0026 │ │ ├── cursor.164 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0027 │ │ ├── cursor.84 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0028 │ │ ├── cursor.129 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0029 │ │ ├── cursor.62 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0030 │ │ ├── cursor.85 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0031 │ │ ├── cursor.80 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0032 │ │ ├── cursor.1835 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0033 │ │ ├── cursor.138 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0034 │ │ ├── cursor.82 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0035 │ │ ├── cursor.91 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0036 │ │ ├── cursor.67 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0037 │ │ ├── cursor.139 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0038 │ │ ├── cursor.87 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0039 │ │ ├── cursor.88 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0040 │ │ ├── cursor.96 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0041 │ │ ├── cursor.140 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0042 │ │ ├── cursor.126 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0043 │ │ ├── cursor.182 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0044 │ │ ├── cursor.105 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0045 │ │ ├── cursor.51 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0046 │ │ ├── cursor.53 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0047 │ │ ├── cursor.43 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0048 │ │ ├── cursor.53 │ │ ├── out.expected │ │ └── test.go.in │ ├── test.0049 │ │ ├── cursor.44 │ │ ├── out.expected │ │ └── test.go.in │ └── test.0050 │ │ ├── cursor.45 │ │ ├── out.expected │ │ └── test.go.in ├── autocompletecontext.go ├── autocompletefile.go ├── client.go ├── config.go ├── cursorcontext.go ├── debian │ ├── changelog │ ├── compat │ ├── control │ ├── copyright │ ├── docs │ ├── gocode.default │ ├── rules │ └── source │ │ └── format ├── decl.go ├── declcache.go ├── docs │ ├── IDE_integration.md │ └── autocomplete_formats.md ├── emacs-company │ ├── README.md │ └── company-go.el ├── emacs │ └── go-autocomplete.el ├── formatters.go ├── gocode.go ├── os_posix.go ├── os_windows.go ├── package.go ├── ripper.go ├── rpc.go ├── scope.go ├── server.go ├── utils.go └── vim │ ├── autoload │ └── gocomplete.vim │ ├── ftplugin │ └── go │ │ └── gocomplete.vim │ ├── pathogen_update.sh │ ├── symlink.sh │ └── update.sh ├── gotags ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── main.go ├── parser.go ├── parser_test.go ├── tag.go ├── tag_test.go └── tests │ ├── const.go-src │ ├── func.go-src │ ├── import.go-src │ ├── interface.go-src │ ├── simple.go-src │ ├── struct.go-src │ ├── type.go-src │ └── var.go-src ├── lint ├── LICENSE ├── README ├── golint │ ├── golint.go │ └── import.go ├── lint.go ├── lint_test.go ├── misc │ ├── emacs │ │ └── golint.el │ └── vim │ │ └── ftplugin │ │ └── go │ │ └── lint.vim └── testdata │ ├── 4.go │ ├── 5_test.go │ ├── blank-import-lib.go │ ├── blank-import-lib_test.go │ ├── blank-import-main.go │ ├── common-methods.go │ ├── const-block.go │ ├── else-multi.go │ ├── else.go │ ├── error-return.go │ ├── errorf.go │ ├── errors.go │ ├── import-dot.go │ ├── inc.go │ ├── make.go │ ├── names.go │ ├── pkg-doc1.go │ ├── pkg-doc2.go │ ├── pkg-doc3.go │ ├── pkg-doc4.go │ ├── pkg-main.go │ ├── range.go │ ├── receiver-names.go │ ├── sort.go │ ├── stutter.go │ ├── unexp-return.go │ └── var-decl.go ├── rog-go ├── canvas │ ├── background.go │ ├── canvas.go │ ├── ellipse.go │ ├── fanciful.go │ ├── objects.go │ ├── raster.go │ └── text.go ├── cmd │ ├── apipe │ │ ├── acme.go │ │ └── apply.go │ ├── bounce │ │ └── bounce.go │ ├── calc │ │ ├── calc.go │ │ ├── doc.go │ │ ├── help.go │ │ └── ops.go │ ├── ec2 │ │ └── ec2.go │ ├── godeps │ │ ├── godeps.go │ │ └── godeps_test.go │ ├── hello │ │ └── hello.go │ ├── mandel │ │ └── mandel.go │ ├── peter-rabbit │ │ ├── board.go │ │ ├── game_test.go │ │ └── peter-rabbit.go │ ├── pxargs │ │ └── pxargs.go │ ├── rpcreader │ │ └── rpcreader.go │ ├── shape │ │ └── shape.go │ ├── share │ │ ├── doc.go │ │ └── share.go │ ├── share2 │ │ └── share.go │ ├── showdeps │ │ └── showdeps.go │ ├── stackgraph │ │ ├── stackgraph.go │ │ └── svg.go │ ├── timestamp │ │ └── timestamp.go │ └── trampoline │ │ └── trampoline.go ├── deepdiff │ ├── deepequal_test.go │ └── diff.go ├── encoding │ └── values │ │ └── values.go ├── exp │ ├── abc │ │ ├── abc.go │ │ ├── abc.y │ │ ├── audio │ │ │ ├── _testmain.go │ │ │ ├── audio.go │ │ │ ├── buffer.go │ │ │ ├── buffers.go │ │ │ ├── format.go │ │ │ ├── input.go │ │ │ ├── output.go │ │ │ ├── util.go │ │ │ ├── w_auread.go │ │ │ ├── w_auwrite.go │ │ │ ├── w_converter.go │ │ │ ├── w_delay.go │ │ │ ├── w_envelope.go │ │ │ ├── w_graph.go │ │ │ ├── w_mixer.go │ │ │ ├── w_multiply.go │ │ │ ├── w_permute.go │ │ │ ├── w_phaser.go │ │ │ ├── w_ringbuf.go │ │ │ ├── w_time.go │ │ │ ├── w_wave.go │ │ │ ├── w_wavfile.go │ │ │ └── widget_test.go │ │ ├── basic │ │ │ ├── basic.go │ │ │ ├── echo.go │ │ │ ├── read.go │ │ │ ├── rot13.go │ │ │ ├── stdin.go │ │ │ ├── stdout.go │ │ │ └── write.go │ │ ├── notes.txt │ │ ├── status.go │ │ └── transform.go │ ├── breader │ │ └── breader.go │ ├── callback │ │ ├── callback.c │ │ ├── callback.h │ │ └── init.go │ ├── cmd │ │ ├── errfix │ │ │ ├── doc.go │ │ │ ├── errgo.go │ │ │ ├── errgo_test.go │ │ │ ├── fix.go │ │ │ ├── import_test.go │ │ │ ├── main.go │ │ │ ├── main_test.go │ │ │ └── typecheck.go │ │ ├── godef │ │ │ ├── acme.go │ │ │ ├── doc.go │ │ │ └── godef.go │ │ ├── gosym │ │ │ ├── filters.go │ │ │ ├── gosym_test.go │ │ │ ├── line.go │ │ │ ├── list.go │ │ │ ├── main.go │ │ │ ├── testfiles │ │ │ │ └── src │ │ │ │ │ └── test │ │ │ │ │ └── test.go │ │ │ └── write.go │ │ ├── websocket-analyse │ │ │ └── websocket-analyse.go │ │ └── websocket-stress │ │ │ └── websocket-stress.go │ ├── deepcopy │ │ ├── deepcopy.go │ │ └── deepcopy_test.go │ ├── errorpath │ │ ├── callees.go │ │ ├── errorpaths.go │ │ ├── errorpaths_test.go │ │ └── testprog.go │ ├── example │ │ ├── event │ │ │ ├── event_test.go │ │ │ ├── win.go │ │ │ ├── window.c │ │ │ └── window.h │ │ └── looper │ │ │ ├── looper.go │ │ │ └── looper_test.go │ ├── filemarshal │ │ ├── filemarshal.go │ │ ├── filemarshal_test.go │ │ └── rpc │ │ │ └── rpc.go │ ├── go │ │ ├── ast │ │ │ ├── ast.go │ │ │ ├── filter.go │ │ │ ├── print.go │ │ │ ├── print_test.go │ │ │ ├── resolve.go │ │ │ ├── scope.go │ │ │ └── walk.go │ │ ├── parser │ │ │ ├── interface.go │ │ │ ├── parser.go │ │ │ ├── parser_test.go │ │ │ └── universe.go │ │ ├── printer │ │ │ ├── nodes.go │ │ │ ├── performance_test.go │ │ │ ├── printer.go │ │ │ ├── printer_test.go │ │ │ └── testdata │ │ │ │ ├── comments.golden │ │ │ │ ├── comments.input │ │ │ │ ├── comments.x │ │ │ │ ├── declarations.golden │ │ │ │ ├── declarations.input │ │ │ │ ├── empty.golden │ │ │ │ ├── empty.input │ │ │ │ ├── expressions.golden │ │ │ │ ├── expressions.input │ │ │ │ ├── expressions.raw │ │ │ │ ├── linebreaks.golden │ │ │ │ ├── linebreaks.input │ │ │ │ ├── parser.go │ │ │ │ ├── slow.golden │ │ │ │ ├── slow.input │ │ │ │ ├── statements.golden │ │ │ │ └── statements.input │ │ ├── scanner │ │ │ ├── errors.go │ │ │ ├── scanner.go │ │ │ └── scanner_test.go │ │ ├── sym │ │ │ └── sym.go │ │ ├── token │ │ │ ├── position.go │ │ │ ├── position_test.go │ │ │ └── token.go │ │ └── types │ │ │ ├── goodarch.go │ │ │ ├── objpos.go │ │ │ ├── types.go │ │ │ └── types_test.go │ ├── key │ │ └── key.go │ ├── rpcreflect │ │ └── rpcreflect.go │ ├── runtime │ │ └── debug │ │ │ ├── stack.go │ │ │ └── stack_test.go │ ├── stamp │ │ └── stamp.go │ ├── stquery │ │ ├── example_test.go │ │ ├── query.go │ │ └── query_test.go │ └── stringfs │ │ └── stringfs.go ├── extern │ ├── draw │ │ ├── arith.go │ │ ├── color.go │ │ ├── draw.go │ │ ├── draw_test.go │ │ └── event.go │ └── x11 │ │ ├── auth.go │ │ └── conn.go ├── fakenet │ ├── chan.go │ ├── conn.go │ ├── fakenet_test.go │ └── listen.go ├── go9p │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── README │ ├── g9p │ │ ├── fmt.go │ │ ├── osusers.go │ │ ├── p9.go │ │ ├── packr.go │ │ ├── packt.go │ │ └── unpack.go │ ├── g9pc │ │ ├── client.go │ │ ├── close.go │ │ ├── examples │ │ │ ├── cl.go │ │ │ ├── ls.go │ │ │ ├── read.go │ │ │ └── write.go │ │ ├── mount.go │ │ ├── open.go │ │ ├── pool.go │ │ ├── read.go │ │ ├── remove.go │ │ ├── stat.go │ │ ├── walk.go │ │ └── write.go │ └── g9plog │ │ └── stats.go ├── loopback │ ├── loopback.go │ ├── loopback_test.go │ ├── net.go │ ├── parse.go │ ├── parse_test.go │ └── pipe.go ├── ncnet │ └── ncnet.go ├── ncrpc │ └── ncrpc.go ├── new9p │ ├── bit.go │ ├── client │ │ ├── conn.go │ │ ├── dial.go │ │ ├── fid.go │ │ ├── fsys.go │ │ ├── ns.go │ │ ├── ops.go │ │ └── stream.go │ ├── const.go │ ├── dir.go │ ├── doc.txt │ ├── examples │ │ ├── bundle.go │ │ ├── cat.go │ │ └── cl.go │ ├── fcall.go │ ├── inferno │ │ ├── memfs.b │ │ ├── styx.b │ │ ├── styx.m │ │ ├── styxlib.b │ │ ├── styxlib.m │ │ └── styxlisten.b │ └── seq │ │ ├── ops.go │ │ └── sequencer.go ├── parallel │ ├── parallel.go │ └── parallel_test.go ├── readlines │ ├── lines.go │ └── lines_test.go ├── reverse │ ├── export_test.go │ ├── scan.go │ └── scan_test.go ├── typeapply │ ├── typeapply.go │ └── typeapply_test.go └── values │ ├── const.go │ ├── lens.go │ ├── lenses.go │ └── values.go └── tools.go ├── .hgignore ├── AUTHORS ├── CONTRIBUTORS ├── LICENSE ├── PATENTS ├── README ├── astutil ├── enclosing.go ├── enclosing_test.go ├── imports.go └── imports_test.go ├── blog ├── atom │ └── atom.go └── blog.go ├── cmd ├── benchcmp │ ├── benchcmp.go │ ├── compare.go │ ├── compare_test.go │ ├── doc.go │ ├── parse.go │ └── parse_test.go ├── cover │ ├── cover.go │ ├── cover_test.go │ ├── doc.go │ ├── func.go │ ├── html.go │ └── testdata │ │ ├── main.go │ │ └── test.go ├── digraph │ ├── digraph.go │ └── digraph_test.go ├── eg │ └── eg.go ├── godex │ ├── doc.go │ ├── gc.go │ ├── gccgo.go │ ├── godex.go │ ├── print.go │ ├── source.go │ └── writetype.go ├── godoc │ ├── README.godoc-app │ ├── appinit.go │ ├── blog.go │ ├── codewalk.go │ ├── dl.go │ ├── doc.go │ ├── godoc_test.go │ ├── handlers.go │ ├── main.go │ ├── play.go │ ├── remotesearch.go │ ├── setup-godoc-app.bash │ └── x.go ├── goimports │ ├── doc.go │ └── goimports.go ├── gorename │ └── main.go ├── gotype │ ├── doc.go │ └── gotype.go ├── html2article │ └── conv.go ├── oracle │ ├── emacs-test.bash │ ├── main.go │ ├── oracle.el │ └── oracle.vim ├── present │ ├── appengine.go │ ├── dir.go │ ├── doc.go │ ├── local.go │ ├── play.go │ ├── static │ │ ├── article.css │ │ ├── dir.css │ │ ├── dir.js │ │ ├── favicon.ico │ │ ├── jquery-ui.js │ │ ├── print.css │ │ ├── slides.js │ │ └── styles.css │ └── templates │ │ ├── action.tmpl │ │ ├── article.tmpl │ │ ├── dir.tmpl │ │ └── slides.tmpl ├── ssadump │ └── main.go ├── stringer │ ├── endtoend_test.go │ ├── golden_test.go │ ├── stringer.go │ ├── testdata │ │ ├── day.go │ │ ├── gap.go │ │ ├── num.go │ │ ├── number.go │ │ ├── prime.go │ │ └── unum.go │ └── util_test.go └── vet │ ├── asmdecl.go │ ├── assign.go │ ├── atomic.go │ ├── bool.go │ ├── buildtag.go │ ├── composite.go │ ├── copylock.go │ ├── deadcode.go │ ├── doc.go │ ├── main.go │ ├── method.go │ ├── nilfunc.go │ ├── print.go │ ├── rangeloop.go │ ├── shadow.go │ ├── shift.go │ ├── structtag.go │ ├── testdata │ ├── asm.go │ ├── asm1.s │ ├── asm2.s │ ├── asm3.s │ ├── asm4.s │ ├── assign.go │ ├── atomic.go │ ├── bool.go │ ├── buildtag.go │ ├── buildtag_bad.go │ ├── composite.go │ ├── copylock_func.go │ ├── copylock_range.go │ ├── deadcode.go │ ├── method.go │ ├── nilfunc.go │ ├── print.go │ ├── rangeloop.go │ ├── shadow.go │ ├── shift.go │ ├── structtag.go │ └── unsafeptr.go │ ├── types.go │ ├── unsafeptr.go │ ├── vet_test.go │ └── whitelist │ └── whitelist.go ├── codereview.cfg ├── container └── intsets │ ├── sparse.go │ ├── sparse_test.go │ ├── util.go │ └── util_test.go ├── cover └── profile.go ├── dashboard ├── README ├── app │ ├── app.yaml │ ├── build │ │ ├── build.go │ │ ├── dash.go │ │ ├── handler.go │ │ ├── init.go │ │ ├── notify.go │ │ ├── notify.txt │ │ ├── perf.go │ │ ├── perf_changes.go │ │ ├── perf_changes.html │ │ ├── perf_detail.go │ │ ├── perf_detail.html │ │ ├── perf_graph.go │ │ ├── perf_graph.html │ │ ├── perf_learn.go │ │ ├── perf_learn.html │ │ ├── perf_notify.txt │ │ ├── test.go │ │ ├── ui.go │ │ ├── ui.html │ │ └── update.go │ ├── cache │ │ └── cache.go │ ├── cron.yaml │ ├── index.yaml │ ├── key │ │ └── key.go │ └── static │ │ ├── status_alert.gif │ │ ├── status_good.gif │ │ └── style.css ├── builder │ ├── bench.go │ ├── doc.go │ ├── env.go │ ├── exec.go │ ├── filemutex_flock.go │ ├── filemutex_local.go │ ├── filemutex_windows.go │ ├── http.go │ ├── main.go │ └── vcs.go ├── coordinator │ ├── Makefile │ ├── buildongce │ │ └── create.go │ └── main.go ├── env │ ├── linux-x86-base │ │ ├── Dockerfile │ │ ├── Makefile │ │ ├── README │ │ └── scripts │ │ │ ├── build-go-builder.sh │ │ │ └── install-apt-deps.sh │ ├── linux-x86-clang │ │ ├── Dockerfile │ │ ├── Makefile │ │ ├── scripts │ │ │ ├── build-go-builder.sh │ │ │ └── install-apt-deps.sh │ │ └── sources │ │ │ └── clang-deps.list │ ├── linux-x86-gccgo │ │ ├── Dockerfile │ │ ├── Makefile │ │ ├── README │ │ └── scripts │ │ │ ├── install-apt-deps.sh │ │ │ ├── install-gccgo-builder.sh │ │ │ └── install-gold.sh │ ├── linux-x86-nacl │ │ ├── Dockerfile │ │ ├── Makefile │ │ ├── README │ │ ├── build-command.pl │ │ └── scripts │ │ │ ├── build-go-builder.sh │ │ │ └── install-apt-deps.sh │ └── linux-x86-sid │ │ ├── Dockerfile │ │ ├── Makefile │ │ └── scripts │ │ ├── build-go-builder.sh │ │ └── install-apt-deps.sh ├── updater │ └── updater.go └── watcher │ └── watcher.go ├── go ├── buildutil │ ├── allpackages.go │ ├── allpackages_test.go │ ├── util.go │ └── util_test.go ├── callgraph │ ├── callgraph.go │ └── util.go ├── exact │ ├── exact.go │ ├── exact_test.go │ ├── go13.go │ └── go14.go ├── gccgoimporter │ ├── gccgoinstallation.go │ ├── gccgoinstallation_test.go │ ├── importer.go │ ├── importer_test.go │ ├── parser.go │ ├── parser_test.go │ └── testdata │ │ ├── complexnums.go │ │ ├── complexnums.gox │ │ ├── imports.go │ │ ├── imports.gox │ │ ├── pointer.go │ │ └── pointer.gox ├── gcimporter │ ├── exportdata.go │ ├── gcimporter.go │ ├── gcimporter_test.go │ └── testdata │ │ └── exports.go ├── importer │ ├── export.go │ ├── import.go │ ├── import_test.go │ └── predefined.go ├── loader │ ├── cgo.go │ ├── loader.go │ ├── loader_test.go │ ├── source_test.go │ ├── stdlib_test.go │ ├── testdata │ │ ├── a.go │ │ └── b.go │ └── util.go ├── pointer │ ├── TODO │ ├── analysis.go │ ├── api.go │ ├── callgraph.go │ ├── constraint.go │ ├── doc.go │ ├── example_test.go │ ├── gen.go │ ├── hvn.go │ ├── intrinsics.go │ ├── labels.go │ ├── opt.go │ ├── pointer_test.go │ ├── print.go │ ├── reflect.go │ ├── solve.go │ ├── stdlib_test.go │ ├── testdata │ │ ├── a_test.go │ │ ├── another.go │ │ ├── arrayreflect.go │ │ ├── arrays.go │ │ ├── channels.go │ │ ├── chanreflect.go │ │ ├── chanreflect1.go │ │ ├── context.go │ │ ├── conv.go │ │ ├── finalizer.go │ │ ├── flow.go │ │ ├── fmtexcerpt.go │ │ ├── func.go │ │ ├── funcreflect.go │ │ ├── hello.go │ │ ├── interfaces.go │ │ ├── issue9002.go │ │ ├── mapreflect.go │ │ ├── maps.go │ │ ├── panic.go │ │ ├── recur.go │ │ ├── reflect.go │ │ ├── rtti.go │ │ ├── structreflect.go │ │ ├── structs.go │ │ └── timer.go │ └── util.go ├── ssa │ ├── blockopt.go │ ├── builder.go │ ├── builder_test.go │ ├── const.go │ ├── create.go │ ├── doc.go │ ├── dom.go │ ├── emit.go │ ├── example_test.go │ ├── func.go │ ├── interp │ │ ├── external.go │ │ ├── external_darwin.go │ │ ├── external_freebsd.go │ │ ├── external_plan9.go │ │ ├── external_unix.go │ │ ├── external_windows.go │ │ ├── interp.go │ │ ├── interp_test.go │ │ ├── map.go │ │ ├── ops.go │ │ ├── reflect.go │ │ ├── testdata │ │ │ ├── a_test.go │ │ │ ├── b_test.go │ │ │ ├── boundmeth.go │ │ │ ├── callstack.go │ │ │ ├── complit.go │ │ │ ├── coverage.go │ │ │ ├── defer.go │ │ │ ├── fieldprom.go │ │ │ ├── ifaceconv.go │ │ │ ├── ifaceprom.go │ │ │ ├── initorder.go │ │ │ ├── methprom.go │ │ │ ├── mrvchain.go │ │ │ ├── range.go │ │ │ ├── recover.go │ │ │ └── static.go │ │ └── value.go │ ├── lift.go │ ├── lvalue.go │ ├── methods.go │ ├── print.go │ ├── sanity.go │ ├── source.go │ ├── source_test.go │ ├── ssa.go │ ├── ssautil │ │ ├── switch.go │ │ ├── switch_test.go │ │ ├── testdata │ │ │ └── switches.go │ │ └── visit.go │ ├── stdlib_test.go │ ├── testdata │ │ ├── objlookup.go │ │ └── valueforexpr.go │ ├── testmain.go │ ├── testmain_test.go │ ├── util.go │ └── wrappers.go ├── types │ ├── api.go │ ├── api_test.go │ ├── assignments.go │ ├── builtins.go │ ├── builtins_test.go │ ├── call.go │ ├── check.go │ ├── check_test.go │ ├── conversions.go │ ├── decl.go │ ├── errors.go │ ├── eval.go │ ├── eval_test.go │ ├── expr.go │ ├── exprstring.go │ ├── exprstring_test.go │ ├── go11.go │ ├── go12.go │ ├── hilbert_test.go │ ├── initorder.go │ ├── issues_test.go │ ├── labels.go │ ├── lookup.go │ ├── methodset.go │ ├── methodsetcache.go │ ├── object.go │ ├── objset.go │ ├── operand.go │ ├── ordering.go │ ├── package.go │ ├── predicates.go │ ├── resolver.go │ ├── resolver_test.go │ ├── return.go │ ├── scope.go │ ├── selection.go │ ├── self_test.go │ ├── sizes.go │ ├── stdlib_test.go │ ├── stmt.go │ ├── testdata │ │ ├── blank.src │ │ ├── builtins.src │ │ ├── const0.src │ │ ├── const1.src │ │ ├── constdecl.src │ │ ├── conversions.src │ │ ├── cycles.src │ │ ├── cycles1.src │ │ ├── cycles2.src │ │ ├── cycles3.src │ │ ├── cycles4.src │ │ ├── decls0.src │ │ ├── decls1.src │ │ ├── decls2a.src │ │ ├── decls2b.src │ │ ├── decls3.src │ │ ├── errors.src │ │ ├── expr0.src │ │ ├── expr1.src │ │ ├── expr2.src │ │ ├── expr3.src │ │ ├── gotos.src │ │ ├── importdecl0a.src │ │ ├── importdecl0b.src │ │ ├── importdecl1a.src │ │ ├── importdecl1b.src │ │ ├── init0.src │ │ ├── init1.src │ │ ├── init2.src │ │ ├── issues.src │ │ ├── labels.src │ │ ├── methodsets.src │ │ ├── shifts.src │ │ ├── stmt0.src │ │ ├── stmt1.src │ │ └── vardecl.src │ ├── token_test.go │ ├── type.go │ ├── typestring.go │ ├── typestring_test.go │ ├── typeutil │ │ ├── imports.go │ │ ├── imports_test.go │ │ ├── map.go │ │ ├── map_test.go │ │ └── ui.go │ ├── typexpr.go │ └── universe.go └── vcs │ ├── discovery.go │ ├── env.go │ ├── http.go │ ├── vcs.go │ └── vcs_test.go ├── godoc ├── analysis │ ├── README │ ├── analysis.go │ ├── callgraph.go │ ├── implements.go │ ├── json.go │ ├── peers.go │ └── typeinfo.go ├── cmdline.go ├── cmdline_test.go ├── corpus.go ├── dirtrees.go ├── format.go ├── godoc.go ├── godoc_test.go ├── index.go ├── index_test.go ├── linkify.go ├── meta.go ├── page.go ├── parser.go ├── pres.go ├── redirect │ └── redirect.go ├── search.go ├── server.go ├── server_test.go ├── snippet.go ├── spec.go ├── spot.go ├── static │ ├── analysis │ │ ├── call-eg.png │ │ ├── call3.png │ │ ├── callers1.png │ │ ├── callers2.png │ │ ├── chan1.png │ │ ├── chan2a.png │ │ ├── chan2b.png │ │ ├── error1.png │ │ ├── help.html │ │ ├── ident-def.png │ │ ├── ident-field.png │ │ ├── ident-func.png │ │ ├── ipcg-func.png │ │ ├── ipcg-pkg.png │ │ ├── typeinfo-pkg.png │ │ └── typeinfo-src.png │ ├── callgraph.html │ ├── codewalk.html │ ├── codewalkdir.html │ ├── dirlist.html │ ├── doc.go │ ├── error.html │ ├── example.html │ ├── gen.go │ ├── godoc.html │ ├── godocs.js │ ├── images │ │ ├── minus.gif │ │ ├── plus.gif │ │ ├── treeview-black-line.gif │ │ ├── treeview-black.gif │ │ ├── treeview-default-line.gif │ │ ├── treeview-default.gif │ │ ├── treeview-gray-line.gif │ │ └── treeview-gray.gif │ ├── implements.html │ ├── jquery.js │ ├── jquery.treeview.css │ ├── jquery.treeview.edit.js │ ├── jquery.treeview.js │ ├── makestatic.go │ ├── methodset.html │ ├── opensearch.xml │ ├── package.html │ ├── package.txt │ ├── play.js │ ├── playground.js │ ├── search.html │ ├── search.txt │ ├── searchcode.html │ ├── searchdoc.html │ ├── searchtxt.html │ ├── static.go │ └── style.css ├── tab.go ├── template.go ├── util │ ├── throttle.go │ └── util.go └── vfs │ ├── gatefs │ └── gatefs.go │ ├── httpfs │ └── httpfs.go │ ├── mapfs │ ├── mapfs.go │ └── mapfs_test.go │ ├── namespace.go │ ├── os.go │ ├── vfs.go │ └── zipfs │ └── zipfs.go ├── imports ├── fix.go ├── fix_test.go ├── imports.go ├── mkindex.go ├── mkstdlib.go ├── sortimports.go ├── sortimports_compat.go └── zstdlib.go ├── oracle ├── TODO ├── callees.go ├── callers.go ├── callgraph.go ├── callstack.go ├── definition.go ├── describe.go ├── freevars.go ├── implements.go ├── oracle.go ├── oracle_test.go ├── peers.go ├── pointsto.go ├── pos.go ├── referrers.go ├── serial │ └── serial.go ├── testdata │ └── src │ │ ├── lib │ │ └── lib.go │ │ └── main │ │ ├── callgraph-json.go │ │ ├── callgraph-json.golden │ │ ├── callgraph.go │ │ ├── callgraph.golden │ │ ├── callgraph2.go │ │ ├── callgraph2.golden │ │ ├── calls-json.go │ │ ├── calls-json.golden │ │ ├── calls.go │ │ ├── calls.golden │ │ ├── describe-json.go │ │ ├── describe-json.golden │ │ ├── describe.go │ │ ├── describe.golden │ │ ├── freevars.go │ │ ├── freevars.golden │ │ ├── implements-json.go │ │ ├── implements-json.golden │ │ ├── implements.go │ │ ├── implements.golden │ │ ├── imports.go │ │ ├── imports.golden │ │ ├── multi.go │ │ ├── peers-json.go │ │ ├── peers-json.golden │ │ ├── peers.go │ │ ├── peers.golden │ │ ├── pointsto-json.go │ │ ├── pointsto-json.golden │ │ ├── pointsto.go │ │ ├── pointsto.golden │ │ ├── referrers-json.go │ │ ├── referrers-json.golden │ │ ├── reflection.go │ │ ├── reflection.golden │ │ ├── what-json.go │ │ ├── what-json.golden │ │ ├── what.go │ │ └── what.golden └── what.go ├── playground ├── appengine.go ├── common.go ├── local.go └── socket │ └── socket.go ├── present ├── args.go ├── caption.go ├── code.go ├── doc.go ├── html.go ├── iframe.go ├── image.go ├── link.go ├── link_test.go ├── parse.go ├── style.go └── style_test.go └── refactor ├── README ├── eg ├── eg.go ├── eg_test.go ├── match.go ├── rewrite.go └── testdata │ ├── A.template │ ├── A1.go │ ├── A1.golden │ ├── A2.go │ ├── A2.golden │ ├── B.template │ ├── B1.go │ ├── B1.golden │ ├── C.template │ ├── C1.go │ ├── C1.golden │ ├── D.template │ ├── D1.go │ ├── D1.golden │ ├── E.template │ ├── E1.go │ ├── E1.golden │ ├── F.template │ ├── F1.go │ ├── F1.golden │ ├── bad_type.template │ ├── expr_type_mismatch.template │ ├── no_after_return.template │ ├── no_before.template │ └── type_mismatch.template ├── importgraph ├── graph.go └── graph_test.go ├── lexical ├── lexical.go └── lexical_test.go ├── rename ├── check.go ├── rename.el ├── rename.go ├── rename_test.go ├── spec.go └── util.go └── satisfy └── find.go /go.mod: -------------------------------------------------------------------------------- 1 | module src/utils/time 2 | 3 | go 1.20 4 | -------------------------------------------------------------------------------- /gobook/gobook-1.0.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/gobook/gobook-1.0.tar.gz -------------------------------------------------------------------------------- /gobook/goeg/src/americanise/expected.txt: -------------------------------------------------------------------------------- 1 | This is just some test text. It contains some of the British words that 2 | have different spellings in American English, such as behavior, color, 3 | favorite, labor, and neighbor. 4 | 5 | In fact the differences between British and American spellings aren't 6 | that great. Some British words that end with "our" get "or" endings in 7 | American English, and similarly for "re" to "er" (for example "Center" 8 | becomes "Center"), and "ogue" becomes "og" as with dialog and 9 | catalog. 10 | 11 | There are also a few more obscure changes, such as "ence" to "ense", for 12 | example "defense" becomes "defense". And there are a few miscellaneous 13 | differences, such as for anemia, hemorrhage, aluminum, check, curb, 14 | tire, sulfur, and maneuver. 15 | -------------------------------------------------------------------------------- /gobook/goeg/src/americanise/input.txt: -------------------------------------------------------------------------------- 1 | This is just some test text. It contains some of the British words that 2 | have different spellings in American English, such as behaviour, colour, 3 | favourite, labour, and neighbour. 4 | 5 | In fact the differences between British and American spellings aren't 6 | that great. Some British words that end with "our" get "or" endings in 7 | American English, and similarly for "re" to "er" (for example "Centre" 8 | becomes "Center"), and "ogue" becomes "og" as with dialogue and 9 | catalogue. 10 | 11 | There are also a few more obscure changes, such as "ence" to "ense", for 12 | example "defence" becomes "defense". And there are a few miscellaneous 13 | differences, such as for anaemia, haemorrhage, aluminium, cheque, kerb, 14 | tyre, sulphur, and manoeuvre. 15 | -------------------------------------------------------------------------------- /gobook/goeg/src/bigdigits/0123456789.txt: -------------------------------------------------------------------------------- 1 | 000 1 222 333 4 55555 666 77777 888 9999 2 | 0 0 11 2 2 3 3 44 5 6 7 8 8 9 9 3 | 0 0 1 2 3 4 4 5 6 7 8 8 9 9 4 | 0 0 1 2 33 4 4 555 6666 7 888 9999 5 | 0 0 1 2 3 444444 5 6 6 7 8 8 9 6 | 0 0 1 2 3 3 4 5 5 6 6 7 8 8 9 7 | 000 111 22222 333 4 555 666 7 888 9 8 | -------------------------------------------------------------------------------- /gobook/goeg/src/bigdigits_ans/0123456789.txt: -------------------------------------------------------------------------------- 1 | ********************************************************************* 2 | 000 1 222 333 4 55555 666 77777 888 9999 3 | 0 0 11 2 2 3 3 44 5 6 7 8 8 9 9 4 | 0 0 1 2 3 4 4 5 6 7 8 8 9 9 5 | 0 0 1 2 33 4 4 555 6666 7 888 9999 6 | 0 0 1 2 3 444444 5 6 6 7 8 8 9 7 | 0 0 1 2 3 3 4 5 5 6 6 7 8 8 9 8 | 000 111 22222 333 4 555 666 7 888 9 9 | ********************************************************************* 10 | -------------------------------------------------------------------------------- /gobook/goeg/src/cgrep3/util_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2011-12 Qtrac Ltd. 2 | // 3 | // This program or package and any associated files are licensed under the 4 | // Apache License, Version 2.0 (the "License"); you may not use these files 5 | // except in compliance with the License. You can get a copy of the License 6 | // at: http://www.apache.org/licenses/LICENSE-2.0. 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package main 15 | 16 | func commandLineFiles(files []string) []string { return files } 17 | -------------------------------------------------------------------------------- /gobook/goeg/src/cgrep3/util_freebsd.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2011-12 Qtrac Ltd. 2 | // 3 | // This program or package and any associated files are licensed under the 4 | // Apache License, Version 2.0 (the "License"); you may not use these files 5 | // except in compliance with the License. You can get a copy of the License 6 | // at: http://www.apache.org/licenses/LICENSE-2.0. 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package main 15 | 16 | func commandLineFiles(files []string) []string { return files } 17 | -------------------------------------------------------------------------------- /gobook/goeg/src/cgrep3/util_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright © 2011-12 Qtrac Ltd. 2 | // 3 | // This program or package and any associated files are licensed under the 4 | // Apache License, Version 2.0 (the "License"); you may not use these files 5 | // except in compliance with the License. You can get a copy of the License 6 | // at: http://www.apache.org/licenses/LICENSE-2.0. 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | 14 | package main 15 | 16 | func commandLineFiles(files []string) []string { return files } 17 | -------------------------------------------------------------------------------- /gobook/goeg/src/invoicedata/invoices.gob.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/gobook/goeg/src/invoicedata/invoices.gob.gz -------------------------------------------------------------------------------- /gobook/goeg/src/linkcheck/linkutil/index.links: -------------------------------------------------------------------------------- 1 | #top 2 | about.html 3 | alt_key.html 4 | alt_key_api.html 5 | aqpbook.html 6 | comparepdf.html 7 | diffpdf.html 8 | gobook.html 9 | http://code.google.com/p/optarg/ 10 | http://endsoftpatents.org/innovating-without-patents 11 | http://golang.org 12 | http://ptgmedia.pearsoncmg.com/imprint_downloads/informit/promotions/python/python2python3.pdf 13 | http://savannah.nongnu.org/projects/lout/ 14 | http://www.froglogic.com 15 | mailto:mark@qtrac.eu 16 | marksummerfield.html 17 | py3book.html 18 | pyqtbook.html 19 | -------------------------------------------------------------------------------- /gobook/goeg/src/soundex/soundex-test-data.txt: -------------------------------------------------------------------------------- 1 | A226 Ashcraft 2 | A226 Ashcroft 3 | B622 Burroughs 4 | B620 Burrows 5 | C532 Ciondecks 6 | E460 Ellery 7 | E460 Euler 8 | E251 Example 9 | G200 Gauss 10 | G200 Ghosh 11 | H416 Heilbronn 12 | H416 Hilbert 13 | K530 Kant 14 | K530 Knuth 15 | L300 Ladd 16 | L222 Lissajous 17 | L300 Lloyd 18 | L222 Lukasiewicz 19 | O600 O'Hara 20 | R163 Robert 21 | R150 Rubin 22 | R163 Rupert 23 | S532 Soundex 24 | T522 Tymczak 25 | W350 Wheaton 26 | -------------------------------------------------------------------------------- /gobook/goeg/src/utf16-to-utf8/utf-16-be.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/gobook/goeg/src/utf16-to-utf8/utf-16-be.txt -------------------------------------------------------------------------------- /gobook/goeg/src/utf16-to-utf8/utf-16-le.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/gobook/goeg/src/utf16-to-utf8/utf-16-le.txt -------------------------------------------------------------------------------- /helloworld/go.mod: -------------------------------------------------------------------------------- 1 | module example.com/m 2 | 3 | go 1.16 4 | 5 | require ( 6 | example.com/greetings v0.0.0-00010101000000-000000000000 7 | github.com/gerryyang/goinaction/module/hello v0.0.0-20210323092231-9586d180a662 // indirect 8 | rsc.io/quote v1.5.2 9 | ) 10 | 11 | replace example.com/greetings => ./greetings 12 | -------------------------------------------------------------------------------- /helloworld/greetings/go.mod: -------------------------------------------------------------------------------- 1 | module example.com/greetings 2 | 3 | go 1.16 4 | -------------------------------------------------------------------------------- /module/hello/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/gerryyang/goinaction/module/hello 2 | 3 | go 1.16 4 | 5 | require ( 6 | golang.org/x/text v0.3.5 // indirect 7 | rsc.io/quote/v3 v3.1.0 8 | rsc.io/sampler v1.3.1 // indirect 9 | ) 10 | -------------------------------------------------------------------------------- /module/hello/go.sum: -------------------------------------------------------------------------------- 1 | golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 2 | golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= 3 | golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 4 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 5 | rsc.io/quote/v3 v3.1.0 h1:9JKUTTIUgS6kzR9mK1YuGKv6Nl+DijDNIc0ghT58FaY= 6 | rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= 7 | rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= 8 | rsc.io/sampler v1.3.1 h1:F0c3J2nQCdk9ODsNhU3sElnvPIxM/xV1c/qZuAeZmac= 9 | rsc.io/sampler v1.3.1/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= 10 | -------------------------------------------------------------------------------- /module/hello/hello.go: -------------------------------------------------------------------------------- 1 | package hello 2 | 3 | import ( 4 | //"rsc.io/quote" 5 | quoteV3 "rsc.io/quote/v3" 6 | ) 7 | 8 | func Hello() string { 9 | //return "Hello, world." 10 | //return quote.Hello() 11 | return quoteV3.HelloV3() 12 | } 13 | 14 | func Proverb() string { 15 | return quoteV3.Concurrency() 16 | } 17 | 18 | -------------------------------------------------------------------------------- /module/hello/hello_test.go: -------------------------------------------------------------------------------- 1 | package hello 2 | 3 | import "testing" 4 | 5 | func TestHello(t *testing.T) { 6 | want := "Hello, world." 7 | if got := Hello(); got != want { 8 | t.Errorf("Hello() = %q, want %q", got, want) 9 | } 10 | } 11 | 12 | func TestProverb(t *testing.T) { 13 | want := "Concurrency is not parallelism." 14 | if got := Proverb(); got != want { 15 | t.Errorf("Proverb() = %q, want %q", got, want) 16 | } 17 | } 18 | 19 | -------------------------------------------------------------------------------- /module/hello/world/world.go: -------------------------------------------------------------------------------- 1 | package world 2 | 3 | func World() string { 4 | return "world" 5 | } 6 | 7 | -------------------------------------------------------------------------------- /module/hello/world/world_test.go: -------------------------------------------------------------------------------- 1 | package world 2 | 3 | import "testing" 4 | 5 | func TestWorld(t *testing.T) { 6 | want := "world" 7 | if got := World(); got != want { 8 | t.Errorf("World() = %q, want %q", got, want) 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /performance/test1/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/gerryyang/goinaction/performance/test1 2 | 3 | go 1.20 4 | -------------------------------------------------------------------------------- /performance/test1/test1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/performance/test1/test1 -------------------------------------------------------------------------------- /performance/test2/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/gerryyang/goinaction/performance/test2 2 | 3 | go 1.20 4 | -------------------------------------------------------------------------------- /programming_in_go/bin/file_demo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/programming_in_go/bin/file_demo -------------------------------------------------------------------------------- /programming_in_go/pkg/darwin_amd64/github.com/astaxie/bat/httplib.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/programming_in_go/pkg/darwin_amd64/github.com/astaxie/bat/httplib.a -------------------------------------------------------------------------------- /programming_in_go/pkg/darwin_amd64/github.com/tools/godep/Godeps/_workspace/src/github.com/kr/fs.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/programming_in_go/pkg/darwin_amd64/github.com/tools/godep/Godeps/_workspace/src/github.com/kr/fs.a -------------------------------------------------------------------------------- /programming_in_go/pkg/darwin_amd64/github.com/tools/godep/Godeps/_workspace/src/github.com/kr/pretty.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/programming_in_go/pkg/darwin_amd64/github.com/tools/godep/Godeps/_workspace/src/github.com/kr/pretty.a -------------------------------------------------------------------------------- /programming_in_go/pkg/darwin_amd64/github.com/tools/godep/Godeps/_workspace/src/github.com/kr/text.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/programming_in_go/pkg/darwin_amd64/github.com/tools/godep/Godeps/_workspace/src/github.com/kr/text.a -------------------------------------------------------------------------------- /programming_in_go/pkg/darwin_amd64/github.com/tools/godep/Godeps/_workspace/src/github.com/pmezard/go-difflib/difflib.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/programming_in_go/pkg/darwin_amd64/github.com/tools/godep/Godeps/_workspace/src/github.com/pmezard/go-difflib/difflib.a -------------------------------------------------------------------------------- /programming_in_go/pkg/darwin_amd64/github.com/tools/godep/Godeps/_workspace/src/golang.org/x/tools/go/vcs.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/programming_in_go/pkg/darwin_amd64/github.com/tools/godep/Godeps/_workspace/src/golang.org/x/tools/go/vcs.a -------------------------------------------------------------------------------- /programming_in_go/pkg/darwin_amd64/stacker/stack.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/programming_in_go/pkg/darwin_amd64/stacker/stack.a -------------------------------------------------------------------------------- /programming_in_go/src/americanise/expected.txt: -------------------------------------------------------------------------------- 1 | This is just some test text. It contains some of the British words that 2 | have different spellings in American English, such as behavior, color, 3 | favorite, labor, and neighbor. 4 | 5 | In fact the differences between British and American spellings aren't 6 | that great. Some British words that end with "our" get "or" endings in 7 | American English, and similarly for "re" to "er" (for example "Center" 8 | becomes "Center"), and "ogue" becomes "og" as with dialog and 9 | catalog. 10 | 11 | There are also a few more obscure changes, such as "ence" to "ense", for 12 | example "defense" becomes "defense". And there are a few miscellaneous 13 | differences, such as for anemia, hemorrhage, aluminum, check, curb, 14 | tire, sulfur, and maneuver. 15 | -------------------------------------------------------------------------------- /programming_in_go/src/americanise/input.txt: -------------------------------------------------------------------------------- 1 | This is just some test text. It contains some of the British words that 2 | have different spellings in American English, such as behaviour, colour, 3 | favourite, labour, and neighbour. 4 | 5 | In fact the differences between British and American spellings aren't 6 | that great. Some British words that end with "our" get "or" endings in 7 | American English, and similarly for "re" to "er" (for example "Centre" 8 | becomes "Center"), and "ogue" becomes "og" as with dialogue and 9 | catalogue. 10 | 11 | There are also a few more obscure changes, such as "ence" to "ense", for 12 | example "defence" becomes "defense". And there are a few miscellaneous 13 | differences, such as for anaemia, haemorrhage, aluminium, cheque, kerb, 14 | tyre, sulphur, and manoeuvre. 15 | -------------------------------------------------------------------------------- /programming_in_go/src/bigdigits/0123456789.txt: -------------------------------------------------------------------------------- 1 | 000 1 222 333 4 55555 666 77777 888 9999 2 | 0 0 11 2 2 3 3 44 5 6 7 8 8 9 9 3 | 0 0 1 2 3 4 4 5 6 7 8 8 9 9 4 | 0 0 1 2 33 4 4 555 6666 7 888 9999 5 | 0 0 1 2 3 444444 5 6 6 7 8 8 9 6 | 0 0 1 2 3 3 4 5 5 6 6 7 8 8 9 7 | 000 111 22222 333 4 555 666 7 888 9 8 | -------------------------------------------------------------------------------- /src/MySQL/mysql_client/src/github.com/go-sql-driver/mysql/.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Issue description 2 | Tell us what should happen and what happens instead 3 | 4 | ### Example code 5 | ```go 6 | If possible, please enter some example code here to reproduce the issue. 7 | ``` 8 | 9 | ### Error log 10 | ``` 11 | If you have an error log, please paste it here. 12 | ``` 13 | 14 | ### Configuration 15 | *Driver version (or git SHA):* 16 | 17 | *Go version:* run `go version` in your console 18 | 19 | *Server version:* E.g. MySQL 5.6, MariaDB 10.0.20 20 | 21 | *Server OS:* E.g. Debian 8.1 (Jessie), Windows 10 22 | -------------------------------------------------------------------------------- /src/MySQL/mysql_client/src/github.com/go-sql-driver/mysql/.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Description 2 | Please explain the changes you made here. 3 | 4 | ### Checklist 5 | - [ ] Code compiles correctly 6 | - [ ] Created tests which fail without the change (if possible) 7 | - [ ] All tests passing 8 | - [ ] Extended the README / documentation, if necessary 9 | - [ ] Added myself / the copyright holder to the AUTHORS file 10 | -------------------------------------------------------------------------------- /src/MySQL/mysql_client/src/github.com/go-sql-driver/mysql/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .DS_Store? 3 | ._* 4 | .Spotlight-V100 5 | .Trashes 6 | Icon? 7 | ehthumbs.db 8 | Thumbs.db 9 | -------------------------------------------------------------------------------- /src/MySQL/mysql_client/src/github.com/go-sql-driver/mysql/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | go: 4 | - 1.2 5 | - 1.3 6 | - 1.4 7 | - 1.5 8 | - 1.6 9 | - 1.7 10 | - tip 11 | 12 | before_script: 13 | - mysql -e 'create database gotest;' 14 | -------------------------------------------------------------------------------- /src/MySQL/mysql_client/src/github.com/go-sql-driver/mysql/appengine.go: -------------------------------------------------------------------------------- 1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package 2 | // 3 | // Copyright 2013 The Go-MySQL-Driver Authors. All rights reserved. 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 7 | // You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | // +build appengine 10 | 11 | package mysql 12 | 13 | import ( 14 | "appengine/cloudsql" 15 | ) 16 | 17 | func init() { 18 | RegisterDial("cloudsql", cloudsql.Dial) 19 | } 20 | -------------------------------------------------------------------------------- /src/MySQL/mysql_client/src/github.com/go-sql-driver/mysql/result.go: -------------------------------------------------------------------------------- 1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package 2 | // 3 | // Copyright 2012 The Go-MySQL-Driver Authors. All rights reserved. 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 7 | // You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | package mysql 10 | 11 | type mysqlResult struct { 12 | affectedRows int64 13 | insertId int64 14 | } 15 | 16 | func (res *mysqlResult) LastInsertId() (int64, error) { 17 | return res.insertId, nil 18 | } 19 | 20 | func (res *mysqlResult) RowsAffected() (int64, error) { 21 | return res.affectedRows, nil 22 | } 23 | -------------------------------------------------------------------------------- /src/MySQL/mysql_client/src/github.com/readline/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | script: 3 | - go test -v 4 | -------------------------------------------------------------------------------- /src/MySQL/mysql_client/src/github.com/readline/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2013-03-25 2 | ---------- 3 | - initial -------------------------------------------------------------------------------- /src/MySQL/mysql_client/src/github.com/readline/readline.go: -------------------------------------------------------------------------------- 1 | package readline 2 | 3 | import ( 4 | "bufio" 5 | "bytes" 6 | "io" 7 | ) 8 | 9 | func ReadLine(reader io.Reader, f func(string)) { 10 | buf := bufio.NewReader(reader) 11 | line, err := buf.ReadBytes('\n') 12 | for err == nil { 13 | line = bytes.TrimRight(line, "\n") 14 | if len(line) > 0 { 15 | if line[len(line)-1] == 13 { //'\r' 16 | line = bytes.TrimRight(line, "\r") 17 | } 18 | f(string(line)) 19 | } 20 | line, err = buf.ReadBytes('\n') 21 | } 22 | 23 | if len(line) > 0 { 24 | f(string(line)) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/MySQL/mysql_client/src/init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export GOPATH=../mysql_client 4 | echo "init done" 5 | -------------------------------------------------------------------------------- /src/NoSQL/ssdb_client/README.md: -------------------------------------------------------------------------------- 1 | 2 | # SSDB - A fast NoSQL database for storing big list of data 3 | 4 | SDB is a high performace key-value(key-string, key-zset, key-hashmap) NoSQL database, an alternative to Redis. 5 | 6 | SSDB is stable, production-ready and is widely used by many Internet companies including QIHU 360. 7 | 8 | https://github.com/ideawu/ssdb 9 | 10 | -------------------------------------------------------------------------------- /src/NoSQL/ssdb_client/v2/README.md: -------------------------------------------------------------------------------- 1 | 2 | #SSDB Go API DEMO 3 | 4 | refer to: 5 | 6 | [1] http://eng.42go.com/scala-vs-go-tcp-benchmark/ 7 | 8 | [2] https://github.com/ssdb/gossdb 9 | 10 | [3] http://ssdb.io/docs/go/index.html 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/cgo/inc/hello.h: -------------------------------------------------------------------------------- 1 | // hello.h 2 | 3 | #ifndef HELLO_H 4 | #define HELLO_H 5 | 6 | #include 7 | 8 | void hello(const char *name); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/cgo/src/hello.c: -------------------------------------------------------------------------------- 1 | // hello.c 2 | 3 | #include "hello.h" 4 | 5 | void hello(const char *name) 6 | { 7 | printf("say hello to %s\n", name); 8 | return; 9 | } 10 | -------------------------------------------------------------------------------- /src/cgo/src/main.c: -------------------------------------------------------------------------------- 1 | // main.c 2 | 3 | #include "hello.h" 4 | 5 | int main(int argc, char **argv) 6 | { 7 | hello("gerry"); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /src/channel/channel_buf.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func main() { 8 | // 创建一个channel用以同步goroutine 9 | done := make(chan bool, 2) 10 | count := 3 11 | 12 | for i := 0; i < count; i++ { 13 | 14 | // 在goroutine中执行输出操作 15 | go func(i int) { 16 | done <- true 17 | fmt.Println("goroutine message:", i) 18 | 19 | }(i) 20 | } 21 | 22 | <-done // 等待goroutine结束 23 | fmt.Println("main function message") 24 | } 25 | 26 | /* 27 | output: 28 | gerryyang@mba:channel$./channel_buf 29 | goroutine message: 0 30 | goroutine message: 1 31 | main function message 32 | 33 | 说明:有buffer的channel, 假设管道buffer的大小为n, 则可以连续写管道n次(非阻塞), 否则会deadlock, 读管道同理 34 | */ 35 | -------------------------------------------------------------------------------- /src/channel/channel_nobuf.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | // 创建一个channel用以同步goroutine 10 | done := make(chan bool) 11 | count := 3 12 | 13 | for i := 0; i < count; i++ { 14 | 15 | // 在goroutine中执行输出操作 16 | go func(i int) { 17 | time.Sleep(time.Duration(i) * time.Second) 18 | fmt.Println("goroutine message:", i) 19 | 20 | // 告诉main函数执行完毕. 21 | // 这个channel在goroutine中是可见的 22 | // 因为它是在相同的地址空间执行的. 23 | done <- true 24 | }(i) 25 | } 26 | 27 | <-done // 等待goroutine结束 28 | fmt.Println("main function message") 29 | } 30 | 31 | /* 32 | output: 33 | gerryyang@mba:channel$./channel_nobuf 34 | goroutine message: 0 35 | main function message 36 | 37 | 说明:没有buffer的channel, 写管道会被阻塞, 写管道和读管道的数量必须匹配, 否则会deadlock 38 | */ 39 | -------------------------------------------------------------------------------- /src/exec/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/gerryyang/goinaction/src/exec 2 | 3 | go 1.20 4 | -------------------------------------------------------------------------------- /src/file_scp/README: -------------------------------------------------------------------------------- 1 | file_scp is like scp(secure copy, remote file copy program) but uses golang to copies files between hosts on a network. 2 | 3 | use dd cmd to create 100M data.txt like: 4 | dd if=/dev/zero of=test bs=1M count=100 5 | 6 | file compare may use following way: 7 | 8 | cmp f1 f2 9 | 10 | od -N 32 -t x1 file 11 | 12 | hexdump file | head 13 | 14 | md5sum file1 file2 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/file_scp/data.txt: -------------------------------------------------------------------------------- 1 | aaaaaaaaaaaa 2 | bbbbbbbbbbbb 3 | -------------------------------------------------------------------------------- /src/godep_test/src/app/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | foo "lib/foolib" 6 | ) 7 | 8 | func main() { 9 | fmt.Println(foo.Add(1, 2)) 10 | } 11 | -------------------------------------------------------------------------------- /src/godep_test/src/lib/foolib/foo.go: -------------------------------------------------------------------------------- 1 | package foo 2 | 3 | func Add(a, b int) int { 4 | return a + b 5 | } 6 | -------------------------------------------------------------------------------- /src/http/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # 代码说明 4 | 5 | * httpc: http相关的库代码 6 | * http_svr: http服务器 7 | * https_client: https客户端 8 | * https_server: https服务端 9 | * https_proxy: https代理 10 | * cert: 测试https使用的`x509.Certificate` 11 | 12 | -------------------------------------------------------------------------------- /src/http/cert/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | * Generate private key (.key) 4 | 5 | ``` 6 | # Key considerations for algorithm "RSA" ≥ 2048-bit 7 | openssl genrsa -out server.key 2048 8 | ``` 9 | 10 | * Generation of self-signed(x509) public key (PEM-encodings .pem|.crt) based on the private (.key) 11 | 12 | ``` 13 | openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650 14 | 15 | openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650 -subj /CN=localhost 16 | ``` 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/http/http_svr/http_svr_v2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | ) 7 | 8 | type MyMux struct { 9 | } 10 | 11 | func (p *MyMux) ServeHTTP(w http.ResponseWriter, r *http.Request) { 12 | if r.URL.Path == "/" { 13 | sayhelloName(w, r) 14 | return 15 | } 16 | http.NotFound(w, r) 17 | return 18 | } 19 | 20 | func sayhelloName(w http.ResponseWriter, r *http.Request) { 21 | fmt.Fprintf(w, "Hello gerryyang, from GoLang HTTP svr v2!\n") 22 | } 23 | 24 | func main() { 25 | mux := &MyMux{} 26 | http.ListenAndServe(":9090", mux) 27 | } 28 | -------------------------------------------------------------------------------- /src/http/https_proxy/gen_self_signed_cert.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | case `uname -s` in 4 | Linux*) sslConfig=/etc/ssl/openssl.cnf;; 5 | Darwin*) sslConfig=/System/Library/OpenSSL/openssl.cnf;; 6 | esac 7 | openssl req \ 8 | -newkey rsa:2048 \ 9 | -x509 \ 10 | -nodes \ 11 | -keyout server.key \ 12 | -new \ 13 | -out server.pem \ 14 | -subj /CN=localhost \ 15 | -reqexts SAN \ 16 | -extensions SAN \ 17 | -config <(cat $sslConfig \ 18 | <(printf '[SAN]\nsubjectAltName=DNS:localhost')) \ 19 | -sha256 \ 20 | -days 3650 21 | -------------------------------------------------------------------------------- /src/http/https_server/https_server.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | // "fmt" 5 | // "io" 6 | "net/http" 7 | "log" 8 | ) 9 | 10 | func HelloServer(w http.ResponseWriter, req *http.Request) { 11 | log.Printf("HelloServer") 12 | 13 | w.Header().Set("Content-Type", "text/plain") 14 | w.Write([]byte("This is an example server.\n")) 15 | // fmt.Fprintf(w, "This is an example server.\n") 16 | // io.WriteString(w, "This is an example server.\n") 17 | 18 | log.Printf("HelloServer end") 19 | } 20 | 21 | func main() { 22 | http.HandleFunc("/hello", HelloServer) 23 | err := http.ListenAndServeTLS(":443", "../cert/server.crt", "../cert/server.key", nil) 24 | if err != nil { 25 | log.Fatal("ListenAndServe: ", err) 26 | } 27 | } -------------------------------------------------------------------------------- /src/int64_bytes_convert/int64_bytes_convert.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "encoding/binary" 6 | ) 7 | 8 | func main() { 9 | var i int64 = 320 10 | buf := Int64ToBytes(i) 11 | fmt.Println(buf) 12 | fmt.Println(BytesToInt64(buf)) 13 | } 14 | 15 | func Int64ToBytes(i int64) []byte { 16 | var buf = make([]byte, 8) 17 | binary.LittleEndian.PutUint64(buf, uint64(i)) 18 | return buf 19 | } 20 | 21 | func BytesToInt64(buf []byte) int64 { 22 | return int64(binary.LittleEndian.Uint64(buf)) 23 | } 24 | -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/00changelog.i: -------------------------------------------------------------------------------- 1 |  dummy changelog to prevent using the old repo layout -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/branch: -------------------------------------------------------------------------------- 1 | default 2 | -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/cache/branchheads: -------------------------------------------------------------------------------- 1 | c3294304d93f48a37d3bed1d382882a9c2989f99 48 2 | c3294304d93f48a37d3bed1d382882a9c2989f99 default 3 | -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/cache/tags: -------------------------------------------------------------------------------- 1 | 48 c3294304d93f48a37d3bed1d382882a9c2989f99 5e9f5c0ed680689f0b60be9f3de398fd30d75dfb 2 | 3 | 4fbe6aadba231e838a449d340e43bdaab0bf85bd go.weekly.2012-02-07 4 | 5c22fbd77d91f54d76cdbdee05318699754c44cc go.weekly.2012-02-22 5 | -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/dirstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/dirstate -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/hgrc: -------------------------------------------------------------------------------- 1 | [paths] 2 | default = https://code.google.com/p/log4go/ 3 | -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/requires: -------------------------------------------------------------------------------- 1 | revlogv1 2 | fncache 3 | store 4 | dotencode 5 | -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/00changelog.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/00changelog.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/00manifest.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/00manifest.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/_l_i_c_e_n_s_e.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/_l_i_c_e_n_s_e.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/_makefile.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/_makefile.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/_r_e_a_d_m_e.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/_r_e_a_d_m_e.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/config.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/config.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/elog.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/elog.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/elog__config.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/elog__config.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/elog__filelog.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/elog__filelog.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/elog__socklog.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/elog__socklog.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/elog__test.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/elog__test.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/example.xml.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/example.xml.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/examples/_console_log_writer___manual.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/examples/_console_log_writer___manual.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/examples/_file_log_writer___manual.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/examples/_file_log_writer___manual.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/examples/_simple_net_log_server.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/examples/_simple_net_log_server.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/examples/_socket_log_writer___manual.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/examples/_socket_log_writer___manual.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/examples/_x_m_l_configuration_example.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/examples/_x_m_l_configuration_example.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/examples/example.xml.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/examples/example.xml.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/filelog.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/filelog.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/log4go.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/log4go.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/log4go/_makefile.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/log4go/_makefile.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/log4go/elog.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/log4go/elog.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/log4go/elog__config.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/log4go/elog__config.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/log4go/elog__filelog.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/log4go/elog__filelog.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/log4go/elog__socklog.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/log4go/elog__socklog.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/log4go/elog__test.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/log4go/elog__test.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/log4go/log4go.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/log4go/log4go.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/log4go/log4go__config.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/log4go/log4go__config.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/log4go/log4go__filelog.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/log4go/log4go__filelog.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/log4go/log4go__socklog.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/log4go/log4go__socklog.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/log4go/log4go__termlog.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/log4go/log4go__termlog.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/log4go/log4go__test.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/log4go/log4go__test.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/log4go/log4go__wrapper.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/log4go/log4go__wrapper.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/log4go__test.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/log4go__test.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/pattlog.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/pattlog.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/socklog.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/socklog.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/src/_makefile.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/src/_makefile.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/src/elog.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/src/elog.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/src/elog__config.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/src/elog__config.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/src/elog__filelog.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/src/elog__filelog.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/src/elog__socklog.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/src/elog__socklog.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/src/elog__test.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/src/elog__test.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/src/example.xml.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/src/example.xml.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/termlog.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/termlog.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/wrapper.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/wrapper.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/xmllog.go.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/xmllog.go.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/data/~2ehgtags.i: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/data/~2ehgtags.i -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/phaseroots: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/phaseroots -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/store/undo.phaseroots: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/store/undo.phaseroots -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/undo.bookmarks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/undo.bookmarks -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/undo.branch: -------------------------------------------------------------------------------- 1 | default -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/undo.desc: -------------------------------------------------------------------------------- 1 | 0 2 | pull 3 | https://code.google.com/p/log4go/ 4 | -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hg/undo.dirstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/log4go/.hg/undo.dirstate -------------------------------------------------------------------------------- /src/log4go/src/log4go/.hgtags: -------------------------------------------------------------------------------- 1 | 4fbe6aadba231e838a449d340e43bdaab0bf85bd go.weekly.2012-02-07 2 | 56168fd53249d639c25c74ced881fffb20d27be9 go.weekly.2012-02-22 3 | 56168fd53249d639c25c74ced881fffb20d27be9 go.weekly.2012-02-22 4 | 5c22fbd77d91f54d76cdbdee05318699754c44cc go.weekly.2012-02-22 5 | -------------------------------------------------------------------------------- /src/log4go/src/log4go/README: -------------------------------------------------------------------------------- 1 | Please see http://log4go.googlecode.com/ 2 | 3 | Installation: 4 | - Run `goinstall log4go.googlecode.com/hg` 5 | 6 | Usage: 7 | - Add the following import: 8 | import l4g "log4go.googlecode.com/hg" 9 | 10 | Acknowledgements: 11 | - pomack 12 | For providing awesome patches to bring log4go up to the latest Go spec 13 | -------------------------------------------------------------------------------- /src/log4go/src/log4go/examples/ConsoleLogWriter_Manual.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | import l4g "code.google.com/p/log4go" 8 | 9 | func main() { 10 | log := l4g.NewLogger() 11 | log.AddFilter("stdout", l4g.DEBUG, l4g.NewConsoleLogWriter()) 12 | log.Info("The time is now: %s", time.Now().Format("15:04:05 MST 2006/01/02")) 13 | } 14 | -------------------------------------------------------------------------------- /src/log4go/src/log4go/examples/SocketLogWriter_Manual.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | import l4g "code.google.com/p/log4go" 8 | 9 | func main() { 10 | log := l4g.NewLogger() 11 | log.AddFilter("network", l4g.FINEST, l4g.NewSocketLogWriter("udp", "192.168.1.255:12124")) 12 | 13 | // Run `nc -u -l -p 12124` or similar before you run this to see the following message 14 | log.Info("The time is now: %s", time.Now().Format("15:04:05 MST 2006/01/02")) 15 | 16 | // This makes sure the output stream buffer is written 17 | log.Close() 18 | } 19 | -------------------------------------------------------------------------------- /src/log4go/src/log4go/examples/XMLConfigurationExample.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import l4g "code.google.com/p/log4go" 4 | 5 | func main() { 6 | // Load the configuration (isn't this easy?) 7 | l4g.LoadConfiguration("example.xml") 8 | 9 | // And now we're ready! 10 | l4g.Finest("This will only go to those of you really cool UDP kids! If you change enabled=true.") 11 | l4g.Debug("Oh no! %d + %d = %d!", 2, 2, 2+2) 12 | l4g.Info("About that time, eh chaps?") 13 | } 14 | -------------------------------------------------------------------------------- /src/log4go/src/source-archive.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/src/log4go/src/source-archive.zip -------------------------------------------------------------------------------- /src/race_check/README.md: -------------------------------------------------------------------------------- 1 | 2 | 测试输出: 3 | 4 | ``` 5 | ./main 6 | ================== 7 | WARNING: DATA RACE 8 | Read at 0x000001216848 by goroutine 9: 9 | main.main.func1() 10 | /Users/gerry/Proj/github/goinaction/src/race_check/main.go:16 +0x32 11 | 12 | Previous write at 0x000001216848 by goroutine 6: 13 | main.main.func1() 14 | /Users/gerry/Proj/github/goinaction/src/race_check/main.go:16 +0x4a 15 | 16 | Goroutine 9 (running) created at: 17 | main.main() 18 | /Users/gerry/Proj/github/goinaction/src/race_check/main.go:15 +0x64 19 | 20 | Goroutine 6 (running) created at: 21 | main.main() 22 | /Users/gerry/Proj/github/goinaction/src/race_check/main.go:15 +0x64 23 | ================== 24 | Counter: 990 25 | Found 1 data race(s) 26 | ``` -------------------------------------------------------------------------------- /src/race_check/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | go build -race main.go -------------------------------------------------------------------------------- /src/race_check/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "sync" 6 | ) 7 | 8 | var counter int 9 | 10 | func main() { 11 | var wg sync.WaitGroup 12 | 13 | for i := 0; i < 1000; i++ { 14 | wg.Add(1) 15 | go func() { 16 | counter++ 17 | wg.Done() 18 | }() 19 | } 20 | 21 | wg.Wait() 22 | fmt.Println("Counter:", counter) 23 | } 24 | -------------------------------------------------------------------------------- /src/reflect/demo2_test.go: -------------------------------------------------------------------------------- 1 | package demo 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | "testing" 7 | ) 8 | 9 | type Student2 struct { 10 | Name string `json:"name1" db:"name2"` 11 | Age int `json:"age1" db:"age2"` 12 | } 13 | 14 | func Test2(t *testing.T) { 15 | var s Student2 16 | v := reflect.ValueOf(&s) 17 | 18 | // 类型 19 | ty := v.Type() 20 | 21 | // 获取字段 22 | for i := 0; i < ty.Elem().NumField(); i++ { 23 | f := ty.Elem().Field(i) 24 | fmt.Println(f.Tag.Get("json")) 25 | fmt.Println(f.Tag.Get("db")) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/reflect/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/gerryyang/goinaction/src/reflect 2 | 3 | go 1.20 4 | -------------------------------------------------------------------------------- /src/rsa/src/README.md: -------------------------------------------------------------------------------- 1 | 2 | # 公私钥生成 3 | 4 | * 生成RSA私钥 5 | 6 | openssl genrsa -out privatekey.pem 1024 7 | 8 | * 从RSA私钥导出公钥 9 | 10 | openssl rsa -in privatekey.pem -out public.pem -outform PEM -pubout 11 | 12 | * 转换为pkcs8格式私钥 13 | 14 | openssl pkcs8 -topk8 -inform PEM -in privatekey.pem -outform PEM -nocrypt 15 | 16 | # refer 17 | 18 | 1. https://blog.csdn.net/xz_studying/article/details/80314111 19 | 2. https://segmentfault.com/a/1190000004151272 20 | 3. https://github.com/89hmdys/toast 21 | 4. https://studygolang.com/articles/5257 22 | -------------------------------------------------------------------------------- /src/socket/ip.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | "os" 7 | ) 8 | 9 | func main() { 10 | if len(os.Args) != 2 { 11 | fmt.Fprintf(os.Stderr, "Usage: %s ip-addr\n", os.Args[0]) 12 | os.Exit(1) 13 | } 14 | 15 | name := os.Args[1] 16 | addr := net.ParseIP(name) 17 | if addr == nil { 18 | fmt.Println("Invalid address") 19 | } else { 20 | fmt.Println("The address is ", addr.String()) 21 | } 22 | 23 | os.Exit(0) 24 | } 25 | -------------------------------------------------------------------------------- /src/socket/tcpechov1/README: -------------------------------------------------------------------------------- 1 | 2 | The simple demo for tcp communication used golang. 3 | 4 | -------------------------------------------------------------------------------- /src/socket/tcpechov2/README: -------------------------------------------------------------------------------- 1 | 2 | tcpforward benchmark tool 3 | short connections mode 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/socket/tcpechov3/README: -------------------------------------------------------------------------------- 1 | 2 | tcpforward benchmark tool 3 | long connections mode but not deal with err cases. 4 | 5 | refer to http://eng.42go.com/scala-vs-go-tcp-benchmark/ 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/socket/tcpechov3/tcpsvr.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net" 5 | "runtime" 6 | ) 7 | 8 | func handleClient(conn net.Conn) { 9 | defer conn.Close() 10 | 11 | var buf [4]byte 12 | for { 13 | n, err := conn.Read(buf[0:]) 14 | if err != nil { 15 | return 16 | } 17 | if n > 0 { 18 | _, err = conn.Write([]byte("Pong")) 19 | if err != nil { 20 | return 21 | } 22 | } 23 | } 24 | } 25 | 26 | func main() { 27 | runtime.GOMAXPROCS(4) 28 | 29 | tcpAddr, _ := net.ResolveTCPAddr("tcp4", ":1201") 30 | listener, _ := net.ListenTCP("tcp", tcpAddr) 31 | 32 | for { 33 | conn, _ := listener.Accept() 34 | go handleClient(conn) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/socket/tcpechov4/README: -------------------------------------------------------------------------------- 1 | 2 | tcpforward benchmark tool 3 | long connections mode and deal with err cases. 4 | 5 | refer to http://eng.42go.com/scala-vs-go-tcp-benchmark/ 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/tcp/test/go.mod: -------------------------------------------------------------------------------- 1 | module test 2 | 3 | go 1.20 4 | -------------------------------------------------------------------------------- /src/tcp/test/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | ) 7 | 8 | func main() { 9 | conn, err := net.Dial("tcp", "golang.org:80") 10 | if err != nil { 11 | fmt.Println("net.Dial err: ", err) 12 | } 13 | conn.Close() 14 | 15 | // 验证 conn Close 后调用 Write 是否会 crash 16 | if _, err := conn.Write([]byte("hello")); err != nil { 17 | fmt.Println("conn.Write err: ", err) 18 | } 19 | } 20 | 21 | /* 22 | $ ./test 23 | conn.Write err: write tcp 9.134.129.173:50710->142.251.211.241:80: use of closed network connection 24 | */ 25 | -------------------------------------------------------------------------------- /src/template/demo1/demo1.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "os" 5 | "text/template" 6 | ) 7 | 8 | type Person struct { 9 | Name string 10 | Age int 11 | } 12 | 13 | func main() { 14 | // Define a template 15 | tmpl := "Name: {{.Name}}, Age: {{.Age}}\n" 16 | 17 | // Create a new template and parse the template string 18 | t := template.Must(template.New("person").Parse(tmpl)) 19 | 20 | // Create a new person object 21 | p := Person{Name: "Alice", Age: 30} 22 | 23 | // Execute the template with the person object as input 24 | err := t.Execute(os.Stdout, p) 25 | if err != nil { 26 | panic(err) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/template/demo1/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/gerryyang/goinaction/src/template/demo1 2 | 3 | go 1.20 4 | -------------------------------------------------------------------------------- /src/template/demo2/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/gerryyang/goinaction/src/template/demo2 2 | 3 | go 1.20 4 | 5 | require gopkg.in/yaml.v2 v2.4.0 6 | -------------------------------------------------------------------------------- /src/template/demo2/go.sum: -------------------------------------------------------------------------------- 1 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 2 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 3 | gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= 4 | gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 5 | -------------------------------------------------------------------------------- /src/template/demo2/meta.yaml: -------------------------------------------------------------------------------- 1 | allocatesvr: 2 | SvrFE: "14" 3 | Required: 4 | WorldID: "50" 5 | 6 | -------------------------------------------------------------------------------- /src/template/demo2/test.cfg: -------------------------------------------------------------------------------- 1 | AllocateSvrFE = {{ .allocatesvr.SvrFE }} 2 | ReportInterval = 15 3 | WorldID = {{ .Required.WorldID }} 4 | -------------------------------------------------------------------------------- /tools/README.md: -------------------------------------------------------------------------------- 1 | 2 | install necessary Go tools 3 | 4 | ``` 5 | github.com/nsf/gocode 6 | code.google.com/p/go.tools/cmd/goimports 7 | code.google.com/p/rog-go/exp/cmd/godef 8 | code.google.com/p/go.tools/cmd/oracle 9 | code.google.com/p/go.tools/cmd/gorename 10 | github.com/golang/lint/golint 11 | github.com/kisielk/errcheck 12 | github.com/jstemmer/gotags 13 | ``` 14 | 15 | 可以通过 gopm.io (Download Go packages with version, but no require for version control tools like Git and Hg, etc.) 根据路径单独下载。 16 | 17 | -------------------------------------------------------------------------------- /tools/errcheck/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.2 5 | - tip 6 | -------------------------------------------------------------------------------- /tools/errcheck/example/main2.go: -------------------------------------------------------------------------------- 1 | // This file exists so that we can check that multi-file packages work 2 | package main 3 | 4 | import "fmt" 5 | 6 | type t struct{} 7 | 8 | func (x t) a() error { 9 | fmt.Println("this method returns an error") // UNCHECKED 10 | //line myfile.txt:100 11 | fmt.Println("this method also returns an error") // UNCHECKED 12 | return nil 13 | } 14 | 15 | type u struct { 16 | t t 17 | } 18 | -------------------------------------------------------------------------------- /tools/gocode/.gitignore: -------------------------------------------------------------------------------- 1 | *.8 2 | *.a 3 | *.out 4 | gocode 5 | goremote 6 | gocodetest 7 | *.swp 8 | listidents 9 | showcursor 10 | showsmap 11 | rename 12 | -------------------------------------------------------------------------------- /tools/gocode/_testing/README: -------------------------------------------------------------------------------- 1 | --== Desc ==-- 2 | 3 | This is a bunch of automated tests for gocode. 4 | 5 | Tests can be slow, because after each request gocode server runs GC. 6 | And current Go GC is slow. You won't notice that other than in tests 7 | because usually you spend some time in editor between requests and 8 | that time is wasted on a GC run, but testing app throws requests one 9 | after another and it causes GC to eat a lot of CPU. So.. don't worry 10 | about that. 11 | -------------------------------------------------------------------------------- /tools/gocode/_testing/all.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | gocode close 3 | sleep 0.5 4 | echo "--------------------------------------------------------------------" 5 | echo "Autocompletion tests..." 6 | echo "--------------------------------------------------------------------" 7 | ./run.rb 8 | sleep 0.5 9 | gocode close 10 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0001/cursor.47: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0001/cursor.47 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0001/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt. 7 | } 8 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0002/cursor.105: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0002/cursor.105 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0002/out.expected: -------------------------------------------------------------------------------- 1 | Found 5 candidates: 2 | func main() 3 | package os 4 | var key string 5 | var test map[string]os.Error 6 | var value os.Error 7 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0002/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "os" 4 | 5 | var test map[string]os.Error 6 | 7 | func main() { 8 | for key, value := range test { 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0003/cursor.552: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0003/cursor.552 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0003/out.expected: -------------------------------------------------------------------------------- 1 | Found 7 candidates: 2 | func End() token.Pos 3 | func IsExported() bool 4 | func Pos() token.Pos 5 | func String() string 6 | var Name string 7 | var NamePos token.Pos 8 | var Obj *ast.Object 9 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0004/cursor.1348: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0004/cursor.1348 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0004/out.expected: -------------------------------------------------------------------------------- 1 | Found 6 candidates: 2 | func PrettyPrintTypeExpr(out io.Writer, e ast.Expr) 3 | package ast 4 | package io 5 | var e ast.Expr 6 | var out io.Writer 7 | var t ast.Expr 8 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0005/b.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // this is a file 'a.go' 4 | 5 | import ( 6 | superos "os" 7 | ) 8 | 9 | func B() superos.Error { 10 | return nil 11 | } 12 | 13 | // notice how changing type of a return function in one file, 14 | // the inferred type of a variable in another file changes also 15 | 16 | func (t *Tester) SetC() { 17 | t.c = 31337 18 | } 19 | 20 | func (t *Tester) SetD() { 21 | t.d = 31337 22 | } 23 | 24 | // support for multifile packages, including correct namespace handling 25 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0005/cursor.327: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0005/cursor.327 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0005/out.expected: -------------------------------------------------------------------------------- 1 | Found 5 candidates: 2 | func A() localos.Error 3 | func B() superos.Error 4 | package localos 5 | type Tester struct 6 | var test superos.Error 7 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0005/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // this is a file 'a.go' 4 | 5 | import ( 6 | localos "os" 7 | ) 8 | 9 | func A() localos.Error { 10 | return nil 11 | } 12 | 13 | // B() is defined in file 'b.go' 14 | var test = B() 15 | 16 | type Tester struct { 17 | a, b, c, d int 18 | } 19 | 20 | func (t *Tester) SetA() { 21 | t.a = 31337 22 | } 23 | 24 | func (t *Tester) SetB() { 25 | t.b = 31337 26 | } 27 | 28 | // methods SetC and SetD are defined in 'b.go' 29 | 30 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0006/b.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // this is a file 'a.go' 4 | 5 | import ( 6 | superos "os" 7 | ) 8 | 9 | func B() superos.Error { 10 | return nil 11 | } 12 | 13 | // notice how changing type of a return function in one file, 14 | // the inferred type of a variable in another file changes also 15 | 16 | func (t *Tester) SetC() { 17 | t.c = 31337 18 | } 19 | 20 | func (t *Tester) SetD() { 21 | t.d = 31337 22 | } 23 | 24 | // support for multifile packages, including correct namespace handling 25 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0006/cursor.286: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0006/cursor.286 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0006/out.expected: -------------------------------------------------------------------------------- 1 | Found 8 candidates: 2 | func SetA() 3 | func SetB() 4 | func SetC() 5 | func SetD() 6 | var a int 7 | var b int 8 | var c int 9 | var d int 10 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0006/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // this is a file 'a.go' 4 | 5 | import ( 6 | localos "os" 7 | ) 8 | 9 | func A() localos.Error { 10 | return nil 11 | } 12 | 13 | // B() is defined in file 'b.go' 14 | var test = B() 15 | 16 | type Tester struct { 17 | a, b, c, d int 18 | } 19 | 20 | func (t *Tester) SetA() { 21 | t.a = 31337 22 | } 23 | 24 | func (t *Tester) SetB() { 25 | t.b = 31337 26 | } 27 | 28 | Tester. 29 | 30 | // methods SetC and SetD are defined in 'b.go' 31 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0007/cursor.58: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0007/cursor.58 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0007/out.expected: -------------------------------------------------------------------------------- 1 | Found 5 candidates: 2 | var ForkLock sync.RWMutex 3 | var SocketDisableIPv6 bool 4 | var Stderr int 5 | var Stdin int 6 | var Stdout int 7 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0007/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "syscall" 4 | 5 | func main() { 6 | syscall.var 7 | } 8 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0008/cursor.120: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0008/cursor.120 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0008/out.expected: -------------------------------------------------------------------------------- 1 | Found 6 candidates: 2 | func Lock() 3 | func Unlock() 4 | var Mutex sync.Mutex 5 | var data map[string][]string 6 | var path string 7 | var time int64 8 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0008/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "sync" 4 | 5 | var hosts struct { 6 | sync.Mutex 7 | data map[string][]string 8 | time int64 9 | path string 10 | } 11 | 12 | hosts. 13 | 14 | func main() { 15 | } 16 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0009/cursor.126: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0009/cursor.126 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0009/out.expected: -------------------------------------------------------------------------------- 1 | Found 2 candidates: 2 | func Lock() 3 | func Unlock() 4 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0009/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "sync" 4 | 5 | var hosts struct { 6 | sync.Mutex 7 | data map[string][]string 8 | time int64 9 | path string 10 | } 11 | 12 | hosts.Mutex. 13 | 14 | func main() { 15 | } 16 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0010/cursor.104: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0010/cursor.104 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0010/out.expected: -------------------------------------------------------------------------------- 1 | Found 7 candidates: 2 | func End() token.Pos 3 | func Pos() token.Pos 4 | var Comment *ast.CommentGroup 5 | var Doc *ast.CommentGroup 6 | var Names []*ast.Ident 7 | var Type ast.Expr 8 | var Values []ast.Expr 9 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0010/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "go/ast" 4 | 5 | func main() { 6 | var gd *ast.GenDecl 7 | v := gd.Specs[0].(*ast.ValueSpec) 8 | v. 9 | } 10 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0011/cursor.76: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0011/cursor.76 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0011/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "reflect" 4 | 5 | func main() { 6 | var test reflect.Value 7 | test. 8 | } 9 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0012/cursor.114: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0012/cursor.114 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0012/out.expected: -------------------------------------------------------------------------------- 1 | Found 6 candidates: 2 | func main() 3 | type MyMap map[string]int 4 | var key string 5 | var m MyMap 6 | var value int 7 | var z int 8 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0012/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type MyMap map[string]int 4 | 5 | func main() { 6 | var m MyMap 7 | for key, value := range m { 8 | z := m["15"] 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0013/cursor.359: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0013/cursor.359 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0013/out.expected: -------------------------------------------------------------------------------- 1 | Found 24 candidates: 2 | func main() 3 | var a int 4 | var add int 5 | var and int 6 | var andnot int 7 | var b int 8 | var c bool 9 | var d bool 10 | var div int 11 | var eq bool 12 | var geq bool 13 | var greater bool 14 | var leq bool 15 | var less bool 16 | var logand bool 17 | var logor bool 18 | var mul int 19 | var neq bool 20 | var or int 21 | var rem int 22 | var shl int 23 | var shr int 24 | var sub int 25 | var xor int 26 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0013/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a, b int 5 | add := a + b 6 | sub := a - b 7 | mul := a * b 8 | div := a / b 9 | or := a | b 10 | xor := a ^ b 11 | rem := a % b 12 | shr := a >> uint(b) 13 | shl := a << uint(b) 14 | and := a & b 15 | andnot := a &^ b 16 | 17 | eq := a == b 18 | neq := a != b 19 | less := a < b 20 | leq := a <= b 21 | greater := a > b 22 | geq := a >= b 23 | 24 | var c, d bool 25 | logor := c || d 26 | logand := c && d 27 | 28 | } 29 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0014/cursor.191: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0014/cursor.191 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0014/out.expected: -------------------------------------------------------------------------------- 1 | Found 11 candidates: 2 | func main() 3 | type MyPtrInt *int 4 | var a *int 5 | var aa int 6 | var b int 7 | var bb *MyPtrInt 8 | var c *int 9 | var d **int 10 | var megaptr **int 11 | var superint int 12 | var typeptr MyPtrInt 13 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0014/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type MyPtrInt *int 4 | 5 | func main() { 6 | var megaptr **int 7 | a := *megaptr 8 | b := *a 9 | 10 | var superint int 11 | c := &superint 12 | d := &c 13 | 14 | var typeptr MyPtrInt 15 | aa := *typeptr 16 | bb := &typeptr 17 | 18 | } 19 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0015/cursor.130: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0015/cursor.130 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0015/out.expected: -------------------------------------------------------------------------------- 1 | Found 9 candidates: 2 | func main() 3 | var a int 4 | var arro bool 5 | var b bool 6 | var c chan bool 7 | var uadd int 8 | var unot bool 9 | var usub int 10 | var uxor bool 11 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0015/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a int 5 | var b bool 6 | var c chan bool 7 | uadd := +a 8 | usub := -a 9 | unot := !b 10 | uxor := ^b 11 | arro := <-c 12 | 13 | } 14 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0016/cursor.122: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0016/cursor.122 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0016/out.expected: -------------------------------------------------------------------------------- 1 | Found 4 candidates: 2 | func main() 3 | var a int 4 | var b string 5 | var d bool 6 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0016/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var a int 5 | for { 6 | var b string 7 | if a == len(b) { 8 | var c bool 9 | } else { 10 | var d bool 11 | 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0017/cursor.70: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0017/cursor.70 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0017/out.expected: -------------------------------------------------------------------------------- 1 | Found 3 candidates: 2 | func a(a, b, c int) int 3 | func b(a, b, c string) string 4 | func main() 5 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0017/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func a(a, b, c int) int { 4 | return 123 5 | } 6 | 7 | func main() { 8 | 9 | } 10 | 11 | func b(a, b, c string) string { 12 | return "abc" 13 | } 14 | 15 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0018/cursor.355: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0018/cursor.355 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0018/out.expected: -------------------------------------------------------------------------------- 1 | Found 2 candidates: 2 | func Bark() 3 | var Legs int 4 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0018/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | // just a dummy example 8 | type Dog struct { 9 | Legs int 10 | } 11 | 12 | func (d *Dog) Bark() { 13 | fmt.Printf("Bark!\n") 14 | } 15 | 16 | // another one 17 | type Test struct { 18 | // map of slices of pointer to a *Dog 19 | MoreTests map[string][]**Dog 20 | } 21 | 22 | func (t *Test) GetMe() *Test { 23 | return t 24 | } 25 | 26 | func main() { 27 | t := new(Test) 28 | (*t.GetMe().MoreTests["blabla"][10]). 29 | } 30 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0019/cursor.72: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0019/cursor.72 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0019/out.expected: -------------------------------------------------------------------------------- 1 | Found 14 candidates: 2 | const BestCompression 3 | const BestSpeed 4 | const DefaultCompression 5 | const NoCompression 6 | func NewReader(r io.Reader) (io.ReadCloser, error) 7 | func NewReaderDict(r io.Reader, dict []byte) (io.ReadCloser, error) 8 | func NewWriter(w io.Writer) *zlib.Writer 9 | func NewWriterLevel(w io.Writer, level int) (*zlib.Writer, error) 10 | func NewWriterLevelDict(w io.Writer, level int, dict []byte) (*zlib.Writer, error) 11 | type Resetter interface 12 | type Writer struct 13 | var ErrChecksum error 14 | var ErrDictionary error 15 | var ErrHeader error 16 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0019/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "compress/zlib" 4 | 5 | func main() { 6 | var b map[int]zlib. 7 | } 8 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0020/cursor.174: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0020/cursor.174 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0020/out.expected: -------------------------------------------------------------------------------- 1 | Found 4 candidates: 2 | func Lock() 3 | func Unlock() 4 | var Dummy Dummy 5 | var Mutex sync.Mutex 6 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0020/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "sync" 4 | 5 | type Dummy struct { 6 | sync.Mutex 7 | } 8 | 9 | type Bar struct { 10 | Dummy 11 | } 12 | 13 | func (b *Bar) Lock() { 14 | } 15 | 16 | func (b *Bar) Unlock() { 17 | } 18 | 19 | func main() { 20 | var b Bar 21 | b. 22 | } 23 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0021/cursor.82: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0021/cursor.82 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0021/out.expected: -------------------------------------------------------------------------------- 1 | Found 7 candidates: 2 | func End() token.Pos 3 | func IsExported() bool 4 | func Pos() token.Pos 5 | func String() string 6 | var Name string 7 | var NamePos token.Pos 8 | var Obj *ast.Object 9 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0021/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "go/ast" 4 | 5 | func main() { 6 | var test *ast.ImportSpec 7 | test.Name. 8 | } 9 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0022/cursor.79: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0022/cursor.79 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0022/out.expected: -------------------------------------------------------------------------------- 1 | Found 5 candidates: 2 | func getMap() map[string]os.Error 3 | func main() 4 | package os 5 | var key string 6 | var value os.Error 7 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0022/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "os" 4 | 5 | func main() { 6 | for key, value := range getMap() { 7 | 8 | } 9 | } 10 | 11 | func getMap() map[string]os.Error { 12 | // simply to trick type inference 13 | return nil 14 | } 15 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0023/cursor.88: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0023/cursor.88 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0023/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Simple check for unicode awareness 4 | 5 | import ъ "fmt" 6 | 7 | func main() { 8 | ъ. 9 | } 10 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0024/cursor.71: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0024/cursor.71 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0024/out.expected: -------------------------------------------------------------------------------- 1 | Found 3 candidates: 2 | var a int 3 | var b int 4 | var c int 5 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0024/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type X struct { 4 | a,b,c int 5 | } 6 | 7 | func main() { 8 | var X *X 9 | X. 10 | } 11 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0025/cursor.53: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0025/cursor.53 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0025/out.expected: -------------------------------------------------------------------------------- 1 | Found 9 candidates: 2 | func Alignof(any) uintptr 3 | func New(typ interface{}) unsafe.Pointer 4 | func NewArray(typ interface{}, n int) unsafe.Pointer 5 | func Offsetof(any) uintptr 6 | func Reflect(i interface{}) (typ interface{}, addr unsafe.Pointer) 7 | func Sizeof(any) uintptr 8 | func Typeof(i interface{}) interface{} 9 | func Unreflect(typ interface{}, addr unsafe.Pointer) interface{} 10 | type Pointer uintptr 11 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0025/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "unsafe" 4 | 5 | func main() { 6 | unsafe. 7 | } 8 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0026/cursor.164: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0026/cursor.164 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0026/out.expected: -------------------------------------------------------------------------------- 1 | Found 7 candidates: 2 | func main() 3 | var A struct 4 | var B struct 5 | var C struct 6 | var a int 7 | var d int 8 | var g int 9 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0026/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var A = struct { a, b, c int }{1,2,3} 4 | var B struct { d, e, f int } 5 | 6 | func main() { 7 | C := struct { g, h, i int }{1,2,3} 8 | 9 | a := A.a 10 | d := B.d 11 | g := C.g 12 | 13 | } 14 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0027/cursor.84: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0027/cursor.84 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0027/out.expected: -------------------------------------------------------------------------------- 1 | Found 2 candidates: 2 | func String() 3 | var name string 4 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0027/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type file struct { 4 | name string 5 | } 6 | 7 | func (file *file) String() { 8 | file. 9 | return file.name 10 | } 11 | 12 | func main() { 13 | 14 | } 15 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0028/cursor.129: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0028/cursor.129 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0028/out.expected: -------------------------------------------------------------------------------- 1 | Found 1 candidates: 2 | func PowerOfTwo() int 3 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0028/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type X int 4 | 5 | func (x X) PowerOfTwo() int { 6 | return int(x * x) 7 | } 8 | 9 | func main() { 10 | a := X(56) 11 | i := a + 67 12 | j := ^i 13 | j. 14 | } 15 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0029/cursor.62: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0029/cursor.62 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0029/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import . "fmt" 4 | 5 | func main() { 6 | var a Formatter 7 | 8 | } 9 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0030/cursor.85: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0030/cursor.85 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0030/out.expected: -------------------------------------------------------------------------------- 1 | Found 3 candidates: 2 | var F1 int 3 | var F2 int 4 | var F3 int 5 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0030/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type A struct { 4 | F1, F2, F3 int 5 | } 6 | 7 | type B A 8 | 9 | func main() { 10 | var b B 11 | b. 12 | } 13 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0031/cursor.80: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0031/cursor.80 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0031/out.expected: -------------------------------------------------------------------------------- 1 | Found 2 candidates: 2 | func main() 3 | var c int 4 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0031/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var c chan int 5 | select { 6 | case c := <-c: 7 | _ = c 8 | 9 | default: 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0032/cursor.1835: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0032/cursor.1835 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0033/cursor.138: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0033/cursor.138 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0033/out.expected: -------------------------------------------------------------------------------- 1 | Found 6 candidates: 2 | func testEllipsis(dummies ...*Dummy) 3 | type Dummy struct 4 | var d *Dummy 5 | var dummies ...*Dummy 6 | var i int 7 | var x *Dummy 8 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0033/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Dummy struct { 4 | a, b, c int 5 | } 6 | 7 | func testEllipsis(dummies ...*Dummy) { 8 | for i, d := range dummies { 9 | x := dummies[0] 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0034/cursor.82: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0034/cursor.82 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0034/out.expected: -------------------------------------------------------------------------------- 1 | Found 3 candidates: 2 | func At(x int, y int) color.Color 3 | func Bounds() image.Rectangle 4 | func ColorModel() color.Model 5 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0034/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "image/png" 4 | 5 | func test() { 6 | img, err := png.Decode(nil) 7 | img. 8 | } 9 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0035/cursor.91: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0035/cursor.91 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0035/out.expected: -------------------------------------------------------------------------------- 1 | Found 5 candidates: 2 | func main() 3 | var err error 4 | var offset int 5 | var r rune 6 | var s string 7 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0035/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | var err error 5 | s := err.Error() 6 | for offset, r := range s { 7 | 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0036/cursor.67: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0036/cursor.67 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0036/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "debug/elf" 4 | 5 | func main() { 6 | var f elf.File 7 | f. 8 | } -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0037/cursor.139: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0037/cursor.139 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0037/out.expected: -------------------------------------------------------------------------------- 1 | Found 7 candidates: 2 | func main() 3 | type Array [5]int 4 | var a Array 5 | var s []string 6 | var s1 []string 7 | var s2 []int 8 | var s3 9 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0037/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Array [5]int 4 | 5 | func main() { 6 | var s []string 7 | var a Array 8 | s1 := append(s[:], "123") 9 | s2 := a[0:100500] 10 | s3 := append() 11 | 12 | } 13 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0038/cursor.87: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0038/cursor.87 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0038/out.expected: -------------------------------------------------------------------------------- 1 | Found 2 candidates: 2 | func main() 3 | var x 4 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0038/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | if y := 20; y == 0 { 5 | } 6 | if x := 10; x == 0 { 7 | } else if 8 | } 9 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0039/cursor.88: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0039/cursor.88 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0039/out.expected: -------------------------------------------------------------------------------- 1 | Found 2 candidates: 2 | func main() 3 | var z 4 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0039/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | z := 5 5 | if y := 20; y == 0 { 6 | } 7 | if x := 10; x == 0 { 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0040/cursor.96: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0040/cursor.96 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0040/out.expected: -------------------------------------------------------------------------------- 1 | Found 3 candidates: 2 | func create_foo() Foo 3 | type Foo struct 4 | var t Foo 5 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0040/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Foo struct {} 4 | 5 | func (f *Foo) Bar() {} 6 | 7 | func create_foo() Foo { 8 | t := Foo{} 9 | 10 | } 11 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0041/cursor.140: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0041/cursor.140 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0041/out.expected: -------------------------------------------------------------------------------- 1 | Found 3 candidates: 2 | var Xa int 3 | var Xb int 4 | var Xy Y 5 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0041/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type X struct { 4 | Xa int 5 | Xb int 6 | Xy Y 7 | } 8 | 9 | type Y struct { 10 | Ya int 11 | Yb int 12 | } 13 | 14 | func main() { 15 | x := X{ 16 | Xy: Y{ 17 | Ya: 1, 18 | }, 19 | 20 | } 21 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0042/cursor.126: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0042/cursor.126 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0042/out.expected: -------------------------------------------------------------------------------- 1 | Found 2 candidates: 2 | var Ya int 3 | var Yb int 4 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0042/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type X struct { 4 | Xa int 5 | Xb int 6 | Xy Y 7 | } 8 | 9 | type Y struct { 10 | Ya int 11 | Yb int 12 | } 13 | 14 | func main() { 15 | x := X{ 16 | Xy: Y{ 17 | 18 | } 19 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0043/cursor.182: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0043/cursor.182 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0043/out.expected: -------------------------------------------------------------------------------- 1 | Found 4 candidates: 2 | func foo() 3 | var Xa int 4 | var Xb int 5 | var Xy Y 6 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0043/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type X struct { 4 | Xa int 5 | Xb int 6 | Xy Y 7 | } 8 | 9 | type Y struct { 10 | Ya int 11 | Yb int 12 | } 13 | 14 | func (x X) foo() { 15 | return 16 | } 17 | 18 | func main() { 19 | x := X{ 20 | Xa: 1, 21 | Xb: 2, 22 | } 23 | y := Y{ 24 | Ya: x. 25 | } 26 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0044/cursor.105: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0044/cursor.105 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0044/out.expected: -------------------------------------------------------------------------------- 1 | Found 2 candidates: 2 | var Xa int 3 | var Xb int 4 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0044/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type X struct { 4 | Xa int 5 | Xb int 6 | } 7 | 8 | func (x X) foo() { 9 | return 10 | } 11 | 12 | func main() { 13 | x := X{ 14 | 15 | } 16 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0045/cursor.51: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0045/cursor.51 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0045/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | if fmt. 7 | } 8 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0046/cursor.53: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0046/cursor.53 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0046/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | x := fmt. 7 | } 8 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0047/cursor.43: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0047/out.expected: -------------------------------------------------------------------------------- 1 | Nothing to complete. 2 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0047/test.go.in: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | type T struct{ X } 4 | 5 | var _ = T.x. 6 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0048/cursor.53: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0048/cursor.53 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0048/out.expected: -------------------------------------------------------------------------------- 1 | Found 7 candidates: 2 | func Fprint(w io.Writer, a ...interface{}) (n int, err error) 3 | func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) 4 | func Fprintln(w io.Writer, a ...interface{}) (n int, err error) 5 | func Fscan(r io.Reader, a ...interface{}) (n int, err error) 6 | func Fscanf(r io.Reader, format string, a ...interface{}) (n int, err error) 7 | func Fscanln(r io.Reader, a ...interface{}) (n int, err error) 8 | type Formatter interface 9 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0048/test.go.in: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | x := fmt.Fpr 7 | } 8 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0049/cursor.44: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0049/cursor.44 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0049/out.expected: -------------------------------------------------------------------------------- 1 | Found 1 candidates: 2 | var i int 3 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0049/test.go.in: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | func t(a struct { 4 | i int 5 | }) { 6 | a. 7 | } 8 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0050/cursor.45: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/gocode/_testing/test.0050/cursor.45 -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0050/out.expected: -------------------------------------------------------------------------------- 1 | Found 1 candidates: 2 | var i int 3 | -------------------------------------------------------------------------------- /tools/gocode/_testing/test.0050/test.go.in: -------------------------------------------------------------------------------- 1 | package p 2 | 3 | func t(a *struct { 4 | i int 5 | }) { 6 | a. 7 | } 8 | -------------------------------------------------------------------------------- /tools/gocode/debian/changelog: -------------------------------------------------------------------------------- 1 | gocode (0.0.1~20110805-1) oneiric; urgency=low 2 | 3 | * Initial release 4 | 5 | -- Juan L. Negron Fri, 05 Aug 2011 22:58:48 -0700 6 | -------------------------------------------------------------------------------- /tools/gocode/debian/compat: -------------------------------------------------------------------------------- 1 | 7 2 | -------------------------------------------------------------------------------- /tools/gocode/debian/docs: -------------------------------------------------------------------------------- 1 | README.md 2 | -------------------------------------------------------------------------------- /tools/gocode/debian/gocode.default: -------------------------------------------------------------------------------- 1 | # Defaults for gocode initscript 2 | # sourced by /etc/init.d/gocode 3 | # installed at /etc/default/gocode by the maintainer scripts 4 | 5 | # 6 | # This is a POSIX shell fragment 7 | # 8 | 9 | # Additional options that are passed to the Daemon. 10 | DAEMON_OPTS="" 11 | -------------------------------------------------------------------------------- /tools/gocode/debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /tools/gocode/vim/ftplugin/go/gocomplete.vim: -------------------------------------------------------------------------------- 1 | setlocal omnifunc=gocomplete#Complete 2 | -------------------------------------------------------------------------------- /tools/gocode/vim/pathogen_update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mkdir -p "$HOME/.vim/bundle/gocode/autoload" 3 | mkdir -p "$HOME/.vim/bundle/gocode/ftplugin/go" 4 | cp "${0%/*}/autoload/gocomplete.vim" "$HOME/.vim/bundle/gocode/autoload" 5 | cp "${0%/*}/ftplugin/go/gocomplete.vim" "$HOME/.vim/bundle/gocode/ftplugin/go" 6 | -------------------------------------------------------------------------------- /tools/gocode/vim/symlink.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd "${0%/*}" 3 | ROOTDIR=`pwd` 4 | mkdir -p "$HOME/.vim/autoload" 5 | mkdir -p "$HOME/.vim/ftplugin/go" 6 | ln -s "$ROOTDIR/autoload/gocomplete.vim" "$HOME/.vim/autoload/" 7 | ln -s "$ROOTDIR/ftplugin/go/gocomplete.vim" "$HOME/.vim/ftplugin/go/" 8 | -------------------------------------------------------------------------------- /tools/gocode/vim/update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | mkdir -p "$HOME/.vim/autoload" 3 | mkdir -p "$HOME/.vim/ftplugin/go" 4 | cp "${0%/*}/autoload/gocomplete.vim" "$HOME/.vim/autoload" 5 | cp "${0%/*}/ftplugin/go/gocomplete.vim" "$HOME/.vim/ftplugin/go" 6 | -------------------------------------------------------------------------------- /tools/gotags/.gitignore: -------------------------------------------------------------------------------- 1 | gotags 2 | *.png 3 | -------------------------------------------------------------------------------- /tools/gotags/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.1 5 | - 1.2 6 | - 1.3 7 | - tip 8 | -------------------------------------------------------------------------------- /tools/gotags/tag_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestTagString(t *testing.T) { 8 | tag := NewTag("tagname", "filename", 2, "x") 9 | tag.Fields["access"] = "public" 10 | tag.Fields["type"] = "struct" 11 | tag.Fields["signature"] = "()" 12 | tag.Fields["empty"] = "" 13 | 14 | expected := "tagname\tfilename\t2;\"\tx\taccess:public\tline:2\tsignature:()\ttype:struct" 15 | 16 | s := tag.String() 17 | if s != expected { 18 | t.Errorf("Tag.String()\n is:%s\nwant:%s", s, expected) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tools/gotags/tests/const.go-src: -------------------------------------------------------------------------------- 1 | package Test 2 | 3 | const Constant string = "const" 4 | const OtherConst = "const" 5 | 6 | const ( 7 | A = true 8 | B, C = "c", "d" 9 | _, D = 0, 0 10 | ) 11 | -------------------------------------------------------------------------------- /tools/gotags/tests/func.go-src: -------------------------------------------------------------------------------- 1 | package Test 2 | 3 | func Function1() string { 4 | } 5 | 6 | func function2(p1, p2 int, p3 *string) { 7 | } 8 | 9 | func function3() (result bool) { 10 | } 11 | 12 | func function4(p interface{}) interface{} { 13 | } 14 | 15 | func function5() (a, b string, c error) { 16 | } 17 | -------------------------------------------------------------------------------- /tools/gotags/tests/import.go-src: -------------------------------------------------------------------------------- 1 | package Test 2 | 3 | import "fmt" 4 | 5 | import ( 6 | "go/ast" 7 | "go/parser" 8 | ) 9 | -------------------------------------------------------------------------------- /tools/gotags/tests/interface.go-src: -------------------------------------------------------------------------------- 1 | package Test 2 | 3 | type Interface interface { 4 | InterfaceMethod(int) string 5 | OtherMethod() 6 | io.Reader 7 | } 8 | -------------------------------------------------------------------------------- /tools/gotags/tests/simple.go-src: -------------------------------------------------------------------------------- 1 | package main 2 | -------------------------------------------------------------------------------- /tools/gotags/tests/struct.go-src: -------------------------------------------------------------------------------- 1 | package Test 2 | 3 | type Struct struct { 4 | Field1, Field2 int 5 | field3 string 6 | field4 *bool 7 | } 8 | 9 | func NewStruct() *Struct { 10 | return &Struct{} 11 | } 12 | 13 | func (s Struct) F1() ([]bool, [2]*string) { 14 | } 15 | 16 | func (Struct) F2() (result bool) { 17 | } 18 | 19 | type TestEmbed struct { 20 | Struct 21 | *io.Writer 22 | } 23 | 24 | func NewTestEmbed() TestEmbed { 25 | } 26 | 27 | type Struct2 struct { 28 | } 29 | 30 | func NewStruct2() (*Struct2, error) { 31 | } 32 | 33 | func Dial() (*Connection, error) { 34 | } 35 | 36 | type Connection struct { 37 | } 38 | 39 | func Dial2() (*Connection, *Struct2) { 40 | } 41 | 42 | func Dial3() (a, b *Connection) { 43 | } 44 | -------------------------------------------------------------------------------- /tools/gotags/tests/type.go-src: -------------------------------------------------------------------------------- 1 | package Test 2 | 3 | type testType int 4 | type testArrayType [4]int 5 | type testSliceType []int 6 | type testPointerType *string 7 | type testFuncType1 func() 8 | type testFuncType2 func(int) string 9 | type testMapType map[string]bool 10 | type testChanType chan bool 11 | -------------------------------------------------------------------------------- /tools/gotags/tests/var.go-src: -------------------------------------------------------------------------------- 1 | package Test 2 | 3 | var variable1 int 4 | var variable2 string = "string" 5 | 6 | var ( 7 | A = true 8 | B, C = "c", "d" 9 | _, D = 0, 0 10 | ) 11 | -------------------------------------------------------------------------------- /tools/lint/misc/vim/ftplugin/go/lint.vim: -------------------------------------------------------------------------------- 1 | " Copyright 2013 The Go Authors. All rights reserved. 2 | " Use of this source code is governed by a BSD-style 3 | " license that can be found in the LICENSE file. 4 | " 5 | " lint.vim: Vim command to lint Go files with golint. 6 | " 7 | " https://github.com/golang/lint 8 | " 9 | " This filetype plugin add a new commands for go buffers: 10 | " 11 | " :Lint 12 | " 13 | " Run golint for the current Go file. 14 | " 15 | if exists("b:did_ftplugin_go_lint") 16 | finish 17 | endif 18 | 19 | if !executable("golint") 20 | finish 21 | endif 22 | 23 | command! -buffer Lint call s:GoLint() 24 | 25 | function! s:GoLint() abort 26 | cexpr system('golint ' . shellescape(expand('%'))) 27 | endfunction 28 | 29 | let b:did_ftplugin_go_lint = 1 30 | 31 | " vim:ts=4:sw=4:et 32 | -------------------------------------------------------------------------------- /tools/lint/testdata/5_test.go: -------------------------------------------------------------------------------- 1 | // This file ends in _test.go, so we should not warn about doc comments. 2 | // OK 3 | 4 | package pkg 5 | 6 | import "testing" 7 | 8 | type H int 9 | 10 | func TestSomething(t *testing.T) { 11 | } 12 | 13 | func TestSomething_suffix(t *testing.T) { 14 | } 15 | 16 | func ExampleBuffer_reader() { 17 | } 18 | -------------------------------------------------------------------------------- /tools/lint/testdata/blank-import-lib_test.go: -------------------------------------------------------------------------------- 1 | // Test that blank imports in test packages are not flagged. 2 | // OK 3 | 4 | // Package foo ... 5 | package foo 6 | 7 | // These are essentially the same imports as in the "library" package, but 8 | // these should not trigger the warning because this is a test. 9 | 10 | import _ "encoding/json" 11 | 12 | import ( 13 | "fmt" 14 | "testing" 15 | 16 | _ "os" 17 | 18 | _ "net/http" 19 | _ "path" 20 | ) 21 | 22 | var ( 23 | _ fmt.Stringer // for "fmt" 24 | _ testing.T // for "testing" 25 | ) 26 | -------------------------------------------------------------------------------- /tools/lint/testdata/blank-import-main.go: -------------------------------------------------------------------------------- 1 | // Test that blank imports in package main are not flagged. 2 | // OK 3 | 4 | // Binary foo ... 5 | package main 6 | 7 | import _ "fmt" 8 | 9 | import ( 10 | "os" 11 | _ "path" 12 | ) 13 | 14 | var _ os.File // for "os" 15 | -------------------------------------------------------------------------------- /tools/lint/testdata/common-methods.go: -------------------------------------------------------------------------------- 1 | // Test that we don't nag for comments on common methods. 2 | // OK 3 | 4 | // Package pkg ... 5 | package pkg 6 | 7 | import "net/http" 8 | 9 | // T is ... 10 | type T int 11 | 12 | func (T) Error() string { return "" } 13 | func (T) String() string { return "" } 14 | func (T) ServeHTTP(w http.ResponseWriter, r *http.Request) {} 15 | func (T) Read(p []byte) (n int, err error) { return 0, nil } 16 | func (T) Write(p []byte) (n int, err error) { return 0, nil } 17 | -------------------------------------------------------------------------------- /tools/lint/testdata/else-multi.go: -------------------------------------------------------------------------------- 1 | // Test of return+else warning; should not trigger on multi-branch if/else. 2 | // OK 3 | 4 | // Package pkg ... 5 | package pkg 6 | 7 | import "log" 8 | 9 | func f(x int) bool { 10 | if x == 0 { 11 | log.Print("x is zero") 12 | } else if x > 0 { 13 | return true 14 | } else { 15 | log.Printf("non-positive x: %d", x) 16 | } 17 | return false 18 | } 19 | -------------------------------------------------------------------------------- /tools/lint/testdata/else.go: -------------------------------------------------------------------------------- 1 | // Test of return+else warning. 2 | 3 | // Package pkg ... 4 | package pkg 5 | 6 | import "log" 7 | 8 | func f(x int) bool { 9 | if x > 0 { 10 | return true 11 | } else { // MATCH /if.*return.*else.*outdent/ 12 | log.Printf("non-positive x: %d", x) 13 | } 14 | return false 15 | } 16 | 17 | func g(f func() bool) string { 18 | if ok := f(); ok { 19 | return "it's okay" 20 | } else { // MATCH /if.*return.*else.*outdent.*short.*var.*declaration/ 21 | return "it's NOT okay!" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tools/lint/testdata/errorf.go: -------------------------------------------------------------------------------- 1 | // Test for not using fmt.Errorf. 2 | 3 | // Package foo ... 4 | package foo 5 | 6 | import ( 7 | "errors" 8 | "fmt" 9 | ) 10 | 11 | func f(x int) error { 12 | if x > 10 { 13 | return errors.New(fmt.Sprintf("something %d", x)) // MATCH /should replace.*errors\.New\(fmt\.Sprintf\(\.\.\.\)\).*fmt\.Errorf\(\.\.\.\)/ 14 | } 15 | if x > 5 { 16 | return errors.New(g("blah")) // ok 17 | } 18 | if x > 4 { 19 | return errors.New("something else") // ok 20 | } 21 | return nil 22 | } 23 | 24 | func g(s string) string { return "prefix: " + s } 25 | -------------------------------------------------------------------------------- /tools/lint/testdata/import-dot.go: -------------------------------------------------------------------------------- 1 | // Test that dot imports are flagged. 2 | 3 | // Package pkg ... 4 | package pkg 5 | 6 | import . "fmt" // MATCH /dot import/ 7 | 8 | var _ Stringer // from "fmt" 9 | -------------------------------------------------------------------------------- /tools/lint/testdata/inc.go: -------------------------------------------------------------------------------- 1 | // Test for use of x++ and x--. 2 | 3 | // Package pkg ... 4 | package pkg 5 | 6 | func addOne(x int) int { 7 | x += 1 // MATCH /x\+\+/ 8 | return x 9 | } 10 | 11 | func subOneInLoop(y int) { 12 | for ; y > 0; y -= 1 { // MATCH /y--/ 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /tools/lint/testdata/make.go: -------------------------------------------------------------------------------- 1 | // Test for pointless make() calls. 2 | 3 | // Package pkg ... 4 | package pkg 5 | 6 | import "net/http" 7 | 8 | // T is a test type. 9 | type T int 10 | 11 | var z []T 12 | 13 | func f() { 14 | x := make([]T, 0) // MATCH /var x \[\]T/ 15 | y := make([]http.Request, 0) // MATCH /var y \[\]http\.Request/ 16 | z = make([]T, 0) // ok, because we don't know where z is declared 17 | 18 | _, _ = x, y 19 | } 20 | -------------------------------------------------------------------------------- /tools/lint/testdata/pkg-doc1.go: -------------------------------------------------------------------------------- 1 | // Test of missing package comment. 2 | 3 | package foo // MATCH /should.*package comment.*unless/ 4 | -------------------------------------------------------------------------------- /tools/lint/testdata/pkg-doc2.go: -------------------------------------------------------------------------------- 1 | // Test of package comment in an incorrect form. 2 | 3 | // Some random package doc that isn't in the right form. 4 | // MATCH /package comment should.*form.*"Package testdata .*"/ 5 | package testdata 6 | -------------------------------------------------------------------------------- /tools/lint/testdata/pkg-doc3.go: -------------------------------------------------------------------------------- 1 | // Test of block package comment. 2 | // OK 3 | 4 | /* 5 | Package foo is pretty sweet. 6 | */ 7 | package foo 8 | -------------------------------------------------------------------------------- /tools/lint/testdata/pkg-doc4.go: -------------------------------------------------------------------------------- 1 | // Test of block package comment with leading space. 2 | 3 | /* 4 | Package foo is pretty sweet. 5 | MATCH /package comment.*leading space/ 6 | */ 7 | package foo 8 | -------------------------------------------------------------------------------- /tools/lint/testdata/pkg-main.go: -------------------------------------------------------------------------------- 1 | // Test of package comment for package main. 2 | // OK 3 | 4 | // This binary does something awesome. 5 | package main 6 | -------------------------------------------------------------------------------- /tools/lint/testdata/range.go: -------------------------------------------------------------------------------- 1 | // Test for range construction. 2 | 3 | // Package foo ... 4 | package foo 5 | 6 | func f() { 7 | var m map[string]int 8 | 9 | // with := 10 | for x, _ := range m { // MATCH /should omit 2nd value.*range.*equivalent.*for x := range/ 11 | _ = x 12 | } 13 | // with = 14 | var y string 15 | _ = y 16 | for y, _ = range m { // MATCH /should omit 2nd value.*range.*equivalent.*for y = range/ 17 | } 18 | 19 | // all OK: 20 | for x := range m { 21 | _ = x 22 | } 23 | for x, y := range m { 24 | _, _ = x, y 25 | } 26 | for _, y := range m { 27 | _ = y 28 | } 29 | var x int 30 | _ = x 31 | for y = range m { 32 | } 33 | for y, x = range m { 34 | } 35 | for _, x = range m { 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tools/lint/testdata/sort.go: -------------------------------------------------------------------------------- 1 | // Test that we don't ask for comments on sort.Interface methods. 2 | 3 | // Package pkg ... 4 | package pkg 5 | 6 | // T is ... 7 | type T []int 8 | 9 | // Len by itself should get documented. 10 | 11 | func (t T) Len() int { return len(t) } // MATCH /exported method T\.Len.*should.*comment/ 12 | 13 | // U is ... 14 | type U []int 15 | 16 | func (u U) Len() int { return len(u) } 17 | func (u U) Less(i, j int) bool { return u[i] < u[j] } 18 | func (u U) Swap(i, j int) { u[i], u[j] = u[j], u[i] } 19 | 20 | func (u U) Other() {} // MATCH /exported method U\.Other.*should.*comment/ 21 | -------------------------------------------------------------------------------- /tools/lint/testdata/stutter.go: -------------------------------------------------------------------------------- 1 | // Test of stuttery names. 2 | 3 | // Package donut ... 4 | package donut 5 | 6 | // DonutMaker makes donuts. 7 | type DonutMaker struct{} // MATCH /donut\.DonutMaker.*stutter/ 8 | 9 | // DonutRank computes the ranking of a donut. 10 | func DonutRank(d Donut) int { // MATCH /donut\.DonutRank.*stutter/ 11 | return 0 12 | } 13 | 14 | // Donut is a delicious treat. 15 | type Donut struct{} // ok because it is the whole name 16 | 17 | // Donuts are great, aren't they? 18 | type Donuts []Donut // ok because it didn't start a new word 19 | 20 | type donutGlaze int // ok because it is unexported 21 | 22 | // DonutMass reports the mass of a donut. 23 | func (d *Donut) DonutMass() (grams int) { // okay because it is a method 24 | return 38 25 | } 26 | -------------------------------------------------------------------------------- /tools/rog-go/cmd/calc/help.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "sort" 6 | ) 7 | 8 | var help = genericOp{0, 0, func(*stack, string) { 9 | var lines []string 10 | for name, vs := range ops { 11 | lines = append(lines, fmt.Sprintf("%s[%d]", name, argCount(vs[0]))) 12 | } 13 | sort.Strings(lines) 14 | for _, l := range lines { 15 | fmt.Printf("%s\n", l) 16 | } 17 | }} 18 | 19 | func printAll() { 20 | for name, vs := range ops { 21 | fmt.Printf("%s\n", name) 22 | for _, v := range vs { 23 | fmt.Printf("\t%T\n", v) 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tools/rog-go/cmd/share/doc.go: -------------------------------------------------------------------------------- 1 | // Share is a piece of demo code to illustrate the flexibility of the rpc and netchan 2 | // packages. It requires one instance to be running in server mode on some network 3 | // address addr, e.g. localhost:3456: 4 | // 5 | // share -s localhost:3456 6 | // 7 | // Then in other windows or on other machines, run some client instances: 8 | // share -name foo localhost:3456 9 | // 10 | // The name must be different for each client instance. 11 | // When a client instance is running, there are two commands: 12 | // list 13 | // List all currently connected client names 14 | // read client filename 15 | // Ask the given client for the contents of the named file. 16 | package documentation 17 | -------------------------------------------------------------------------------- /tools/rog-go/exp/abc/audio/_testmain.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "abc/audio" 4 | import "testing" 5 | 6 | var tests = []testing.Test { 7 | testing.Test{ "audio.TestParserWithPipes", audio.TestParserWithPipes }, 8 | testing.Test{ "audio.TestConversion", audio.TestConversion }, 9 | } 10 | var benchmarks = []testing.Benchmark { 11 | } 12 | 13 | func main() { 14 | testing.Main(tests); 15 | testing.RunBenchmarks(benchmarks) 16 | } 17 | -------------------------------------------------------------------------------- /tools/rog-go/exp/abc/audio/input.go: -------------------------------------------------------------------------------- 1 | package audio 2 | 3 | import ( 4 | "code.google.com/p/rog-go/exp/abc" 5 | ) 6 | 7 | func init() { 8 | abc.Register("input", map[string]abc.Socket{ 9 | "audio", abc.Socket{SamplesT, abc.Female}, 10 | "out": abc.Socket{SamplesT, abc.Male}, 11 | "1": abc.Socket{abc.StringT, abc.Female}, 12 | }, makeInput) 13 | } 14 | 15 | func makeInput(args map[string]interface{}) abc.Widget { 16 | name := args["1"].(string) 17 | ctxt := args["audio"].(*context) 18 | ctxt.Lock() 19 | defer ctxt.Unlock() 20 | node := ctxt.inputs[name] 21 | if node == nil { 22 | if len(name) > 4 && name[0:4] == "buf." { 23 | ctxt.inputs[name] = &node{nullRender, nil} 24 | } 25 | } 26 | args["out"].(chan interface{}) <- node 27 | return nil 28 | } 29 | -------------------------------------------------------------------------------- /tools/rog-go/exp/abc/audio/output.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package audio 4 | 5 | import ( 6 | "code.google.com/p/rog-go/exp/abc" 7 | ) 8 | 9 | func init() { 10 | abc.Register("output", map[string]abc.Socket{ 11 | "audio", abc.Socket{SamplesT, abc.Female}, 12 | "1": abc.Socket{SamplesT, abc.Female}, 13 | "2": abc.Socket{abc.StringT, abc.Female}, 14 | }, makeOutput) 15 | } 16 | 17 | func makeOutput(args map[string]interface{}) abc.Widget { 18 | name := args["2"].(string) 19 | ctxt := args["audio"].(*context) 20 | if len(name) > 4 && name[0:4] == "buf." { 21 | look 22 | if it { 23 | then 24 | if not { 25 | are 26 | 27 | for { 28 | select { 29 | case msg := <-ctl: 30 | 31 | case renderreq := <-intermittent: 32 | } 33 | } 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tools/rog-go/exp/abc/basic/echo.go: -------------------------------------------------------------------------------- 1 | package basic 2 | 3 | import ( 4 | "code.google.com/p/rog-go/exp/abc" 5 | "strings" 6 | ) 7 | 8 | func init() { 9 | abc.Register("echo", map[string]abc.Socket{ 10 | "1": abc.Socket{abc.StringT, abc.Female}, 11 | "out": abc.Socket{FdT, abc.Male}, 12 | }, makeEcho) 13 | } 14 | func makeEcho(_ *abc.Status, args map[string]interface{}) abc.Widget { 15 | s := args["1"].(string) + "\n" 16 | out := NewFd() 17 | args["out"].(chan interface{}) <- out 18 | if w := out.GetWriter(strings.NewReader(s)); w != nil { 19 | w.Write([]byte(s)) 20 | } 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /tools/rog-go/exp/abc/basic/read.go: -------------------------------------------------------------------------------- 1 | package basic 2 | 3 | import ( 4 | "code.google.com/p/rog-go/exp/abc" 5 | "io" 6 | "os" 7 | ) 8 | 9 | func init() { 10 | abc.Register("read", map[string]abc.Socket{ 11 | "1": abc.Socket{abc.StringT, abc.Female}, 12 | "out": abc.Socket{FdT, abc.Male}, 13 | }, makeRead) 14 | } 15 | 16 | func makeRead(_ *abc.Status, args map[string]interface{}) abc.Widget { 17 | f := args["1"].(string) 18 | out := NewFd() 19 | args["out"].(chan interface{}) <- out 20 | fd, _ := os.Open(f) 21 | if w := out.GetWriter(fd); w != nil { 22 | io.Copy(w, fd) 23 | } 24 | return nil 25 | } 26 | -------------------------------------------------------------------------------- /tools/rog-go/exp/abc/basic/stdin.go: -------------------------------------------------------------------------------- 1 | package basic 2 | 3 | import ( 4 | "code.google.com/p/rog-go/exp/abc" 5 | "io" 6 | "os" 7 | ) 8 | 9 | func init() { 10 | abc.Register("stdin", map[string]abc.Socket{ 11 | "out": abc.Socket{FdT, abc.Male}, 12 | }, makeStdin) 13 | } 14 | 15 | func makeStdin(_ *abc.Status, args map[string]interface{}) abc.Widget { 16 | out := NewFd() 17 | args["out"].(chan interface{}) <- out 18 | if w := out.GetWriter(os.Stdin); w != nil { 19 | io.Copy(w, os.Stdin) 20 | } 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /tools/rog-go/exp/abc/basic/stdout.go: -------------------------------------------------------------------------------- 1 | package basic 2 | 3 | import ( 4 | "code.google.com/p/rog-go/exp/abc" 5 | "os" 6 | ) 7 | 8 | func init() { 9 | abc.Register("stdout", map[string]abc.Socket{ 10 | "1": abc.Socket{FdT, abc.Female}, 11 | }, makeStdout) 12 | } 13 | 14 | func makeStdout(_ *abc.Status, args map[string]interface{}) abc.Widget { 15 | in := args["1"].(Fd) 16 | in.PutWriter(os.Stdout) 17 | return nil 18 | } 19 | -------------------------------------------------------------------------------- /tools/rog-go/exp/abc/basic/write.go: -------------------------------------------------------------------------------- 1 | package basic 2 | 3 | import ( 4 | "code.google.com/p/rog-go/exp/abc" 5 | "os" 6 | ) 7 | 8 | func init() { 9 | abc.Register("write", map[string]abc.Socket{ 10 | "1": abc.Socket{FdT, abc.Female}, 11 | "2": abc.Socket{abc.StringT, abc.Female}, 12 | }, makeWrite) 13 | } 14 | 15 | func makeWrite(_ *abc.Status, args map[string]interface{}) abc.Widget { 16 | in := args["1"].(Fd) 17 | f := args["2"].(string) 18 | 19 | fd, _ := os.Create(f) 20 | in.PutWriter(fd) 21 | return nil 22 | } 23 | -------------------------------------------------------------------------------- /tools/rog-go/exp/callback/callback.h: -------------------------------------------------------------------------------- 1 | void callback(void (*f)(void*), void*arg); 2 | void runCallbacks(void); 3 | void callbackInit(void); 4 | void *callbackFunc(void); 5 | -------------------------------------------------------------------------------- /tools/rog-go/exp/cmd/gosym/testfiles/src/test/test.go: -------------------------------------------------------------------------------- 1 | package test 2 | import "other" 3 | 4 | func %test test X func+%X() { 5 | %test test x var+%x := 0 6 | for %test test i var+%i := 0; %test test i var%i < %test test x var%x; %test test i var%i++ { 7 | %test test i var+%i := %test test i var%i 8 | %test test x var%x += %test test i var%i 9 | } 10 | other.%test other Println func%Println(%test test x var%x, %test test i var+%i) 11 | other.%test other Var var%Var = 5 12 | } 13 | 14 | type %test test Foo type+%Foo struct{} 15 | 16 | func (%test test Foo type%Foo) %test test Foo.Bar func+%Bar() {} 17 | -------------------------------------------------------------------------------- /tools/rog-go/exp/example/event/event_test.go: -------------------------------------------------------------------------------- 1 | package event 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | "time" 7 | ) 8 | 9 | func TestEvents(t *testing.T) { 10 | w := NewWindow() 11 | w.SetCallback(func(event int) { 12 | fmt.Printf("got event %d\n", event) 13 | }) 14 | time.Sleep(5e9) 15 | } 16 | -------------------------------------------------------------------------------- /tools/rog-go/exp/example/event/window.h: -------------------------------------------------------------------------------- 1 | typedef struct Window Window; 2 | struct Window { 3 | pthread_mutex_t mu; 4 | void (*handler)(void *ctxt, int eventType); 5 | void *handlerCtxt; 6 | int shutdown; 7 | }; 8 | Window *newWindow(); 9 | void windowClose(Window *w); 10 | void windowSetCallback(Window *w, void (*handler)(void *, int), void *ctxt); 11 | enum { 12 | someEvent, 13 | otherEvent, 14 | }; 15 | -------------------------------------------------------------------------------- /tools/rog-go/exp/example/looper/looper_test.go: -------------------------------------------------------------------------------- 1 | package looper 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestLooper(t *testing.T) { 8 | c := make(chan bool) 9 | loop := NewLooper(func() bool { 10 | c <- true 11 | return false 12 | }) 13 | <-c 14 | loop.Close() 15 | } 16 | 17 | func BenchmarkLooper(b *testing.B) { 18 | i := b.N - 1 19 | c := make(chan int) 20 | loop := NewLooper(func() bool { 21 | i-- 22 | if i <= 0 { 23 | close(c) 24 | return false 25 | } 26 | return true 27 | }) 28 | for _ = range c { 29 | } 30 | loop.Close() 31 | } 32 | -------------------------------------------------------------------------------- /tools/rog-go/exp/go/printer/testdata/empty.golden: -------------------------------------------------------------------------------- 1 | // a comment at the beginning of the file 2 | 3 | package empty 4 | 5 | // a comment at the end of the file 6 | -------------------------------------------------------------------------------- /tools/rog-go/exp/go/printer/testdata/empty.input: -------------------------------------------------------------------------------- 1 | // a comment at the beginning of the file 2 | 3 | package empty 4 | 5 | // a comment at the end of the file 6 | -------------------------------------------------------------------------------- /tools/rog-go/exp/stquery/example_test.go: -------------------------------------------------------------------------------- 1 | package stquery_test 2 | 3 | import ( 4 | "code.google.com/p/rog-go/exp/stquery" 5 | "database/sql" 6 | "fmt" 7 | "log" 8 | "testing" 9 | ) 10 | 11 | func ExampleGetter(t *testing.T) { 12 | db := openDatabase() 13 | var row struct { 14 | Name string 15 | Age int 16 | } 17 | rows, err := db.Query(stquery.Statement(&row, `SELECT $fields 18 | FROM sge_job 19 | WHERE j_job_number = $1 AND j_task_number = -1 20 | ORDER BY j_job_number DESC`)) 21 | if err != nil { 22 | log.Fatal(err) 23 | } 24 | getter := stquery.NewGetter(&row, rows) 25 | for rows.Next() { 26 | if err := getter.Get(); err != nil { 27 | log.Fatal(err) 28 | } 29 | } 30 | fmt.Printf("got row %#v", row) 31 | } 32 | 33 | func openDatabase() *sql.DB { 34 | return nil 35 | } 36 | -------------------------------------------------------------------------------- /tools/rog-go/go9p/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of Go9p authors for copyright purposes. 2 | # This file is distinct from the CONTRIBUTORS files. 3 | # See the latter for an explanation. 4 | 5 | # Names should be added to this file as 6 | # Name or Organization 7 | # The email address is not required for organizations. 8 | 9 | # Please keep the list sorted. 10 | 11 | Andrey Mirtchovski 12 | Latchesar Ionkov 13 | Roger Peppe 14 | -------------------------------------------------------------------------------- /tools/rog-go/go9p/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This is the official list of people who can contribute 2 | # (and typically have contributed) code to the Go9p repository. 3 | # The AUTHORS file lists the copyright holders; this file 4 | # lists people. For example, Google employees are listed here 5 | # but not in AUTHORS, because Google holds the copyright. 6 | # 7 | # The submission process automatically checks to make sure 8 | # that people submitting code are listed in this file (by email address). 9 | # XXX more bumph here? 10 | # Names should be added to this file like so: 11 | # Name 12 | 13 | # Please keep the list sorted. 14 | 15 | Andrey Mirtchovski 16 | Latchesar Ionkov 17 | Roger Peppe 18 | -------------------------------------------------------------------------------- /tools/rog-go/go9p/README: -------------------------------------------------------------------------------- 1 | this is an tentative fork of go9p.googlecode.com . 2 | server side is incomplete. 3 | -------------------------------------------------------------------------------- /tools/rog-go/new9p/examples/cat.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "os" 7 | 8 | "code.google.com/p/goplan9/plan9" 9 | "code.google.com/p/goplan9/plan9/client" 10 | ) 11 | 12 | func main() { 13 | fsys, err := client.MountService("acme") 14 | if err != nil { 15 | panic(err) 16 | } 17 | 18 | fid, err := fsys.Open("index", plan9.OREAD) 19 | if err != nil { 20 | panic(err) 21 | } 22 | 23 | fid.Write([]byte("hello, world")) 24 | 25 | io.Copy(os.Stdout, fid) 26 | fid.Close() 27 | 28 | d, err := fsys.Stat("/index") 29 | if err != nil { 30 | panic(err) 31 | } 32 | fmt.Printf("%v\n", d) 33 | 34 | fsys.Wstat("/index", d) 35 | } 36 | -------------------------------------------------------------------------------- /tools/rog-go/reverse/export_test.go: -------------------------------------------------------------------------------- 1 | package reverse 2 | 3 | func (b *Scanner) SetBufSize(n int) { 4 | b.buf = make([]byte, n) 5 | } 6 | -------------------------------------------------------------------------------- /tools/tools.go/.hgignore: -------------------------------------------------------------------------------- 1 | # Add no patterns to .hgignore except for files generated by the build. 2 | syntax:glob 3 | last-change 4 | dashboard/coordinator/buildongce/client-*.dat 5 | dashboard/coordinator/buildongce/token.dat 6 | dashboard/coordinator/coordinator 7 | -------------------------------------------------------------------------------- /tools/tools.go/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /tools/tools.go/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /tools/tools.go/README: -------------------------------------------------------------------------------- 1 | This subrepository holds the source for various packages and tools that support 2 | the Go programming language. 3 | 4 | Some of the tools, godoc and vet for example, are included in binary Go distributions. 5 | Others, including the Go oracle and the test coverage tool, can be fetched with "go get". 6 | 7 | Packages include a type-checker for Go and an implementation of the 8 | Static Single Assignment form (SSA) representation for Go programs. 9 | 10 | To submit changes to this repository, see http://golang.org/doc/contribute.html. 11 | -------------------------------------------------------------------------------- /tools/tools.go/cmd/godex/gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file implements access to gc-generated export data. 6 | 7 | package main 8 | 9 | import ( 10 | "code.google.com/p/go.tools/go/gcimporter" 11 | ) 12 | 13 | func init() { 14 | register("gc", gcimporter.Import) 15 | } 16 | -------------------------------------------------------------------------------- /tools/tools.go/cmd/godex/source.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file implements access to export data from source. 6 | 7 | package main 8 | 9 | import ( 10 | "code.google.com/p/go.tools/go/types" 11 | ) 12 | 13 | func init() { 14 | register("source", sourceImporter) 15 | } 16 | 17 | func sourceImporter(packages map[string]*types.Package, path string) (*types.Package, error) { 18 | panic("unimplemented") 19 | } 20 | -------------------------------------------------------------------------------- /tools/tools.go/cmd/godoc/dl.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import "net/http" 8 | 9 | // Register a redirect handler for /dl/ to the golang.org download page. 10 | // This file will not be included when deploying godoc to golang.org. 11 | 12 | func init() { 13 | http.Handle("/dl/", http.RedirectHandler("http://golang.org/dl/", http.StatusFound)) 14 | } 15 | -------------------------------------------------------------------------------- /tools/tools.go/cmd/present/appengine.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build appengine 6 | 7 | package main 8 | 9 | import ( 10 | "mime" 11 | 12 | "code.google.com/p/go.tools/present" 13 | 14 | _ "code.google.com/p/go.tools/playground" 15 | ) 16 | 17 | var basePath = "./present/" 18 | 19 | func init() { 20 | initTemplates(basePath) 21 | playScript(basePath, "HTTPTransport") 22 | present.PlayEnabled = true 23 | 24 | // App Engine has no /etc/mime.types 25 | mime.AddExtensionType(".svg", "image/svg+xml") 26 | } 27 | 28 | func playable(c present.Code) bool { 29 | return present.PlayEnabled && c.Play && c.Ext == ".go" 30 | } 31 | -------------------------------------------------------------------------------- /tools/tools.go/cmd/present/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/cmd/present/static/favicon.ico -------------------------------------------------------------------------------- /tools/tools.go/cmd/stringer/testdata/num.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Signed integers spanning zero. 6 | 7 | package main 8 | 9 | import "fmt" 10 | 11 | type Num int 12 | 13 | const ( 14 | m_2 Num = -2 + iota 15 | m_1 16 | m0 17 | m1 18 | m2 19 | ) 20 | 21 | func main() { 22 | ck(-3, "Num(-3)") 23 | ck(m_2, "m_2") 24 | ck(m_1, "m_1") 25 | ck(m0, "m0") 26 | ck(m1, "m1") 27 | ck(m2, "m2") 28 | ck(3, "Num(3)") 29 | } 30 | 31 | func ck(num Num, str string) { 32 | if fmt.Sprint(num) != str { 33 | panic("num.go: " + str) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /tools/tools.go/cmd/stringer/testdata/number.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Enumeration with an offset. 6 | // Also includes a duplicate. 7 | 8 | package main 9 | 10 | import "fmt" 11 | 12 | type Number int 13 | 14 | const ( 15 | _ Number = iota 16 | One 17 | Two 18 | Three 19 | AnotherOne = One // Duplicate; note that AnotherOne doesn't appear below. 20 | ) 21 | 22 | func main() { 23 | ck(One, "One") 24 | ck(Two, "Two") 25 | ck(Three, "Three") 26 | ck(AnotherOne, "One") 27 | ck(127, "Number(127)") 28 | } 29 | 30 | func ck(num Number, str string) { 31 | if fmt.Sprint(num) != str { 32 | panic("number.go: " + str) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tools/tools.go/cmd/stringer/testdata/unum.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Unsigned integers spanning zero. 6 | 7 | package main 8 | 9 | import "fmt" 10 | 11 | type Unum uint8 12 | 13 | const ( 14 | m_2 Unum = iota + 253 15 | m_1 16 | ) 17 | 18 | const ( 19 | m0 Unum = iota 20 | m1 21 | m2 22 | ) 23 | 24 | func main() { 25 | ck(^Unum(0)-3, "Unum(252)") 26 | ck(m_2, "m_2") 27 | ck(m_1, "m_1") 28 | ck(m0, "m0") 29 | ck(m1, "m1") 30 | ck(m2, "m2") 31 | ck(3, "Unum(3)") 32 | } 33 | 34 | func ck(unum Unum, str string) { 35 | if fmt.Sprint(unum) != str { 36 | panic("unum.go: " + str) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /tools/tools.go/cmd/vet/testdata/asm4.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64 6 | // +build vet_test 7 | 8 | // Test cases for symbolic NOSPLIT etc. on TEXT symbols. 9 | 10 | TEXT ·noprof(SB),NOPROF,$0-8 11 | RET 12 | 13 | TEXT ·dupok(SB),DUPOK,$0-8 14 | RET 15 | 16 | TEXT ·nosplit(SB),NOSPLIT,$0 17 | RET 18 | 19 | TEXT ·rodata(SB),RODATA,$0-8 20 | RET 21 | 22 | TEXT ·noptr(SB),NOPTR|NOSPLIT,$0 23 | RET 24 | 25 | TEXT ·wrapper(SB),WRAPPER,$0-8 26 | RET 27 | -------------------------------------------------------------------------------- /tools/tools.go/cmd/vet/testdata/assign.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file contains tests for the useless-assignment checker. 6 | 7 | package testdata 8 | 9 | type ST struct { 10 | x int 11 | } 12 | 13 | func (s *ST) SetX(x int) { 14 | // Accidental self-assignment; it should be "s.x = x" 15 | x = x // ERROR "self-assignment of x to x" 16 | // Another mistake 17 | s.x = s.x // ERROR "self-assignment of s.x to s.x" 18 | } 19 | -------------------------------------------------------------------------------- /tools/tools.go/cmd/vet/testdata/buildtag.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file contains tests for the buildtag checker. 6 | 7 | // +builder // ERROR "possible malformed \+build comment" 8 | // +build !ignore 9 | 10 | package testdata 11 | 12 | // +build toolate // ERROR "build comment must appear before package clause and be followed by a blank line" 13 | 14 | var _ = 3 15 | -------------------------------------------------------------------------------- /tools/tools.go/cmd/vet/testdata/buildtag_bad.go: -------------------------------------------------------------------------------- 1 | // This file contains misplaced or malformed build constraints. 2 | // The Go tool will skip it, because the constraints are invalid. 3 | // It serves only to test the tag checker during make test. 4 | 5 | // Mention +build // ERROR "possible malformed \+build comment" 6 | 7 | // +build !!bang // ERROR "invalid double negative in build constraint" 8 | // +build @#$ // ERROR "invalid non-alphanumeric build constraint" 9 | 10 | // +build toolate // ERROR "build comment must appear before package clause and be followed by a blank line" 11 | package bad 12 | 13 | // This is package 'bad' rather than 'main' so the erroneous build 14 | // tag doesn't end up looking like a package doc for the vet command 15 | // when examined by godoc. 16 | -------------------------------------------------------------------------------- /tools/tools.go/cmd/vet/testdata/method.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // This file contains tests for the canonical method checker. 6 | 7 | // This file contains the code to check canonical methods. 8 | 9 | package testdata 10 | 11 | import ( 12 | "fmt" 13 | ) 14 | 15 | type MethodTest int 16 | 17 | func (t *MethodTest) Scan(x fmt.ScanState, c byte) { // ERROR "should have signature Scan" 18 | } 19 | 20 | type MethodTestInterface interface { 21 | ReadByte() byte // ERROR "should have signature ReadByte" 22 | } 23 | -------------------------------------------------------------------------------- /tools/tools.go/codereview.cfg: -------------------------------------------------------------------------------- 1 | defaultcc: golang-codereviews@googlegroups.com 2 | contributors: http://go.googlecode.com/hg/CONTRIBUTORS 3 | -------------------------------------------------------------------------------- /tools/tools.go/dashboard/app/app.yaml: -------------------------------------------------------------------------------- 1 | # Update with 2 | # google_appengine/appcfg.py [-V test-build] update . 3 | # 4 | # Using -V test-build will run as test-build.golang.org. 5 | 6 | application: golang-org 7 | version: build 8 | runtime: go 9 | api_version: go1 10 | 11 | handlers: 12 | - url: /static 13 | static_dir: static 14 | - url: /(|gccgo/)log/.+ 15 | script: _go_app 16 | - url: /(|gccgo/)(|commit|packages|result|perf-result|tag|todo|perf|perfdetail|perfgraph|updatebenchmark) 17 | script: _go_app 18 | - url: /(|gccgo/)(init|buildtest|key|perflearn|_ah/queue/go/delay) 19 | script: _go_app 20 | login: admin 21 | 22 | -------------------------------------------------------------------------------- /tools/tools.go/dashboard/app/build/notify.txt: -------------------------------------------------------------------------------- 1 | Change {{shortHash .Commit.Hash}} broke the {{.Builder}} build: 2 | http://{{.Hostname}}/log/{{.LogHash}} 3 | 4 | {{.Commit.Desc}} 5 | 6 | http://code.google.com/p/go/source/detail?r={{shortHash .Commit.Hash}} 7 | 8 | $ tail -200 < log 9 | {{printf "%s" .LogText | tail 200}} 10 | -------------------------------------------------------------------------------- /tools/tools.go/dashboard/app/build/perf_notify.txt: -------------------------------------------------------------------------------- 1 | {{if .Commit}}Change {{shortHash .Commit.Hash}} caused perf changes on {{.Builder}}: 2 | 3 | {{.Commit.Desc}} 4 | 5 | http://code.google.com/p/go/source/detail?r={{shortHash .Commit.Hash}} 6 | {{else}}This changed caused perf changes on {{.Builder}}: 7 | {{end}} 8 | {{range $b := .Benchmarks}} 9 | {{printf "%-16s %12s %12s %10s" $b.Name "old" "new" "delta"}} 10 | {{range $m := $b.Metrics}}{{printf "%-16s %12v %12v %+10.2f" $m.Name $m.Old $m.New $m.Delta}} 11 | {{end}}{{end}} 12 | {{.Url}} 13 | 14 | -------------------------------------------------------------------------------- /tools/tools.go/dashboard/app/cron.yaml: -------------------------------------------------------------------------------- 1 | cron: 2 | - description: updates noise level for benchmarking results 3 | url: /perflearn?update=1 4 | schedule: every 24 hours 5 | 6 | -------------------------------------------------------------------------------- /tools/tools.go/dashboard/app/static/status_alert.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/dashboard/app/static/status_alert.gif -------------------------------------------------------------------------------- /tools/tools.go/dashboard/app/static/status_good.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/dashboard/app/static/status_good.gif -------------------------------------------------------------------------------- /tools/tools.go/dashboard/builder/filemutex_local.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build nacl plan9 solaris 6 | 7 | package main 8 | 9 | import ( 10 | "log" 11 | "sync" 12 | ) 13 | 14 | // FileMutex is similar to sync.RWMutex, but also synchronizes across processes. 15 | // This implementation is a fallback that does not actually provide inter-process synchronization. 16 | type FileMutex struct { 17 | sync.RWMutex 18 | } 19 | 20 | func MakeFileMutex(filename string) *FileMutex { 21 | return &FileMutex{} 22 | } 23 | 24 | func init() { 25 | log.Printf("WARNING: using fake file mutex." + 26 | " Don't run more than one of these at once!!!") 27 | } 28 | -------------------------------------------------------------------------------- /tools/tools.go/dashboard/coordinator/Makefile: -------------------------------------------------------------------------------- 1 | coordinator: main.go 2 | GOOS=linux go build -o coordinator . 3 | 4 | upload: coordinator 5 | cat coordinator | (cd buildongce && go run create.go --write_object=go-builder-data/coordinator) 6 | 7 | -------------------------------------------------------------------------------- /tools/tools.go/dashboard/env/linux-x86-base/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Go Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | # Base builder image: gobuilders/linux-x86-base 6 | 7 | FROM debian:wheezy 8 | MAINTAINER golang-dev 9 | 10 | ENV DEBIAN_FRONTEND noninteractive 11 | 12 | ADD /scripts/install-apt-deps.sh /scripts/ 13 | RUN /scripts/install-apt-deps.sh 14 | 15 | ADD /scripts/build-go-builder.sh /scripts/ 16 | RUN GO_REV=073fc578434b BUILDER_REV=8845ca94a310 /scripts/build-go-builder.sh && test -f /usr/local/bin/builder 17 | -------------------------------------------------------------------------------- /tools/tools.go/dashboard/env/linux-x86-base/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Go Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | docker: Dockerfile 6 | docker build -t gobuilders/linux-x86-base . 7 | 8 | docker-linux.base.tar.gz: docker 9 | docker save gobuilders/linux-x86-base | gzip | (cd ../../coordinator/buildongce && go run create.go --write_object=go-builder-data/docker-linux.base.tar.gz) 10 | 11 | check: docker 12 | docker run gobuilders/linux-x86-base /usr/local/bin/builder -rev=073fc578434b -buildroot=/ -v -report=false linux-amd64-temp 13 | -------------------------------------------------------------------------------- /tools/tools.go/dashboard/env/linux-x86-base/README: -------------------------------------------------------------------------------- 1 | For now, you can at least do a single build of a single revision: 2 | 3 | $ export BUILD=linux-amd64-temp 4 | $ docker run \ 5 | -v $HOME/keys/$BUILD.buildkey:/.gobuildkey \ 6 | gobuilders/linux-x86-base \ 7 | /usr/local/bin/builder -rev=50ac9eded6ad -buildroot=/ -v $BUILD 8 | 9 | TODO(bradfitz): automate with CoreOS + GCE, ala: 10 | https://github.com/bradfitz/camlistore/blob/master/misc/gce/create.go 11 | 12 | -------------------------------------------------------------------------------- /tools/tools.go/dashboard/env/linux-x86-base/scripts/install-apt-deps.sh: -------------------------------------------------------------------------------- 1 | set -ex 2 | 3 | apt-get update 4 | # For running curl to get the hg starter tarballs (faster than hg clone). 5 | apt-get install -y --no-install-recommends curl ca-certificates 6 | # Optionally used by some net/http tests: 7 | apt-get install -y --no-install-recommends strace 8 | # For building Go's bootstrap 'dist' prog 9 | apt-get install -y --no-install-recommends gcc libc6-dev 10 | # For 32-bit builds: 11 | # TODO(bradfitz): move these into a 386 image that derives from this one. 12 | apt-get install -y --no-install-recommends libc6-dev-i386 gcc-multilib 13 | # For interacting with the Go source & subrepos: 14 | apt-get install -y --no-install-recommends mercurial git-core 15 | 16 | apt-get clean 17 | rm -fr /var/lib/apt/lists 18 | -------------------------------------------------------------------------------- /tools/tools.go/dashboard/env/linux-x86-clang/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Go Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | # gobuilders/linux-x86-clang for building with clang instead of gcc. 6 | 7 | FROM debian:wheezy 8 | MAINTAINER golang-dev 9 | 10 | ENV DEBIAN_FRONTEND noninteractive 11 | 12 | ADD /sources/clang-deps.list /etc/apt/sources.list.d/ 13 | 14 | ADD /scripts/install-apt-deps.sh /scripts/ 15 | RUN /scripts/install-apt-deps.sh 16 | 17 | ADD /scripts/build-go-builder.sh /scripts/ 18 | RUN GO_REV=073fc578434b BUILDER_REV=8845ca94a310 /scripts/build-go-builder.sh && test -f /usr/local/bin/builder 19 | 20 | ENV CC /usr/bin/clang -------------------------------------------------------------------------------- /tools/tools.go/dashboard/env/linux-x86-clang/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Go Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | docker: Dockerfile 6 | docker build -t gobuilders/linux-x86-clang . 7 | 8 | docker-linux.clang.tar.gz: docker 9 | docker save gobuilders/linux-x86-clang | gzip | (cd ../../coordinator/buildongce && go run create.go --write_object=go-builder-data/docker-linux.clang.tar.gz) 10 | 11 | check: docker 12 | docker run gobuilders/linux-x86-clang /usr/local/bin/builder -rev=fa76e8393654 -buildroot=/ -v -report=false linux-amd64-temp 13 | 14 | check32: docker 15 | docker run gobuilders/linux-x86-clang /usr/local/bin/builder -rev=fa76e8393654 -buildroot=/ -v -report=false linux-386-temp 16 | -------------------------------------------------------------------------------- /tools/tools.go/dashboard/env/linux-x86-clang/sources/clang-deps.list: -------------------------------------------------------------------------------- 1 | # The debian sources for stable clang builds, taken from http://llvm.org/apt/ 2 | deb http://llvm.org/apt/wheezy/ llvm-toolchain-wheezy main 3 | deb-src http://llvm.org/apt/wheezy/ llvm-toolchain-wheezy main -------------------------------------------------------------------------------- /tools/tools.go/dashboard/env/linux-x86-gccgo/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Go Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | # gobuilders/linux-x86-gccgo for 32- and 64-bit gccgo. 6 | 7 | FROM debian:wheezy 8 | MAINTAINER golang-dev 9 | 10 | ENV DEBIAN_FRONTEND noninteractive 11 | 12 | ADD /scripts/install-apt-deps.sh /scripts/ 13 | RUN /scripts/install-apt-deps.sh 14 | 15 | ADD /scripts/install-gold.sh /scripts/ 16 | RUN /scripts/install-gold.sh 17 | 18 | ADD /scripts/install-gccgo-builder.sh /scripts/ 19 | RUN /scripts/install-gccgo-builder.sh && test -f /usr/local/bin/builder -------------------------------------------------------------------------------- /tools/tools.go/dashboard/env/linux-x86-gccgo/README: -------------------------------------------------------------------------------- 1 | $ export BUILD=linux-amd64-gccgo 2 | $ export BUILDREV=b9151e911a54 3 | $ docker run \ 4 | -v $HOME/keys/$BUILD.buildkey:/.gobuildkey \ 5 | gobuilders/linux-x86-gccgo \ 6 | /usr/local/bin/builder -tool=gccgo -dashboard='https://build.golang.org/gccgo' -rev=$BUILDREV -buildroot=/gccgo -v -cmd='make check-go -kj' $BUILD 7 | -------------------------------------------------------------------------------- /tools/tools.go/dashboard/env/linux-x86-gccgo/scripts/install-gccgo-builder.sh: -------------------------------------------------------------------------------- 1 | set -ex 2 | 3 | # Installs a version of the go.tools dashboard builder that runs the gccgo build 4 | # command assuming there are 16 cores available to speed up build times. 5 | # TODO(cmang): There should be an option in the builder to specify this. 6 | 7 | curl -o /usr/local/bin/builder http://storage.googleapis.com/go-builder-data/gccgo_builder && chmod +x /usr/local/bin/builder 8 | -------------------------------------------------------------------------------- /tools/tools.go/dashboard/env/linux-x86-gccgo/scripts/install-gold.sh: -------------------------------------------------------------------------------- 1 | set -ex 2 | 3 | # gccgo uses the Gold linker from binutils. 4 | export BINUTILS_VERSION=binutils-2.24 5 | mkdir -p binutils-objdir 6 | curl -s http://ftp.gnu.org/gnu/binutils/$BINUTILS_VERSION.tar.gz | tar x --no-same-owner -zv 7 | (cd binutils-objdir && ../$BINUTILS_VERSION/configure --enable-gold --enable-plugins --prefix=/opt/gold && make -sj && make install -sj) 8 | 9 | rm -rf binutils* -------------------------------------------------------------------------------- /tools/tools.go/dashboard/env/linux-x86-nacl/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Go Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | docker: Dockerfile 6 | docker build -t gobuilders/linux-x86-nacl . 7 | 8 | upload: docker 9 | docker save gobuilders/linux-x86-nacl | gzip | (cd ../../coordinator/buildongce && go run create.go --write_object=go-builder-data/docker-linux.nacl.tar.gz) 10 | 11 | check: docker 12 | docker run gobuilders/linux-x86-nacl /usr/local/bin/builder -rev=073fc578434b -buildroot=/ -v -cmd=/usr/local/bin/build-command.pl -report=false nacl-amd64p32-temp 13 | -------------------------------------------------------------------------------- /tools/tools.go/dashboard/env/linux-x86-nacl/README: -------------------------------------------------------------------------------- 1 | $ export BUILD=nacl-amd64p32-temp 2 | $ export BUILDREV=59b1bb4bf045 3 | $ docker run \ 4 | -v $HOME/keys/$BUILD.buildkey:/.gobuildkey \ 5 | gobuilders/linux-x86-nacl \ 6 | /usr/local/bin/builder -rev=$BUILDREV -buildroot=/ -v -cmd=/usr/local/bin/build-command.pl $BUILD 7 | -------------------------------------------------------------------------------- /tools/tools.go/dashboard/env/linux-x86-nacl/build-command.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | 5 | if ($ENV{GOOS} eq "nacl") { 6 | delete $ENV{GOROOT_FINAL}; 7 | exec("./nacltest.bash", @ARGV); 8 | die "Failed to run nacltest.bash: $!\n"; 9 | } 10 | 11 | exec("./all.bash", @ARGV); 12 | die "Failed to run all.bash: $!\n"; 13 | 14 | -------------------------------------------------------------------------------- /tools/tools.go/dashboard/env/linux-x86-nacl/scripts/install-apt-deps.sh: -------------------------------------------------------------------------------- 1 | set -ex 2 | 3 | apt-get update 4 | # For running curl to get the hg starter tarballs (faster than hg clone). 5 | apt-get install -y --no-install-recommends curl ca-certificates 6 | # For building Go's bootstrap 'dist' prog 7 | apt-get install -y --no-install-recommends gcc libc6-dev 8 | # For interacting with the Go source & subrepos: 9 | apt-get install -y --no-install-recommends mercurial git-core 10 | # For 32-bit nacl: 11 | apt-get install -y --no-install-recommends libc6-i386 libc6-dev-i386 lib32stdc++6 gcc-multilib 12 | 13 | apt-get clean 14 | rm -fr /var/lib/apt/lists 15 | -------------------------------------------------------------------------------- /tools/tools.go/dashboard/env/linux-x86-sid/Dockerfile: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Go Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | FROM debian:sid 6 | MAINTAINER golang-dev 7 | 8 | ENV DEBIAN_FRONTEND noninteractive 9 | 10 | ADD /scripts/install-apt-deps.sh /scripts/ 11 | RUN /scripts/install-apt-deps.sh 12 | 13 | ADD /scripts/build-go-builder.sh /scripts/ 14 | RUN GO_REV=073fc578434b BUILDER_REV=8845ca94a310 /scripts/build-go-builder.sh && test -f /usr/local/bin/builder 15 | -------------------------------------------------------------------------------- /tools/tools.go/dashboard/env/linux-x86-sid/Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2014 The Go Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style 3 | # license that can be found in the LICENSE file. 4 | 5 | docker: Dockerfile 6 | docker build -t gobuilders/linux-x86-sid . 7 | 8 | docker-linux.sid.tar.gz: docker 9 | docker save gobuilders/linux-x86-sid | gzip | (cd ../../coordinator/buildongce && go run create.go --write_object=go-builder-data/docker-linux.sid.tar.gz) 10 | 11 | check: docker 12 | docker run gobuilders/linux-x86-sid /usr/local/bin/builder -rev=fa76e8393654 -buildroot=/ -v -report=false linux-amd64-sid 13 | -------------------------------------------------------------------------------- /tools/tools.go/dashboard/env/linux-x86-sid/scripts/install-apt-deps.sh: -------------------------------------------------------------------------------- 1 | set -ex 2 | 3 | apt-get update 4 | # For running curl to get the hg starter tarballs (faster than hg clone). 5 | apt-get install -y --no-install-recommends curl ca-certificates 6 | # Optionally used by some net/http tests: 7 | apt-get install -y --no-install-recommends strace 8 | # For building Go's bootstrap 'dist' prog 9 | apt-get install -y --no-install-recommends gcc libc6-dev 10 | # For 32-bit builds: 11 | # TODO(bradfitz): move these into a 386 image that derives from this one. 12 | apt-get install -y --no-install-recommends libc6-dev-i386 gcc-multilib 13 | # For interacting with the Go source & subrepos: 14 | apt-get install -y --no-install-recommends mercurial git-core 15 | 16 | apt-get clean 17 | rm -fr /var/lib/apt/lists 18 | -------------------------------------------------------------------------------- /tools/tools.go/go/exact/go13.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.4 6 | 7 | package exact 8 | 9 | import ( 10 | "math" 11 | "math/big" 12 | ) 13 | 14 | func ratToFloat32(x *big.Rat) (float32, bool) { 15 | // Before 1.4, there's no Rat.Float32. 16 | // Emulate it, albeit at the cost of 17 | // imprecision in corner cases. 18 | x64, exact := x.Float64() 19 | x32 := float32(x64) 20 | if math.IsInf(float64(x32), 0) { 21 | exact = false 22 | } 23 | return x32, exact 24 | } 25 | -------------------------------------------------------------------------------- /tools/tools.go/go/exact/go14.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.4 6 | 7 | package exact 8 | 9 | import "math/big" 10 | 11 | func ratToFloat32(x *big.Rat) (float32, bool) { 12 | return x.Float32() 13 | } 14 | -------------------------------------------------------------------------------- /tools/tools.go/go/gccgoimporter/testdata/complexnums.go: -------------------------------------------------------------------------------- 1 | package complexnums 2 | 3 | const NN = -1 - 1i 4 | const NP = -1 + 1i 5 | const PN = 1 - 1i 6 | const PP = 1 + 1i 7 | -------------------------------------------------------------------------------- /tools/tools.go/go/gccgoimporter/testdata/complexnums.gox: -------------------------------------------------------------------------------- 1 | v1; 2 | package complexnums; 3 | pkgpath complexnums; 4 | priority 1; 5 | const NN = -0.1E1-0.1E1i ; 6 | const NP = -0.1E1+0.1E1i ; 7 | const PN = 0.1E1-0.1E1i ; 8 | const PP = 0.1E1+0.1E1i ; 9 | -------------------------------------------------------------------------------- /tools/tools.go/go/gccgoimporter/testdata/imports.go: -------------------------------------------------------------------------------- 1 | package imports 2 | 3 | import "fmt" 4 | 5 | var Hello = fmt.Sprintf("Hello, world") 6 | -------------------------------------------------------------------------------- /tools/tools.go/go/gccgoimporter/testdata/imports.gox: -------------------------------------------------------------------------------- 1 | v1; 2 | package imports; 3 | pkgpath imports; 4 | priority 7; 5 | import fmt fmt "fmt"; 6 | init imports imports..import 7 math math..import 1 runtime runtime..import 1 strconv strconv..import 2 io io..import 3 reflect reflect..import 3 syscall syscall..import 3 time time..import 4 os os..import 5 fmt fmt..import 6; 7 | var Hello ; 8 | -------------------------------------------------------------------------------- /tools/tools.go/go/gccgoimporter/testdata/pointer.go: -------------------------------------------------------------------------------- 1 | package pointer 2 | 3 | type Int8Ptr *int8 4 | -------------------------------------------------------------------------------- /tools/tools.go/go/gccgoimporter/testdata/pointer.gox: -------------------------------------------------------------------------------- 1 | v1; 2 | package pointer; 3 | pkgpath pointer; 4 | type >>; 5 | -------------------------------------------------------------------------------- /tools/tools.go/go/loader/testdata/a.go: -------------------------------------------------------------------------------- 1 | package P 2 | -------------------------------------------------------------------------------- /tools/tools.go/go/loader/testdata/b.go: -------------------------------------------------------------------------------- 1 | package P 2 | -------------------------------------------------------------------------------- /tools/tools.go/go/pointer/testdata/hello.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | import ( 6 | "fmt" 7 | "os" 8 | ) 9 | 10 | type S int 11 | 12 | var theS S 13 | 14 | func (s *S) String() string { 15 | print(s) // @pointsto main.theS 16 | return "" 17 | } 18 | 19 | func main() { 20 | // os.Args is considered intrinsically allocated, 21 | // but may also be set explicitly (e.g. on Windows), hence '...'. 22 | print(os.Args) // @pointsto | ... 23 | fmt.Println("Hello, World!", &theS) 24 | } 25 | 26 | // @calls main.main -> fmt.Println 27 | // @calls (*fmt.pp).handleMethods -> (*main.S).String 28 | -------------------------------------------------------------------------------- /tools/tools.go/go/pointer/testdata/issue9002.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | // Regression test for golang issue 9002. 5 | // 6 | // The two-result "value,ok" receive operation generated a 7 | // too-wide constraint loading (value int, ok bool), not bool, 8 | // from the channel. 9 | // 10 | // This bug manifested itself in an out-of-bounds array access 11 | // when the makechan object was the highest-numbered node, as in 12 | // this program. 13 | // 14 | // In more realistic programs it silently resulted in bogus 15 | // constraints. 16 | _, _ = <-make(chan int) 17 | } 18 | -------------------------------------------------------------------------------- /tools/tools.go/go/pointer/testdata/recur.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | // Analysis abstraction of recursive calls is finite. 6 | 7 | func main() { 8 | main() 9 | } 10 | 11 | // @calls main.main -> main.main 12 | -------------------------------------------------------------------------------- /tools/tools.go/go/pointer/testdata/rtti.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Regression test for oracle crash 4 | // https://code.google.com/p/go/issues/detail?id=6605 5 | // 6 | // Using reflection, methods may be called on types that are not the 7 | // operand of any ssa.MakeInterface instruction. In this example, 8 | // (Y).F is called by deriving the type Y from *Y. Prior to the fix, 9 | // no RTTI (or method set) for type Y was included in the program, so 10 | // the F() call would crash. 11 | 12 | import "reflect" 13 | 14 | var a int 15 | 16 | type X struct{} 17 | 18 | func (X) F() *int { 19 | return &a 20 | } 21 | 22 | type I interface { 23 | F() *int 24 | } 25 | 26 | func main() { 27 | type Y struct{ X } 28 | print(reflect.Indirect(reflect.ValueOf(new(Y))).Interface().(I).F()) // @pointsto main.a 29 | } 30 | -------------------------------------------------------------------------------- /tools/tools.go/go/pointer/testdata/timer.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package main 4 | 5 | import "time" 6 | 7 | func after() {} 8 | 9 | func main() { 10 | // @calls time.startTimer -> time.sendTime 11 | ticker := time.NewTicker(1) 12 | <-ticker.C 13 | 14 | // @calls time.startTimer -> time.sendTime 15 | timer := time.NewTimer(time.Second) 16 | <-timer.C 17 | 18 | // @calls time.startTimer -> time.goFunc 19 | // @calls time.goFunc -> main.after 20 | timer = time.AfterFunc(time.Second, after) 21 | <-timer.C 22 | } 23 | 24 | // @calls time.sendTime -> time.Now 25 | -------------------------------------------------------------------------------- /tools/tools.go/go/ssa/interp/external_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin 6 | 7 | package interp 8 | 9 | import "syscall" 10 | 11 | func init() { 12 | externals["syscall.Sysctl"] = ext۰syscall۰Sysctl 13 | } 14 | 15 | func ext۰syscall۰Sysctl(fr *frame, args []value) value { 16 | r, err := syscall.Sysctl(args[0].(string)) 17 | return tuple{r, wrapError(err)} 18 | } 19 | -------------------------------------------------------------------------------- /tools/tools.go/go/ssa/interp/external_freebsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build freebsd 6 | 7 | package interp 8 | 9 | import "syscall" 10 | 11 | func init() { 12 | externals["syscall.Sysctl"] = ext۰syscall۰Sysctl 13 | externals["syscall.SysctlUint32"] = ext۰syscall۰SysctlUint32 14 | } 15 | 16 | func ext۰syscall۰Sysctl(fr *frame, args []value) value { 17 | r, err := syscall.Sysctl(args[0].(string)) 18 | return tuple{r, wrapError(err)} 19 | } 20 | 21 | func ext۰syscall۰SysctlUint32(fr *frame, args []value) value { 22 | r, err := syscall.SysctlUint32(args[0].(string)) 23 | return tuple{r, wrapError(err)} 24 | } 25 | -------------------------------------------------------------------------------- /tools/tools.go/go/ssa/interp/testdata/a_test.go: -------------------------------------------------------------------------------- 1 | package a 2 | 3 | import "testing" 4 | 5 | func TestFoo(t *testing.T) { 6 | t.Error("foo") 7 | } 8 | 9 | func TestBar(t *testing.T) { 10 | t.Error("bar") 11 | } 12 | 13 | func BenchmarkWiz(b *testing.B) { 14 | b.Error("wiz") 15 | } 16 | 17 | // Don't test Examples since that testing package needs pipe(2) for that. 18 | -------------------------------------------------------------------------------- /tools/tools.go/go/ssa/interp/testdata/b_test.go: -------------------------------------------------------------------------------- 1 | package b 2 | 3 | import "testing" 4 | 5 | func NotATest(t *testing.T) { 6 | t.Error("foo") 7 | } 8 | 9 | func NotABenchmark(b *testing.B) { 10 | b.Error("wiz") 11 | } 12 | -------------------------------------------------------------------------------- /tools/tools.go/go/ssa/interp/testdata/recover.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Tests of panic/recover. 4 | 5 | import "fmt" 6 | 7 | func fortyTwo() (r int) { 8 | r = 42 9 | // The next two statements simulate a 'return' statement. 10 | defer func() { recover() }() 11 | panic(nil) 12 | } 13 | 14 | func zero() int { 15 | defer func() { recover() }() 16 | panic(1) 17 | } 18 | 19 | func zeroEmpty() (int, string) { 20 | defer func() { recover() }() 21 | panic(1) 22 | } 23 | 24 | func main() { 25 | if r := fortyTwo(); r != 42 { 26 | panic(r) 27 | } 28 | if r := zero(); r != 0 { 29 | panic(r) 30 | } 31 | if r, s := zeroEmpty(); r != 0 || s != "" { 32 | panic(fmt.Sprint(r, s)) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tools/tools.go/go/types/go11.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !go1.2 6 | 7 | package types 8 | 9 | import "go/ast" 10 | 11 | func slice3(x *ast.SliceExpr) bool { 12 | return false 13 | } 14 | 15 | func sliceMax(x *ast.SliceExpr) ast.Expr { 16 | return nil 17 | } 18 | -------------------------------------------------------------------------------- /tools/tools.go/go/types/go12.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.2 6 | 7 | package types 8 | 9 | import "go/ast" 10 | 11 | func slice3(x *ast.SliceExpr) bool { 12 | return x.Slice3 13 | } 14 | 15 | func sliceMax(x *ast.SliceExpr) ast.Expr { 16 | return x.Max 17 | } 18 | -------------------------------------------------------------------------------- /tools/tools.go/go/types/testdata/blank.src: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package _ /* ERROR invalid package name */ 6 | -------------------------------------------------------------------------------- /tools/tools.go/go/types/testdata/expr1.src: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // binary expressions 6 | 7 | package expr1 8 | -------------------------------------------------------------------------------- /tools/tools.go/go/types/testdata/importdecl1a.src: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Test case for issue 8969. 6 | 7 | package importdecl1 8 | 9 | import . "unsafe" 10 | 11 | var _ Pointer // use dot-imported package unsafe 12 | -------------------------------------------------------------------------------- /tools/tools.go/go/types/testdata/importdecl1b.src: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package importdecl1 6 | 7 | import . /* ERROR "imported but not used" */ "unsafe" 8 | -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/analysis/call-eg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/analysis/call-eg.png -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/analysis/call3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/analysis/call3.png -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/analysis/callers1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/analysis/callers1.png -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/analysis/callers2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/analysis/callers2.png -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/analysis/chan1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/analysis/chan1.png -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/analysis/chan2a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/analysis/chan2a.png -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/analysis/chan2b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/analysis/chan2b.png -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/analysis/error1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/analysis/error1.png -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/analysis/ident-def.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/analysis/ident-def.png -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/analysis/ident-field.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/analysis/ident-field.png -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/analysis/ident-func.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/analysis/ident-func.png -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/analysis/ipcg-func.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/analysis/ipcg-func.png -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/analysis/ipcg-pkg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/analysis/ipcg-pkg.png -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/analysis/typeinfo-pkg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/analysis/typeinfo-pkg.png -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/analysis/typeinfo-src.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/analysis/typeinfo-src.png -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/callgraph.html: -------------------------------------------------------------------------------- 1 | 16 | -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/codewalkdir.html: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | {{range .}} 9 | 10 | {{$name_html := html .Name}} 11 | 12 | 13 | 14 | 15 | {{end}} 16 |
{{$name_html}} {{html .Title}}
17 | -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package static exports a map of static file content that supports the godoc 6 | // user interface. The map should be used with the mapfs package, see 7 | // code.google.com/p/go.tools/godoc/vfs/mapfs. 8 | package static 9 | -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/error.html: -------------------------------------------------------------------------------- 1 | 6 | 7 |

8 | {{html .}} 9 |

10 | -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/gen.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package static 6 | 7 | //go:generate go run makestatic.go 8 | -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/images/minus.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/images/minus.gif -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/images/plus.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/images/plus.gif -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/images/treeview-black-line.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/images/treeview-black-line.gif -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/images/treeview-black.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/images/treeview-black.gif -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/images/treeview-default-line.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/images/treeview-default-line.gif -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/images/treeview-default.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/images/treeview-default.gif -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/images/treeview-gray-line.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/images/treeview-gray-line.gif -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/images/treeview-gray.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gerryyang/goinaction/711792fd47bcb96b345f36bc53ea16f6abf5dfd0/tools/tools.go/godoc/static/images/treeview-gray.gif -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/implements.html: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/methodset.html: -------------------------------------------------------------------------------- 1 | 10 | -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/opensearch.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | godoc 4 | The Go Programming Language 5 | go golang 6 | 7 | 8 | /favicon.ico 9 | UTF-8 10 | UTF-8 11 | 12 | -------------------------------------------------------------------------------- /tools/tools.go/godoc/static/search.html: -------------------------------------------------------------------------------- 1 | 6 | {{with .Alert}} 7 |

8 | {{html .}} 9 |

10 | {{end}} 11 | {{with .Alt}} 12 |

13 | Did you mean: 14 | {{range .Alts}} 15 | {{html .}} 16 | {{end}} 17 |

18 | {{end}} 19 | -------------------------------------------------------------------------------- /tools/tools.go/imports/sortimports_compat.go: -------------------------------------------------------------------------------- 1 | // +build !go1.2 2 | 3 | // Copyright 2013 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package imports 8 | 9 | import "go/ast" 10 | 11 | // Go 1.1 users don't get fancy package grouping. 12 | // But this is still gofmt-compliant: 13 | 14 | var sortImports = ast.SortImports 15 | -------------------------------------------------------------------------------- /tools/tools.go/oracle/testdata/src/lib/lib.go: -------------------------------------------------------------------------------- 1 | package lib 2 | 3 | type Type int 4 | 5 | func (Type) Method(x *int) *int { 6 | return x 7 | } 8 | 9 | func Func() { 10 | } 11 | 12 | const Const = 3 13 | 14 | var Var = 0 15 | -------------------------------------------------------------------------------- /tools/tools.go/oracle/testdata/src/main/callgraph2.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Tests of call-graph queries. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See callgraph2.golden for expected query results. 6 | 7 | // (Regression test for pointer analysis: programs that use reflection 8 | // create some cgnodes before the root of the callgraph.) 9 | import _ "reflect" 10 | 11 | func f() {} 12 | func main() { 13 | f() 14 | } 15 | 16 | // @callgraph callgraph "^" 17 | -------------------------------------------------------------------------------- /tools/tools.go/oracle/testdata/src/main/callgraph2.golden: -------------------------------------------------------------------------------- 1 | -------- @callgraph callgraph -------- 2 | 3 | Below is a call graph of package main. 4 | The numbered nodes form a spanning tree. 5 | Non-numbered nodes indicate back- or cross-edges to the node whose 6 | number follows in parentheses. 7 | 8 | 0 init 9 | 1 main 10 | 2 f 11 | 12 | -------------------------------------------------------------------------------- /tools/tools.go/oracle/testdata/src/main/calls-json.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Tests of call-graph queries, -format=json. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See calls-json.golden for expected query results. 6 | 7 | func call(f func()) { 8 | f() // @callees @callees-f "f" 9 | } 10 | 11 | func main() { 12 | call(func() { 13 | // @callers callers-main.anon "^" 14 | // @callstack callstack-main.anon "^" 15 | }) 16 | } 17 | -------------------------------------------------------------------------------- /tools/tools.go/oracle/testdata/src/main/describe-json.go: -------------------------------------------------------------------------------- 1 | package describe // @describe pkgdecl "describe" 2 | 3 | // Tests of 'describe' query, -format=json. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See describe-json.golden for expected query results. 6 | 7 | func main() { // 8 | var s struct{ x [3]int } 9 | p := &s.x[0] // @describe desc-val-p "p" 10 | _ = p 11 | 12 | var i I = C(0) 13 | if i == nil { 14 | i = new(D) 15 | } 16 | print(i) // @describe desc-val-i "\\bi\\b" 17 | 18 | go main() // @describe desc-stmt "go" 19 | } 20 | 21 | type I interface { 22 | f() 23 | } 24 | 25 | type C int // @describe desc-type-C "C" 26 | type D struct{} 27 | 28 | func (c C) f() {} 29 | func (d *D) f() {} 30 | -------------------------------------------------------------------------------- /tools/tools.go/oracle/testdata/src/main/freevars.golden: -------------------------------------------------------------------------------- 1 | -------- @freevars fv1 -------- 2 | Free identifiers: 3 | type C 4 | const exp int 5 | var x int 6 | 7 | -------- @freevars fv2 -------- 8 | Free identifiers: 9 | var s.t.a int 10 | var s.t.b int 11 | var s.x int 12 | var x int 13 | var y rune 14 | 15 | -------- @freevars fv3 -------- 16 | Free identifiers: 17 | var x int 18 | 19 | -------------------------------------------------------------------------------- /tools/tools.go/oracle/testdata/src/main/implements-json.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | // Tests of 'implements' query, -output=json. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See implements.golden for expected query results. 6 | 7 | func main() { 8 | } 9 | 10 | type E interface{} // @implements E "E" 11 | 12 | type F interface { // @implements F "F" 13 | f() 14 | } 15 | 16 | type FG interface { // @implements FG "FG" 17 | f() 18 | g() []int // @implements slice "..int" 19 | } 20 | 21 | type C int // @implements C "C" 22 | type D struct{} 23 | 24 | func (c *C) f() {} // @implements starC ".C" 25 | func (d D) f() {} // @implements D "D" 26 | 27 | func (d *D) g() []int { return nil } // @implements starD ".D" 28 | -------------------------------------------------------------------------------- /tools/tools.go/oracle/testdata/src/main/multi.go: -------------------------------------------------------------------------------- 1 | package multi 2 | 3 | func g(x int) { 4 | } 5 | 6 | func f() { 7 | x := 1 8 | g(x) // "g(x)" is the selection for multiple queries 9 | } 10 | 11 | func main() { 12 | f() 13 | } 14 | -------------------------------------------------------------------------------- /tools/tools.go/oracle/testdata/src/main/peers-json.go: -------------------------------------------------------------------------------- 1 | package peers 2 | 3 | // Tests of channel 'peers' query, -format=json. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See peers-json.golden for expected query results. 6 | 7 | func main() { 8 | chA := make(chan *int) 9 | <-chA 10 | select { 11 | case <-chA: // @peers peer-recv-chA "<-" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tools/tools.go/oracle/testdata/src/main/peers-json.golden: -------------------------------------------------------------------------------- 1 | -------- @peers peer-recv-chA -------- 2 | { 3 | "mode": "peers", 4 | "peers": { 5 | "pos": "testdata/src/main/peers-json.go:11:7", 6 | "type": "chan *int", 7 | "allocs": [ 8 | "testdata/src/main/peers-json.go:8:13" 9 | ], 10 | "receives": [ 11 | "testdata/src/main/peers-json.go:9:2", 12 | "testdata/src/main/peers-json.go:11:7" 13 | ] 14 | } 15 | } -------------------------------------------------------------------------------- /tools/tools.go/oracle/testdata/src/main/pointsto-json.go: -------------------------------------------------------------------------------- 1 | package pointsto 2 | 3 | // Tests of 'pointsto' queries, -format=json. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See pointsto-json.golden for expected query results. 6 | 7 | func main() { // 8 | var s struct{ x [3]int } 9 | p := &s.x[0] // @pointsto val-p "p" 10 | _ = p 11 | 12 | var i I = C(0) 13 | if i == nil { 14 | i = new(D) 15 | } 16 | print(i) // @pointsto val-i "\\bi\\b" 17 | } 18 | 19 | type I interface { 20 | f() 21 | } 22 | 23 | type C int 24 | type D struct{} 25 | 26 | func (c C) f() {} 27 | func (d *D) f() {} 28 | -------------------------------------------------------------------------------- /tools/tools.go/oracle/testdata/src/main/pointsto-json.golden: -------------------------------------------------------------------------------- 1 | -------- @pointsto val-p -------- 2 | { 3 | "mode": "pointsto", 4 | "pointsto": [ 5 | { 6 | "type": "*int", 7 | "labels": [ 8 | { 9 | "pos": "testdata/src/main/pointsto-json.go:8:6", 10 | "desc": "s.x[*]" 11 | } 12 | ] 13 | } 14 | ] 15 | }-------- @pointsto val-i -------- 16 | { 17 | "mode": "pointsto", 18 | "pointsto": [ 19 | { 20 | "type": "*D", 21 | "namepos": "testdata/src/main/pointsto-json.go:24:6", 22 | "labels": [ 23 | { 24 | "pos": "testdata/src/main/pointsto-json.go:14:10", 25 | "desc": "new" 26 | } 27 | ] 28 | }, 29 | { 30 | "type": "C", 31 | "namepos": "testdata/src/main/pointsto-json.go:23:6" 32 | } 33 | ] 34 | } -------------------------------------------------------------------------------- /tools/tools.go/oracle/testdata/src/main/referrers-json.go: -------------------------------------------------------------------------------- 1 | package referrers 2 | 3 | // Tests of 'referrers' query. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See referrers.golden for expected query results. 6 | 7 | import "lib" 8 | 9 | type s struct { 10 | f int 11 | } 12 | 13 | func main() { 14 | var v lib.Type = lib.Const // @referrers ref-package "lib" 15 | _ = v.Method // @referrers ref-method "Method" 16 | _ = v.Method 17 | v++ //@referrers ref-local "v" 18 | v++ 19 | 20 | _ = s{}.f // @referrers ref-field "f" 21 | 22 | var s2 s 23 | s2.f = 1 24 | } 25 | -------------------------------------------------------------------------------- /tools/tools.go/oracle/testdata/src/main/reflection.go: -------------------------------------------------------------------------------- 1 | package reflection 2 | 3 | // This is a test of 'pointsto', but we split it into a separate file 4 | // so that pointsto.go doesn't have to import "reflect" each time. 5 | 6 | import "reflect" 7 | 8 | var a int 9 | var b bool 10 | 11 | func main() { 12 | m := make(map[*int]*bool) 13 | m[&a] = &b 14 | 15 | mrv := reflect.ValueOf(m) 16 | if a > 0 { 17 | mrv = reflect.ValueOf(&b) 18 | } 19 | if a > 0 { 20 | mrv = reflect.ValueOf(&a) 21 | } 22 | 23 | _ = mrv // @pointsto mrv "mrv" 24 | p1 := mrv.Interface() // @pointsto p1 "p1" 25 | p2 := mrv.MapKeys() // @pointsto p2 "p2" 26 | p3 := p2[0] // @pointsto p3 "p3" 27 | p4 := reflect.TypeOf(p1) // @pointsto p4 "p4" 28 | 29 | _, _, _, _ = p1, p2, p3, p4 30 | } 31 | -------------------------------------------------------------------------------- /tools/tools.go/oracle/testdata/src/main/what-json.go: -------------------------------------------------------------------------------- 1 | package what 2 | 3 | // Tests of 'what' queries, -format=json. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See what-json.golden for expected query results. 6 | 7 | func main() { 8 | f() // @what call "f" 9 | } 10 | -------------------------------------------------------------------------------- /tools/tools.go/oracle/testdata/src/main/what.go: -------------------------------------------------------------------------------- 1 | package what // @what pkgdecl "what" 2 | 3 | // Tests of 'what' queries. 4 | // See go.tools/oracle/oracle_test.go for explanation. 5 | // See what.golden for expected query results. 6 | 7 | func main() { 8 | f() // @what call "f" 9 | var ch chan int // @what var "var" 10 | <-ch // @what recv "ch" 11 | } 12 | -------------------------------------------------------------------------------- /tools/tools.go/playground/appengine.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build appengine 6 | 7 | package playground 8 | 9 | import ( 10 | "net/http" 11 | 12 | "appengine" 13 | "appengine/urlfetch" 14 | ) 15 | 16 | func client(r *http.Request) *http.Client { 17 | return urlfetch.Client(appengine.NewContext(r)) 18 | } 19 | 20 | func report(r *http.Request, err error) { 21 | appengine.NewContext(r).Errorf("%v", err) 22 | } 23 | -------------------------------------------------------------------------------- /tools/tools.go/playground/local.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !appengine 6 | 7 | package playground 8 | 9 | import ( 10 | "log" 11 | "net/http" 12 | ) 13 | 14 | func client(r *http.Request) *http.Client { 15 | return http.DefaultClient 16 | } 17 | 18 | func report(r *http.Request, err error) { 19 | log.Println(err) 20 | } 21 | -------------------------------------------------------------------------------- /tools/tools.go/present/caption.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package present 6 | 7 | import "strings" 8 | 9 | func init() { 10 | Register("caption", parseCaption) 11 | } 12 | 13 | type Caption struct { 14 | Text string 15 | } 16 | 17 | func (c Caption) TemplateName() string { return "caption" } 18 | 19 | func parseCaption(_ *Context, _ string, _ int, text string) (Elem, error) { 20 | text = strings.TrimSpace(strings.TrimPrefix(text, ".caption")) 21 | return Caption{text}, nil 22 | } 23 | -------------------------------------------------------------------------------- /tools/tools.go/present/html.go: -------------------------------------------------------------------------------- 1 | package present 2 | 3 | import ( 4 | "errors" 5 | "html/template" 6 | "path/filepath" 7 | "strings" 8 | ) 9 | 10 | func init() { 11 | Register("html", parseHTML) 12 | } 13 | 14 | func parseHTML(ctx *Context, fileName string, lineno int, text string) (Elem, error) { 15 | p := strings.Fields(text) 16 | if len(p) != 2 { 17 | return nil, errors.New("invalid .html args") 18 | } 19 | name := filepath.Join(filepath.Dir(fileName), p[1]) 20 | b, err := ctx.ReadFile(name) 21 | if err != nil { 22 | return nil, err 23 | } 24 | return HTML{template.HTML(b)}, nil 25 | } 26 | 27 | type HTML struct { 28 | template.HTML 29 | } 30 | 31 | func (s HTML) TemplateName() string { return "html" } 32 | -------------------------------------------------------------------------------- /tools/tools.go/refactor/README: -------------------------------------------------------------------------------- 1 | code.google.com/p/go.tools/refactor: libraries for refactoring tools. 2 | -------------------------------------------------------------------------------- /tools/tools.go/refactor/eg/testdata/A.template: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package template 4 | 5 | // Basic test of type-aware expression refactoring. 6 | 7 | import ( 8 | "errors" 9 | "fmt" 10 | ) 11 | 12 | func before(s string) error { return fmt.Errorf("%s", s) } 13 | func after(s string) error { return errors.New(s) } 14 | -------------------------------------------------------------------------------- /tools/tools.go/refactor/eg/testdata/A2.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package A2 4 | 5 | // This refactoring causes addition of "errors" import. 6 | // TODO(adonovan): fix: it should also remove "fmt". 7 | 8 | import myfmt "fmt" 9 | 10 | func example(n int) { 11 | myfmt.Errorf("%s", "") 12 | } 13 | -------------------------------------------------------------------------------- /tools/tools.go/refactor/eg/testdata/A2.golden: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package A2 4 | 5 | // This refactoring causes addition of "errors" import. 6 | // TODO(adonovan): fix: it should also remove "fmt". 7 | 8 | import ( 9 | myfmt "fmt" 10 | "errors" 11 | ) 12 | 13 | func example(n int) { 14 | errors.New("") 15 | } 16 | -------------------------------------------------------------------------------- /tools/tools.go/refactor/eg/testdata/B.template: -------------------------------------------------------------------------------- 1 | package template 2 | 3 | // Basic test of expression refactoring. 4 | // (Types are not important in this case; it could be done with gofmt -r.) 5 | 6 | import "time" 7 | 8 | func before(t time.Time) time.Duration { return time.Now().Sub(t) } 9 | func after(t time.Time) time.Duration { return time.Since(t) } 10 | -------------------------------------------------------------------------------- /tools/tools.go/refactor/eg/testdata/B1.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package B1 4 | 5 | import "time" 6 | 7 | var startup = time.Now() 8 | 9 | func example() time.Duration { 10 | before := time.Now() 11 | time.Sleep(1) 12 | return time.Now().Sub(before) 13 | } 14 | 15 | func msSinceStartup() int64 { 16 | return int64(time.Now().Sub(startup) / time.Millisecond) 17 | } 18 | -------------------------------------------------------------------------------- /tools/tools.go/refactor/eg/testdata/B1.golden: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package B1 4 | 5 | import "time" 6 | 7 | var startup = time.Now() 8 | 9 | func example() time.Duration { 10 | before := time.Now() 11 | time.Sleep(1) 12 | return time.Since(before) 13 | } 14 | 15 | func msSinceStartup() int64 { 16 | return int64(time.Since(startup) / time.Millisecond) 17 | } 18 | -------------------------------------------------------------------------------- /tools/tools.go/refactor/eg/testdata/C.template: -------------------------------------------------------------------------------- 1 | package template 2 | 3 | // Test of repeated use of wildcard in pattern. 4 | 5 | // NB: multiple patterns would be required to handle variants such as 6 | // s[:len(s)], s[x:len(s)], etc, since a wildcard can't match nothing at all. 7 | // TODO(adonovan): support multiple templates in a single pass. 8 | 9 | func before(s string) string { return s[:len(s)] } 10 | func after(s string) string { return s } 11 | -------------------------------------------------------------------------------- /tools/tools.go/refactor/eg/testdata/C1.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package C1 4 | 5 | import "strings" 6 | 7 | func example() { 8 | x := "foo" 9 | println(x[:len(x)]) 10 | 11 | // Match, but the transformation is not sound w.r.t. possible side effects. 12 | println(strings.Repeat("*", 3)[:len(strings.Repeat("*", 3))]) 13 | 14 | // No match, since second use of wildcard doesn't match first. 15 | println(strings.Repeat("*", 3)[:len(strings.Repeat("*", 2))]) 16 | 17 | // Recursive match demonstrating bottom-up rewrite: 18 | // only after the inner replacement occurs does the outer syntax match. 19 | println((x[:len(x)])[:len(x[:len(x)])]) 20 | // -> (x[:len(x)]) 21 | // -> x 22 | } 23 | -------------------------------------------------------------------------------- /tools/tools.go/refactor/eg/testdata/C1.golden: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package C1 4 | 5 | import "strings" 6 | 7 | func example() { 8 | x := "foo" 9 | println(x) 10 | 11 | // Match, but the transformation is not sound w.r.t. possible side effects. 12 | println(strings.Repeat("*", 3)) 13 | 14 | // No match, since second use of wildcard doesn't match first. 15 | println(strings.Repeat("*", 3)[:len(strings.Repeat("*", 2))]) 16 | 17 | // Recursive match demonstrating bottom-up rewrite: 18 | // only after the inner replacement occurs does the outer syntax match. 19 | println(x) 20 | // -> (x[:len(x)]) 21 | // -> x 22 | } 23 | -------------------------------------------------------------------------------- /tools/tools.go/refactor/eg/testdata/D.template: -------------------------------------------------------------------------------- 1 | package template 2 | 3 | import "fmt" 4 | 5 | // Test of semantic (not syntactic) matching of basic literals. 6 | 7 | func before() (int, error) { return fmt.Println(123, "a") } 8 | func after() (int, error) { return fmt.Println(456, "!") } 9 | -------------------------------------------------------------------------------- /tools/tools.go/refactor/eg/testdata/D1.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package D1 4 | 5 | import "fmt" 6 | 7 | func example() { 8 | fmt.Println(123, "a") // match 9 | fmt.Println(0x7b, `a`) // match 10 | fmt.Println(0173, "\x61") // match 11 | fmt.Println(100+20+3, "a"+"") // no match: constant expressions, but not basic literals 12 | } 13 | -------------------------------------------------------------------------------- /tools/tools.go/refactor/eg/testdata/D1.golden: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package D1 4 | 5 | import "fmt" 6 | 7 | func example() { 8 | fmt.Println(456, "!") // match 9 | fmt.Println(456, "!") // match 10 | fmt.Println(456, "!") // match 11 | fmt.Println(100+20+3, "a"+"") // no match: constant expressions, but not basic literals 12 | } 13 | -------------------------------------------------------------------------------- /tools/tools.go/refactor/eg/testdata/E.template: -------------------------------------------------------------------------------- 1 | package template 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "os" 7 | ) 8 | 9 | // Replace call to void function by call to non-void function. 10 | 11 | func before(x interface{}) { log.Fatal(x) } 12 | func after(x interface{}) { fmt.Fprintf(os.Stderr, "warning: %v", x) } 13 | -------------------------------------------------------------------------------- /tools/tools.go/refactor/eg/testdata/E1.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package E1 4 | 5 | import "log" 6 | 7 | func example() { 8 | log.Fatal("oops") // match 9 | } 10 | -------------------------------------------------------------------------------- /tools/tools.go/refactor/eg/testdata/E1.golden: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | package E1 4 | 5 | import ( 6 | "log" 7 | "os" 8 | "fmt" 9 | ) 10 | 11 | func example() { 12 | fmt.Fprintf(os.Stderr, "warning: %v", "oops") // match 13 | } 14 | -------------------------------------------------------------------------------- /tools/tools.go/refactor/eg/testdata/F.template: -------------------------------------------------------------------------------- 1 | package templates 2 | 3 | // Test 4 | 5 | import "sync" 6 | 7 | func before(s sync.RWMutex) { s.Lock() } 8 | func after(s sync.RWMutex) { s.RLock() } -------------------------------------------------------------------------------- /tools/tools.go/refactor/eg/testdata/bad_type.template: -------------------------------------------------------------------------------- 1 | package template 2 | 3 | // Test in which replacement has a different type. 4 | 5 | const shouldFail = "int is not a safe replacement for string" 6 | 7 | func before() interface{} { return "three" } 8 | func after() interface{} { return 3 } 9 | -------------------------------------------------------------------------------- /tools/tools.go/refactor/eg/testdata/expr_type_mismatch.template: -------------------------------------------------------------------------------- 1 | package template 2 | 3 | import ( 4 | "crypto/x509" 5 | "fmt" 6 | ) 7 | 8 | // This test demonstrates a false negative: according to the language 9 | // rules this replacement should be ok, but types.Assignable doesn't work 10 | // in the expected way (elementwise assignability) for tuples. 11 | // Perhaps that's even a type-checker bug? 12 | const shouldFail = "(n int, err error) is not a safe replacement for (key interface{}, err error)" 13 | 14 | func before() (interface{}, error) { return x509.ParsePKCS8PrivateKey(nil) } 15 | func after() (interface{}, error) { return fmt.Print() } 16 | -------------------------------------------------------------------------------- /tools/tools.go/refactor/eg/testdata/no_after_return.template: -------------------------------------------------------------------------------- 1 | package template 2 | 3 | const shouldFail = "after: must contain a single statement" 4 | 5 | func before() int { return 0 } 6 | func after() int { println(); return 0 } 7 | -------------------------------------------------------------------------------- /tools/tools.go/refactor/eg/testdata/no_before.template: -------------------------------------------------------------------------------- 1 | package template 2 | 3 | const shouldFail = "no 'before' func found in template" 4 | 5 | func Before() {} 6 | -------------------------------------------------------------------------------- /tools/tools.go/refactor/eg/testdata/type_mismatch.template: -------------------------------------------------------------------------------- 1 | package template 2 | 3 | const shouldFail = "different signatures" 4 | 5 | func before() int { return 0 } 6 | func after() string { return "" } 7 | --------------------------------------------------------------------------------