├── .codeclimate.yml ├── .gitattributes ├── .github └── ISSUE_TEMPLATE.md ├── .gitignore ├── .travis.yml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── _config.yml ├── benchmark.rb ├── bzt.yml ├── cmd └── binder │ ├── Readme.md │ └── main.go ├── codecov.yml ├── compiler ├── ast │ ├── ast.go │ ├── common_test_helpers.go │ ├── expressions.go │ ├── expressions_test_helpers.go │ ├── statements.go │ ├── statements_test_helpers.go │ ├── testable_expressions.go │ ├── testable_statements.go │ └── variables.go ├── bytecode │ ├── expression_generation.go │ ├── generator.go │ ├── instruction.go │ ├── local_table.go │ └── statement_generation.go ├── compiler.go ├── compiler_test.go ├── lexer │ ├── lexer.go │ └── lexer_test.go ├── parser │ ├── arguments │ │ └── arguments.go │ ├── data_type_parsing.go │ ├── errors │ │ └── errors.go │ ├── events │ │ └── events.go │ ├── expression_parsing.go │ ├── expression_parsing_test.go │ ├── flow_control_parsing.go │ ├── method_call_parsing.go │ ├── method_definition_parsing_test.go │ ├── parser.go │ ├── parser_test.go │ ├── precedence │ │ └── precedence.go │ ├── statement_parsing.go │ ├── statement_parsing_test.go │ └── states │ │ └── states.go └── token │ ├── token.go │ └── token_test.go ├── go.mod ├── go.sum ├── goby.go ├── goby_test.go ├── igb ├── manual_test.md └── repl.go ├── lib ├── array.gb ├── array_enumerator.gb ├── db.gb ├── file.gb ├── integer.gb ├── lazy_enumerator.gb ├── net │ ├── http │ │ ├── request.gb │ │ └── response.gb │ └── simple_server.gb ├── plugin.gb ├── range.gb ├── range_enumerator.gb ├── result.gb ├── ripper.gb └── spec.gb ├── native ├── db │ ├── db.go │ └── db_test.go ├── plugin │ ├── plugin.go │ ├── plugin_generator.go │ ├── plugin_generator_test.go │ ├── plugin_integration_test.go │ └── plugin_test.go ├── result │ ├── bindings.go │ └── result.go └── ripper │ ├── ripper.go │ └── ripper_test.go ├── samples ├── channel.gb ├── constant_resolution.gb ├── error-report.gb ├── file_lib │ └── file.gb ├── http-client.gb ├── http.gb ├── import.gb ├── loop.gb ├── module.gb ├── one_thousand_threads.gb ├── print_name.gb ├── require_relative │ ├── bar.gb │ ├── foo.gb │ └── main.gb ├── sample-1.gb ├── sample-2.gb ├── sample-3.gb ├── sample-4.gb ├── sample-5.gb ├── sample-6.gb ├── sample-7.gb ├── server │ ├── blocking_server.gb │ ├── server.gb │ └── static_file_server.gb ├── stack.gb ├── stdin.gb ├── thread.gb ├── to_json.gb └── unused-variable.gb ├── snap └── snapcraft.yaml ├── specs ├── result_spec.gb ├── spec_spec.gb └── times_spec.gb ├── test_fixtures ├── file_test │ └── size.gb ├── file_with_error.gb ├── import_test │ ├── plugin │ │ ├── lib │ │ │ └── lib.go │ │ └── plugin.go │ └── struct │ │ └── struct.go ├── require_test │ ├── bar.gb │ └── foo.gb ├── server.gb └── test_command_test │ ├── test_spec.gb │ └── test_spec2.gb ├── travis.sh ├── vendor ├── github.com │ ├── chzyer │ │ └── readline │ │ │ ├── .travis.yml │ │ │ ├── CHANGELOG.md │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── ansi_windows.go │ │ │ ├── complete.go │ │ │ ├── complete_helper.go │ │ │ ├── complete_segment.go │ │ │ ├── history.go │ │ │ ├── operation.go │ │ │ ├── password.go │ │ │ ├── rawreader_windows.go │ │ │ ├── readline.go │ │ │ ├── remote.go │ │ │ ├── runebuf.go │ │ │ ├── runes.go │ │ │ ├── search.go │ │ │ ├── std.go │ │ │ ├── std_windows.go │ │ │ ├── term.go │ │ │ ├── term_bsd.go │ │ │ ├── term_linux.go │ │ │ ├── term_solaris.go │ │ │ ├── term_unix.go │ │ │ ├── term_windows.go │ │ │ ├── terminal.go │ │ │ ├── utils.go │ │ │ ├── utils_unix.go │ │ │ ├── utils_windows.go │ │ │ ├── vim.go │ │ │ └── windows_api.go │ ├── dave │ │ └── jennifer │ │ │ ├── LICENSE │ │ │ └── jen │ │ │ ├── add.go │ │ │ ├── comments.go │ │ │ ├── custom.go │ │ │ ├── dict.go │ │ │ ├── do.go │ │ │ ├── file.go │ │ │ ├── generated.go │ │ │ ├── group.go │ │ │ ├── hints.go │ │ │ ├── jen.go │ │ │ ├── lit.go │ │ │ ├── statement.go │ │ │ ├── tag.go │ │ │ └── tokens.go │ ├── dlclark │ │ └── regexp2 │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── ATTRIB │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── match.go │ │ │ ├── regexp.go │ │ │ ├── replace.go │ │ │ ├── runner.go │ │ │ ├── syntax │ │ │ ├── charclass.go │ │ │ ├── code.go │ │ │ ├── escape.go │ │ │ ├── fuzz.go │ │ │ ├── parser.go │ │ │ ├── prefix.go │ │ │ ├── replacerdata.go │ │ │ ├── tree.go │ │ │ └── writer.go │ │ │ └── testoutput1 │ ├── fatih │ │ ├── camelcase │ │ │ ├── .travis.yml │ │ │ ├── LICENSE.md │ │ │ ├── README.md │ │ │ └── camelcase.go │ │ └── structs │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── field.go │ │ │ ├── structs.go │ │ │ └── tags.go │ ├── gorilla │ │ ├── context │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── context.go │ │ │ └── doc.go │ │ └── mux │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── doc.go │ │ │ ├── mux.go │ │ │ ├── regexp.go │ │ │ └── route.go │ ├── jmoiron │ │ └── sqlx │ │ │ ├── .gitignore │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── bind.go │ │ │ ├── doc.go │ │ │ ├── named.go │ │ │ ├── reflectx │ │ │ ├── README.md │ │ │ └── reflect.go │ │ │ └── sqlx.go │ ├── lib │ │ └── pq │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── CONTRIBUTING.md │ │ │ ├── LICENSE.md │ │ │ ├── README.md │ │ │ ├── buf.go │ │ │ ├── conn.go │ │ │ ├── copy.go │ │ │ ├── doc.go │ │ │ ├── encode.go │ │ │ ├── error.go │ │ │ ├── notify.go │ │ │ ├── oid │ │ │ ├── doc.go │ │ │ ├── gen.go │ │ │ └── types.go │ │ │ ├── url.go │ │ │ ├── user_posix.go │ │ │ └── user_windows.go │ ├── looplab │ │ └── fsm │ │ │ ├── .gitignore │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── errors.go │ │ │ ├── event.go │ │ │ ├── fsm.go │ │ │ └── wercker.yml │ ├── mattn │ │ ├── go-colorable │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── colorable_appengine.go │ │ │ ├── colorable_others.go │ │ │ ├── colorable_windows.go │ │ │ └── noncolorable.go │ │ └── go-isatty │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── doc.go │ │ │ ├── isatty_appengine.go │ │ │ ├── isatty_bsd.go │ │ │ ├── isatty_linux.go │ │ │ ├── isatty_others.go │ │ │ ├── isatty_solaris.go │ │ │ └── isatty_windows.go │ ├── pkg │ │ └── profile │ │ │ ├── .travis.yml │ │ │ ├── AUTHORS │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── mutex.go │ │ │ ├── mutex17.go │ │ │ ├── profile.go │ │ │ ├── trace.go │ │ │ └── trace16.go │ └── st0012 │ │ └── metago │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── metago.go │ │ └── test.sh ├── golang.org │ └── x │ │ └── sys │ │ ├── AUTHORS │ │ ├── CONTRIBUTORS │ │ ├── LICENSE │ │ ├── PATENTS │ │ └── unix │ │ ├── .gitignore │ │ ├── README.md │ │ ├── asm_darwin_386.s │ │ ├── asm_darwin_amd64.s │ │ ├── asm_darwin_arm.s │ │ ├── asm_darwin_arm64.s │ │ ├── asm_dragonfly_amd64.s │ │ ├── asm_freebsd_386.s │ │ ├── asm_freebsd_amd64.s │ │ ├── asm_freebsd_arm.s │ │ ├── asm_linux_386.s │ │ ├── asm_linux_amd64.s │ │ ├── asm_linux_arm.s │ │ ├── asm_linux_arm64.s │ │ ├── asm_linux_mips64x.s │ │ ├── asm_linux_mipsx.s │ │ ├── asm_linux_ppc64x.s │ │ ├── asm_linux_s390x.s │ │ ├── asm_netbsd_386.s │ │ ├── asm_netbsd_amd64.s │ │ ├── asm_netbsd_arm.s │ │ ├── asm_openbsd_386.s │ │ ├── asm_openbsd_amd64.s │ │ ├── asm_solaris_amd64.s │ │ ├── bluetooth_linux.go │ │ ├── constants.go │ │ ├── dirent.go │ │ ├── endian_big.go │ │ ├── endian_little.go │ │ ├── env_unix.go │ │ ├── env_unset.go │ │ ├── flock.go │ │ ├── flock_linux_32bit.go │ │ ├── gccgo.go │ │ ├── gccgo_c.c │ │ ├── gccgo_linux_amd64.go │ │ ├── gccgo_linux_sparc64.go │ │ ├── mkall.sh │ │ ├── mkerrors.sh │ │ ├── mkpost.go │ │ ├── mksyscall.pl │ │ ├── mksyscall_solaris.pl │ │ ├── mksysctl_openbsd.pl │ │ ├── mksysnum_darwin.pl │ │ ├── mksysnum_dragonfly.pl │ │ ├── mksysnum_freebsd.pl │ │ ├── mksysnum_netbsd.pl │ │ ├── mksysnum_openbsd.pl │ │ ├── openbsd_pledge.go │ │ ├── race.go │ │ ├── race0.go │ │ ├── sockcmsg_linux.go │ │ ├── sockcmsg_unix.go │ │ ├── str.go │ │ ├── syscall.go │ │ ├── syscall_bsd.go │ │ ├── syscall_darwin.go │ │ ├── syscall_darwin_386.go │ │ ├── syscall_darwin_amd64.go │ │ ├── syscall_darwin_arm.go │ │ ├── syscall_darwin_arm64.go │ │ ├── syscall_dragonfly.go │ │ ├── syscall_dragonfly_amd64.go │ │ ├── syscall_freebsd.go │ │ ├── syscall_freebsd_386.go │ │ ├── syscall_freebsd_amd64.go │ │ ├── syscall_freebsd_arm.go │ │ ├── syscall_linux.go │ │ ├── syscall_linux_386.go │ │ ├── syscall_linux_amd64.go │ │ ├── syscall_linux_amd64_gc.go │ │ ├── syscall_linux_arm.go │ │ ├── syscall_linux_arm64.go │ │ ├── syscall_linux_mips64x.go │ │ ├── syscall_linux_mipsx.go │ │ ├── syscall_linux_ppc64x.go │ │ ├── syscall_linux_s390x.go │ │ ├── syscall_linux_sparc64.go │ │ ├── syscall_netbsd.go │ │ ├── syscall_netbsd_386.go │ │ ├── syscall_netbsd_amd64.go │ │ ├── syscall_netbsd_arm.go │ │ ├── syscall_no_getwd.go │ │ ├── syscall_openbsd.go │ │ ├── syscall_openbsd_386.go │ │ ├── syscall_openbsd_amd64.go │ │ ├── syscall_solaris.go │ │ ├── syscall_solaris_amd64.go │ │ ├── syscall_unix.go │ │ ├── syscall_unix_gc.go │ │ ├── types_darwin.go │ │ ├── types_dragonfly.go │ │ ├── types_freebsd.go │ │ ├── types_netbsd.go │ │ ├── types_openbsd.go │ │ ├── types_solaris.go │ │ ├── zerrors_darwin_386.go │ │ ├── zerrors_darwin_amd64.go │ │ ├── zerrors_darwin_arm.go │ │ ├── zerrors_darwin_arm64.go │ │ ├── zerrors_dragonfly_amd64.go │ │ ├── zerrors_freebsd_386.go │ │ ├── zerrors_freebsd_amd64.go │ │ ├── zerrors_freebsd_arm.go │ │ ├── zerrors_linux_386.go │ │ ├── zerrors_linux_amd64.go │ │ ├── zerrors_linux_arm.go │ │ ├── zerrors_linux_arm64.go │ │ ├── zerrors_linux_mips.go │ │ ├── zerrors_linux_mips64.go │ │ ├── zerrors_linux_mips64le.go │ │ ├── zerrors_linux_mipsle.go │ │ ├── zerrors_linux_ppc64.go │ │ ├── zerrors_linux_ppc64le.go │ │ ├── zerrors_linux_s390x.go │ │ ├── zerrors_linux_sparc64.go │ │ ├── zerrors_netbsd_386.go │ │ ├── zerrors_netbsd_amd64.go │ │ ├── zerrors_netbsd_arm.go │ │ ├── zerrors_openbsd_386.go │ │ ├── zerrors_openbsd_amd64.go │ │ ├── zerrors_solaris_amd64.go │ │ ├── zsyscall_darwin_386.go │ │ ├── zsyscall_darwin_amd64.go │ │ ├── zsyscall_darwin_arm.go │ │ ├── zsyscall_darwin_arm64.go │ │ ├── zsyscall_dragonfly_amd64.go │ │ ├── zsyscall_freebsd_386.go │ │ ├── zsyscall_freebsd_amd64.go │ │ ├── zsyscall_freebsd_arm.go │ │ ├── zsyscall_linux_386.go │ │ ├── zsyscall_linux_amd64.go │ │ ├── zsyscall_linux_arm.go │ │ ├── zsyscall_linux_arm64.go │ │ ├── zsyscall_linux_mips.go │ │ ├── zsyscall_linux_mips64.go │ │ ├── zsyscall_linux_mips64le.go │ │ ├── zsyscall_linux_mipsle.go │ │ ├── zsyscall_linux_ppc64.go │ │ ├── zsyscall_linux_ppc64le.go │ │ ├── zsyscall_linux_s390x.go │ │ ├── zsyscall_linux_sparc64.go │ │ ├── zsyscall_netbsd_386.go │ │ ├── zsyscall_netbsd_amd64.go │ │ ├── zsyscall_netbsd_arm.go │ │ ├── zsyscall_openbsd_386.go │ │ ├── zsyscall_openbsd_amd64.go │ │ ├── zsyscall_solaris_amd64.go │ │ ├── zsysctl_openbsd.go │ │ ├── zsysnum_darwin_386.go │ │ ├── zsysnum_darwin_amd64.go │ │ ├── zsysnum_darwin_arm.go │ │ ├── zsysnum_darwin_arm64.go │ │ ├── zsysnum_dragonfly_amd64.go │ │ ├── zsysnum_freebsd_386.go │ │ ├── zsysnum_freebsd_amd64.go │ │ ├── zsysnum_freebsd_arm.go │ │ ├── zsysnum_linux_386.go │ │ ├── zsysnum_linux_amd64.go │ │ ├── zsysnum_linux_arm.go │ │ ├── zsysnum_linux_arm64.go │ │ ├── zsysnum_linux_mips.go │ │ ├── zsysnum_linux_mips64.go │ │ ├── zsysnum_linux_mips64le.go │ │ ├── zsysnum_linux_mipsle.go │ │ ├── zsysnum_linux_ppc64.go │ │ ├── zsysnum_linux_ppc64le.go │ │ ├── zsysnum_linux_s390x.go │ │ ├── zsysnum_linux_sparc64.go │ │ ├── zsysnum_netbsd_386.go │ │ ├── zsysnum_netbsd_amd64.go │ │ ├── zsysnum_netbsd_arm.go │ │ ├── zsysnum_openbsd_386.go │ │ ├── zsysnum_openbsd_amd64.go │ │ ├── zsysnum_solaris_amd64.go │ │ ├── ztypes_darwin_386.go │ │ ├── ztypes_darwin_amd64.go │ │ ├── ztypes_darwin_arm.go │ │ ├── ztypes_darwin_arm64.go │ │ ├── ztypes_dragonfly_amd64.go │ │ ├── ztypes_freebsd_386.go │ │ ├── ztypes_freebsd_amd64.go │ │ ├── ztypes_freebsd_arm.go │ │ ├── ztypes_linux_386.go │ │ ├── ztypes_linux_amd64.go │ │ ├── ztypes_linux_arm.go │ │ ├── ztypes_linux_arm64.go │ │ ├── ztypes_linux_mips.go │ │ ├── ztypes_linux_mips64.go │ │ ├── ztypes_linux_mips64le.go │ │ ├── ztypes_linux_mipsle.go │ │ ├── ztypes_linux_ppc64.go │ │ ├── ztypes_linux_ppc64le.go │ │ ├── ztypes_linux_s390x.go │ │ ├── ztypes_linux_sparc64.go │ │ ├── ztypes_netbsd_386.go │ │ ├── ztypes_netbsd_amd64.go │ │ ├── ztypes_netbsd_arm.go │ │ ├── ztypes_openbsd_386.go │ │ ├── ztypes_openbsd_amd64.go │ │ └── ztypes_solaris_amd64.go └── modules.txt ├── vm ├── array.go ├── array_enumerator_test.go ├── array_test.go ├── benchmark_test.go ├── block.go ├── block_test.go ├── boolean.go ├── boolean_test.go ├── call_frame.go ├── call_object.go ├── channel.go ├── channel_and_thread_test.go ├── channel_test.go ├── class.go ├── class_test.go ├── classes │ └── classes.go ├── concurrent_array.go ├── concurrent_array_test.go ├── concurrent_hash.go ├── concurrent_hash_test.go ├── concurrent_rw_lock.go ├── concurrent_rw_lock_test.go ├── decimal.go ├── decimal_test.go ├── diggable.go ├── environment.go ├── error.go ├── error_test.go ├── errors │ └── error.go ├── evaluation_test.go ├── file.go ├── file_test.go ├── float.go ├── float_test.go ├── go_map.go ├── go_map_test.go ├── go_object.go ├── hash.go ├── hash_test.go ├── http.go ├── http_client.go ├── http_client_test.go ├── http_request_test.go ├── http_response_test.go ├── http_test.go ├── inspection_methods.go ├── instruction.go ├── instruction_translator.go ├── integer.go ├── integer_test.go ├── issue_vm.go ├── json.go ├── json_test.go ├── lazy_enumerator_test.go ├── main_object_test.go ├── match_data.go ├── match_data_test.go ├── method.go ├── null.go ├── null_test.go ├── numeric.go ├── object.go ├── object_test.go ├── range.go ├── range_enumerator_test.go ├── range_test.go ├── regexp.go ├── regexp_test.go ├── repl.go ├── simple_server.go ├── simple_server_test.go ├── spec.go ├── spec_test.go ├── stack.go ├── statement_test.go ├── string.go ├── string_test.go ├── thread.go ├── uri.go ├── uri_test.go ├── validate.go ├── vm.go └── vm_test.go └── wiki ├── Introduction_to_Goby_slide_preview.png ├── goby_codebase_gocity-min.png ├── goby_structure.png ├── goland_logo-text.png ├── goland_logo.png ├── organization1.png └── organization2.png /.codeclimate.yml: -------------------------------------------------------------------------------- 1 | engines: 2 | govet: 3 | enabled: true 4 | golint: 5 | enabled: true 6 | gofmt: 7 | enabled: true 8 | 9 | exclude_paths: 10 | - "Godeps" 11 | - "test_fixtures" 12 | - "vendor" 13 | 14 | ratings: 15 | paths: 16 | - "**.go" -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.gb linguist-language=Ruby 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Before you submit the issue, please provide us following information: 2 | 3 | - Your operating system 4 | - How did you install Goby 5 | - Goby version 6 | - The value of `$GOBY_ROOT` 7 | - Error messages 8 | 9 | If you have trouble building Goby on your machine, please check `$GOPATH` and `$GOROOT` 10 | 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 3 | *.o 4 | *.a 5 | *.so 6 | 7 | # Folders 8 | _obj 9 | _test 10 | 11 | # Architecture specific extensions/prefixes 12 | *.[568vq] 13 | [568vq].out 14 | 15 | *.cgo1.go 16 | *.cgo2.c 17 | _cgo_defun.c 18 | _cgo_gotypes.go 19 | _cgo_export.* 20 | 21 | _testmain.go 22 | 23 | *.exe 24 | *.test 25 | *.prof 26 | .vscode 27 | 28 | .idea 29 | 30 | goby 31 | 32 | *.gbbc 33 | coverage.txt 34 | profile.out 35 | .DS_Store 36 | 37 | .tmp_benchmarks 38 | .tmp_benchmark_comparison 39 | 40 | /plugins -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | 2 | language: go 3 | 4 | matrix: 5 | include: 6 | - go: 1.14 7 | dist: xenial 8 | - go: 1.15 9 | dist: xenial 10 | 11 | services: 12 | - postgresql 13 | 14 | go_import_path: github.com/goby-lang/goby 15 | 16 | before_install: 17 | - sudo apt-get install apache2-utils 18 | 19 | before_script: 20 | - psql -c 'create database goby_test;' -U postgres 21 | 22 | script: 23 | - ./travis.sh 24 | 25 | env: 26 | - "GOBY_ROOT=$HOME/gopath/src/github.com/goby-lang/goby" 27 | 28 | after_success: 29 | - bash <(curl -s https://codecov.io/bash) 30 | 31 | notifications: 32 | slack: 33 | rooms: 34 | - goby-lang:Ler5Uge2Vlx3O8Yt2OFcKg5W#general 35 | on_success: always 36 | on_failure: always 37 | on_start: never 38 | webhooks: 39 | urls: 40 | - https://webhooks.gitter.im/e/149378fb1b44bbaf21f0 41 | on_success: change 42 | on_failure: always 43 | on_start: never 44 | email: 45 | recipients: 46 | - stan001212@gmail.com 47 | on_failure: change 48 | on_success: never 49 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.14 2 | 3 | ENV GOPATH=/go 4 | ENV PATH=$GOPATH/bin:$PATH 5 | 6 | ENV GO111MODULE=on 7 | 8 | RUN mkdir -p $GOPATH/src/github.com/goby-lang/goby 9 | ENV GOBY_ROOT=$GOPATH/src/github.com/goby-lang/goby 10 | 11 | WORKDIR $GOPATH/src/github.com/goby-lang/goby 12 | 13 | ADD . ./ 14 | 15 | RUN go install . 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Stan Lo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | GOFMT ?= gofmt -s 2 | GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*") 3 | RELEASE_OPTIONS := -ldflags "-s -w -X github.com/goby-lang/goby/vm.DefaultLibPath=${GOBY_LIBPATH}" -tags release 4 | TEST_OPTIONS := -ldflags "-s -w" 5 | 6 | .PHONY: fmt 7 | fmt: 8 | $(GOFMT) -w $(GOFILES) 9 | 10 | .PHONY: build 11 | build: 12 | go build $(RELEASE_OPTIONS) . 13 | 14 | .PHONY: install 15 | install: 16 | go install $(RELEASE_OPTIONS) . 17 | 18 | .PHONY: test 19 | test: 20 | go test $(TEST_OPTIONS) ./... 21 | make clean 22 | 23 | .PHONY: clean 24 | clean: 25 | go clean . 26 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-architect -------------------------------------------------------------------------------- /benchmark.rb: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env ruby 2 | require 'optparse' 3 | require 'tempfile' 4 | 5 | options = { 6 | before: 'master', 7 | after: 'HEAD', 8 | bench_time: '1s' 9 | } 10 | 11 | OptionParser.new do |opts| 12 | opts.banner = 'Runs benchmarks on two branches and compares the results' 13 | opts.on('-b hash', '--before hash') do |v| 14 | options[:before] = v 15 | end 16 | 17 | opts.on('-a hash', '--after hash') do |v| 18 | options[:after] = v 19 | end 20 | 21 | opts.on('-t time', '--bench_time time') do |v| 22 | options[:bench_time] = v 23 | end 24 | end.parse! 25 | 26 | benchmark_options = "-run '^$' -bench '.' -benchmem -benchtime #{options[:bench_time]}" 27 | return_to = `git rev-parse --abbrev-ref HEAD` 28 | before_hash = `git rev-parse #{options[:before]}`.strip 29 | after_hash = `git rev-parse #{options[:after]}`.strip 30 | 31 | bf = Tempfile.new('before') 32 | af = Tempfile.new('after') 33 | begin 34 | `git checkout #{before_hash} 2>&1` 35 | 36 | puts "benchmarking #{before_hash}" 37 | bf.write `go test #{benchmark_options} ./...` 38 | 39 | `git checkout #{after_hash} 2>&1` 40 | puts "benchmarking #{after_hash}" 41 | af.write `go test #{benchmark_options} ./...` 42 | af.close 43 | bf.close 44 | 45 | `go get golang.org/x/tools/cmd/benchcmp` 46 | comparison = `$GOPATH/bin/benchcmp #{bf.path} #{af.path}` 47 | 48 | puts RUBY_PLATFORM 49 | puts comparison 50 | rescue StandardError => e 51 | puts e 52 | ensure 53 | bf.unlink 54 | af.unlink 55 | `git checkout #{return_to} 2>&1` 56 | end 57 | -------------------------------------------------------------------------------- /bzt.yml: -------------------------------------------------------------------------------- 1 | # Please install Taurus first 2 | # Then run `bzt bzt.yml 3 | # See https://gettaurus.org/docs/ConfigSyntax/ for more setting options 4 | execution: 5 | - concurrency: 50 6 | throughput: 10 # requests per second 7 | ramp-up: 10s 8 | hold-for: 1m 9 | scenario: 10 | requests: 11 | - http://localhost:3000/ 12 | 13 | settings: 14 | artifacts-dir: /tmp/%Y-%m-%d_%H-%M-%S -------------------------------------------------------------------------------- /cmd/binder/Readme.md: -------------------------------------------------------------------------------- 1 | # binder 2 | 3 | A helper cli for generating goby class bindings for go structures. 4 | 5 | ## Usage 6 | binder -in file_name.go -type MyGoType 7 | 8 | This will create a file named `bindings.go` which contains wrapper functions and an init function which will load those bindings into the vm at runtime. 9 | 10 | To ensure your package is loaded in the vm, include a null import to your package in the main file of your finial binary. 11 | 12 | ```go 13 | import _ "github.com/path/to/your/package" 14 | ``` 15 | 16 | ## Auto generate using go generate 17 | 18 | Adding a go generate comment in the file your define your go structure will allow you to automatically generate updated bindings easily by running `go generate ./...` in the root of your project. 19 | 20 | example in 21 | `github.com/goby-lang/native/result/result.go` 22 | ```go 23 | package result 24 | //go:generate binder -in result.go -type Result 25 | ``` 26 | 27 | ## Binding rules 28 | 29 | * Methods with a named receiver will be instance methods. 30 | * Methods without a named receiver will be class methods. 31 | * Types must be exported. 32 | * Camel case names will be converted to snake case names. 33 | 34 | examples. 35 | ```go 36 | func (t *MyType) func MyFunc() vm.Object 37 | ``` 38 | 39 | will generate the equivalent instance method in goby. 40 | ```ruby 41 | class MyType 42 | def my_func() 43 | end 44 | end 45 | ``` 46 | 47 | 48 | ```go 49 | func (MyType) func MyFunc() vm.Object 50 | ``` 51 | 52 | will generate the equivalent class method in goby. 53 | ```ruby 54 | class MyType 55 | def self.my_func() 56 | end 57 | end 58 | ``` 59 | 60 | ## Current Limitations 61 | 62 | * Only one type can have generated bindings per package. 63 | * Only functions that return `vm.Object` will have bindings generated. 64 | * Function names cannot contain special characters like `?`. 65 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | ignore: 2 | - "**/inspection_methods.go" 3 | - "./test_fixtures/**" 4 | - "./vendor" 5 | - "./lib" -------------------------------------------------------------------------------- /compiler/ast/ast.go: -------------------------------------------------------------------------------- 1 | package ast 2 | 3 | import ( 4 | "bytes" 5 | 6 | "github.com/goby-lang/goby/compiler/token" 7 | ) 8 | 9 | // BaseNode holds the attribute every expression or statement should have 10 | type BaseNode struct { 11 | Token token.Token 12 | isStmt bool 13 | } 14 | 15 | // Line returns node's token's line number 16 | func (b *BaseNode) Line() int { 17 | return b.Token.Line 18 | } 19 | 20 | // IsExp returns if current node should be considered as an expression 21 | func (b *BaseNode) IsExp() bool { 22 | return !b.isStmt 23 | } 24 | 25 | // IsStmt returns if current node should be considered as a statement 26 | func (b *BaseNode) IsStmt() bool { 27 | return b.isStmt 28 | } 29 | 30 | // MarkAsStmt marks current node to be statement 31 | func (b *BaseNode) MarkAsStmt() { 32 | b.isStmt = true 33 | } 34 | 35 | // MarkAsExp marks current node to be expression 36 | func (b *BaseNode) MarkAsExp() { 37 | b.isStmt = false 38 | } 39 | 40 | type node interface { 41 | TokenLiteral() string 42 | String() string 43 | Line() int 44 | IsExp() bool 45 | IsStmt() bool 46 | MarkAsStmt() 47 | MarkAsExp() 48 | } 49 | 50 | // Statement satisfies "node" and statementNode 51 | type Statement interface { 52 | node 53 | statementNode() 54 | } 55 | 56 | // Expression satisfies "node" and expressionNode 57 | type Expression interface { 58 | node 59 | expressionNode() 60 | } 61 | 62 | // Program is the root node of entire AST 63 | type Program struct { 64 | Statements []Statement 65 | } 66 | 67 | // TokenLiteral returns a token literal of the statement 68 | func (p *Program) TokenLiteral() string { 69 | if len(p.Statements) > 0 { 70 | return p.Statements[0].TokenLiteral() 71 | } 72 | 73 | return "" 74 | } 75 | 76 | func (p *Program) String() string { 77 | var out bytes.Buffer 78 | 79 | for _, s := range p.Statements { 80 | out.WriteString(s.String()) 81 | } 82 | 83 | return out.String() 84 | } 85 | -------------------------------------------------------------------------------- /compiler/ast/common_test_helpers.go: -------------------------------------------------------------------------------- 1 | //+build !release 2 | 3 | package ast 4 | 5 | import ( 6 | "testing" 7 | ) 8 | 9 | /* 10 | Program 11 | */ 12 | 13 | // FirstStmt returns program's first statement as a TestStatement 14 | func (p *Program) FirstStmt() TestableStatement { 15 | return p.Statements[0].(TestableStatement) 16 | } 17 | 18 | // NthStmt returns program's nth statement as a TestStatement 19 | func (p *Program) NthStmt(nth int) TestableStatement { 20 | return p.Statements[nth-1].(TestableStatement) 21 | } 22 | 23 | /* 24 | interal helpers 25 | */ 26 | 27 | func compareInt(t *testing.T, exp Expression, value int) { 28 | il, ok := exp.(*IntegerLiteral) 29 | if !ok { 30 | t.Fatalf("expect exp to be IntegerLiteral. got=%T", exp) 31 | } 32 | if il.Value != value { 33 | t.Fatalf("il.Value is not %d. got=%d", value, il.Value) 34 | } 35 | } 36 | 37 | func compareString(t *testing.T, exp Expression, value string) { 38 | sl, ok := exp.(*StringLiteral) 39 | if !ok { 40 | t.Fatalf("expect exp to be StringLiteral. got=%T", exp) 41 | } 42 | if sl.Value != value { 43 | t.Fatalf("il.Value is not %s. got=%s", value, sl.Value) 44 | } 45 | } 46 | 47 | func compareIdentifier(t *testing.T, exp Expression, value TestableIdentifierValue) { 48 | sl, ok := exp.(*Identifier) 49 | if !ok { 50 | t.Fatalf("expect exp to be StringLiteral. got=%T", exp) 51 | } 52 | if sl.Value != string(value) { 53 | t.Fatalf("il.Value is not %s. got=%s", value, sl.Value) 54 | } 55 | } 56 | 57 | func compareBool(t *testing.T, exp Expression, value bool) { 58 | b, ok := exp.(*BooleanExpression) 59 | if !ok { 60 | t.Fatalf("expect exp to be IntegerLiteral. got=%T", exp) 61 | } 62 | if b.Value != value { 63 | t.Fatalf("il.Value is not %t. got=%t", value, b.Value) 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /compiler/bytecode/generator.go: -------------------------------------------------------------------------------- 1 | package bytecode 2 | 3 | import ( 4 | "github.com/goby-lang/goby/compiler/ast" 5 | ) 6 | 7 | type scope struct { 8 | program *ast.Program 9 | localTable *localTable 10 | anchors map[string]*anchor 11 | } 12 | 13 | func newScope() *scope { 14 | return &scope{localTable: newLocalTable(0), anchors: make(map[string]*anchor)} 15 | } 16 | 17 | // Generator contains program's AST and will store generated instruction sets 18 | type Generator struct { 19 | REPL bool 20 | instructionSets []*InstructionSet 21 | blockCounter int 22 | scope *scope 23 | instructionsWithAnchor []*Instruction 24 | } 25 | 26 | // NewGenerator initializes new Generator with complete AST tree. 27 | func NewGenerator() *Generator { 28 | return &Generator{instructionsWithAnchor: []*Instruction{}} 29 | } 30 | 31 | // ResetInstructionSets clears generator's instruction sets 32 | func (g *Generator) ResetInstructionSets() { 33 | g.instructionSets = []*InstructionSet{} 34 | } 35 | 36 | // InitTopLevelScope sets generator's scope with program node, which means it's the top level scope 37 | func (g *Generator) InitTopLevelScope(program *ast.Program) { 38 | g.scope = &scope{program: program, localTable: newLocalTable(0), anchors: make(map[string]*anchor)} 39 | } 40 | 41 | // GenerateInstructions returns compiled instructions 42 | func (g *Generator) GenerateInstructions(stmts []ast.Statement) []*InstructionSet { 43 | g.compileStatements(stmts, g.scope, g.scope.localTable) 44 | // Use anchor's exact position to replace anchor obj 45 | for _, i := range g.instructionsWithAnchor { 46 | i.Params[0] = i.AnchorLine() 47 | } 48 | //fmt.Println(g.instructionsToString()) 49 | //fmt.Print() 50 | return g.instructionSets 51 | } 52 | 53 | func (g *Generator) compileCodeBlock(is *InstructionSet, stmt *ast.BlockStatement, scope *scope, table *localTable) { 54 | for _, s := range stmt.Statements { 55 | g.compileStatement(is, s, scope, table) 56 | } 57 | } 58 | 59 | func (g *Generator) endInstructions(is *InstructionSet, sourceLine int) { 60 | if g.REPL && is.name == Program { 61 | return 62 | } 63 | is.define(Leave, sourceLine) 64 | } 65 | -------------------------------------------------------------------------------- /compiler/bytecode/local_table.go: -------------------------------------------------------------------------------- 1 | package bytecode 2 | 3 | type localTable struct { 4 | store map[string]int 5 | count int 6 | depth int 7 | upper *localTable 8 | } 9 | 10 | func (lt *localTable) get(v string) (int, bool) { 11 | i, ok := lt.store[v] 12 | 13 | return i, ok 14 | } 15 | 16 | func (lt *localTable) set(val string) int { 17 | c, ok := lt.store[val] 18 | 19 | if !ok { 20 | c = lt.count 21 | lt.store[val] = c 22 | lt.count++ 23 | return c 24 | } 25 | 26 | return c 27 | } 28 | 29 | func (lt *localTable) setLCL(v string, d int) (index, depth int) { 30 | index, depth, ok := lt.getLCL(v, d) 31 | 32 | if !ok { 33 | index = lt.set(v) 34 | depth = 0 35 | return index, depth 36 | } 37 | 38 | return index, depth 39 | } 40 | 41 | func (lt *localTable) getLCL(v string, d int) (index, depth int, ok bool) { 42 | index, ok = lt.get(v) 43 | 44 | if ok { 45 | return index, d - lt.depth, ok 46 | } 47 | 48 | if lt.upper != nil { 49 | index, depth, ok = lt.upper.getLCL(v, d) 50 | return 51 | } 52 | 53 | return -1, 0, false 54 | } 55 | 56 | func newLocalTable(depth int) *localTable { 57 | s := make(map[string]int) 58 | return &localTable{store: s, depth: depth} 59 | } 60 | -------------------------------------------------------------------------------- /compiler/compiler.go: -------------------------------------------------------------------------------- 1 | package compiler 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/goby-lang/goby/compiler/bytecode" 7 | "github.com/goby-lang/goby/compiler/lexer" 8 | "github.com/goby-lang/goby/compiler/parser" 9 | ) 10 | 11 | // CompileToInstructions compiles input source code into instruction set data structures 12 | func CompileToInstructions(input string, pm parser.Mode) ([]*bytecode.InstructionSet, error) { 13 | l := lexer.New(input) 14 | p := parser.New(l) 15 | p.Mode = pm 16 | program, err := p.ParseProgram() 17 | if err != nil { 18 | return nil, fmt.Errorf(err.Message) 19 | } 20 | g := bytecode.NewGenerator() 21 | g.InitTopLevelScope(program) 22 | return g.GenerateInstructions(program.Statements), nil 23 | } 24 | -------------------------------------------------------------------------------- /compiler/parser/arguments/arguments.go: -------------------------------------------------------------------------------- 1 | package arguments 2 | 3 | import "github.com/goby-lang/goby/compiler/token" 4 | 5 | // Enums for different kinds of arguments 6 | const ( 7 | NormalArg = iota 8 | OptionedArg 9 | SplatArg 10 | RequiredKeywordArg 11 | OptionalKeywordArg 12 | ) 13 | 14 | // Types is a table maps argument types enum to the their real name 15 | var Types = map[int]string{ 16 | NormalArg: "Normal argument", 17 | OptionedArg: "Optioned argument", 18 | RequiredKeywordArg: "Keyword argument", 19 | OptionalKeywordArg: "Optioned keyword argument", 20 | SplatArg: "Splat argument", 21 | } 22 | 23 | // Tokens marks token types that can be used as method call arguments 24 | var Tokens = map[token.Type]bool{ 25 | token.Int: true, 26 | token.String: true, 27 | token.True: true, 28 | token.False: true, 29 | token.Null: true, 30 | token.InstanceVariable: true, 31 | token.Ident: true, 32 | token.Constant: true, 33 | } 34 | -------------------------------------------------------------------------------- /compiler/parser/events/events.go: -------------------------------------------------------------------------------- 1 | package events 2 | 3 | import ( 4 | "github.com/goby-lang/goby/compiler/parser/states" 5 | ) 6 | 7 | // These are state machine's events 8 | const ( 9 | BackToNormal = "backToNormal" 10 | ParseFuncCall = "parseFuncCall" 11 | ParseMethodParam = "parseMethodParam" 12 | ParseAssignment = "parseAssignment" 13 | ) 14 | 15 | // EventTable is the mapping of state and its corresponding event 16 | var EventTable = map[string]string{ 17 | states.Normal: BackToNormal, 18 | states.ParsingFuncCall: ParseFuncCall, 19 | states.ParsingMethodParam: ParseMethodParam, 20 | states.ParsingAssignment: ParseAssignment, 21 | } 22 | -------------------------------------------------------------------------------- /compiler/parser/precedence/precedence.go: -------------------------------------------------------------------------------- 1 | package precedence 2 | 3 | import "github.com/goby-lang/goby/compiler/token" 4 | 5 | // Constants for denoting precedence 6 | const ( 7 | _ = iota 8 | Lowest 9 | Normal 10 | Assign 11 | Logic 12 | Range 13 | Equals 14 | Compare 15 | Sum 16 | Product 17 | BangPrefix 18 | Index 19 | Call 20 | MinusPrefix 21 | ) 22 | 23 | // LookupTable maps token to its corresponding precedence 24 | var LookupTable = map[token.Type]int{ 25 | token.Eq: Equals, 26 | token.NotEq: Equals, 27 | token.LT: Compare, 28 | token.LTE: Compare, 29 | token.GT: Compare, 30 | token.GTE: Compare, 31 | token.COMP: Compare, 32 | token.And: Logic, 33 | token.Or: Logic, 34 | token.Range: Range, 35 | token.Plus: Sum, 36 | token.Minus: Sum, 37 | token.Modulo: Sum, 38 | token.Slash: Product, 39 | token.Asterisk: Product, 40 | token.Pow: Product, 41 | token.LBracket: Index, 42 | token.Dot: Call, 43 | token.LParen: Call, 44 | token.ResolutionOperator: Call, 45 | token.Assign: Assign, 46 | token.PlusEq: Assign, 47 | token.MinusEq: Assign, 48 | token.OrEq: Assign, 49 | token.Colon: Assign, 50 | } 51 | -------------------------------------------------------------------------------- /compiler/parser/states/states.go: -------------------------------------------------------------------------------- 1 | package states 2 | 3 | // These are state machine's states 4 | const ( 5 | Normal = "normal" 6 | ParsingFuncCall = "parsingFuncCall" 7 | ParsingMethodParam = "parsingMethodParam" 8 | ParsingAssignment = "parsingAssignment" 9 | ) 10 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/goby-lang/goby 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e 7 | github.com/dave/jennifer v0.19.0 8 | github.com/dlclark/regexp2 v1.2.0 9 | github.com/fatih/camelcase v1.0.0 10 | github.com/fatih/structs v1.1.0 11 | github.com/gorilla/context v1.1.1 // indirect 12 | github.com/gorilla/mux v1.7.3 13 | github.com/jmoiron/sqlx v1.2.0 14 | github.com/lib/pq v1.2.0 15 | github.com/looplab/fsm v0.1.0 16 | github.com/mattn/go-colorable v0.1.4 17 | github.com/mattn/go-isatty v0.0.10 // indirect 18 | github.com/pkg/profile v1.3.0 19 | github.com/st0012/metago v0.0.0-20170803060228-9a814882b21a 20 | golang.org/x/sys v0.0.0-20191029155521-f43be2a4598c // indirect 21 | golang.org/x/tools v0.0.0-20200417140056-c07e33ef3290 // indirect 22 | ) 23 | -------------------------------------------------------------------------------- /lib/array.gb: -------------------------------------------------------------------------------- 1 | class Array 2 | def include?(x) 3 | any? do |i| 4 | i == x 5 | end 6 | end 7 | 8 | def to_enum 9 | ArrayEnumerator.new(self) 10 | end 11 | 12 | # Return a lazy iterator for self. 13 | # 14 | def lazy 15 | LazyEnumerator.new(to_enum) 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /lib/array_enumerator.gb: -------------------------------------------------------------------------------- 1 | # Minimail implementation of an array enumerator. 2 | # 3 | # Assumes that the Enumerator interface has two methods: #has_next? and #next. 4 | # 5 | class ArrayEnumerator 6 | def initialize(array) 7 | @array = array 8 | @current_position = -1 9 | end 10 | 11 | # Returns true if there is another element is available. 12 | # 13 | def has_next? 14 | @current_position + 1 < @array.length 15 | end 16 | 17 | # Returns the next element, and advances the internal position. 18 | # 19 | # Raises an error if there are no elements available. 20 | # 21 | def next 22 | if !has_next? 23 | raise StopIteration, "No more elements!" 24 | end 25 | 26 | @current_position += 1 27 | 28 | @array[@current_position] 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/file.gb: -------------------------------------------------------------------------------- 1 | class File 2 | def self.open(filename, mode = "r", perm = 0755) 3 | file = new(filename, mode, perm) 4 | 5 | if block_given? 6 | yield(file) 7 | end 8 | 9 | file.close 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/integer.gb: -------------------------------------------------------------------------------- 1 | class Integer 2 | def times 3 | range = (0..self-1) 4 | 5 | if block_given? 6 | range.each do |i| 7 | yield(i) 8 | end 9 | end 10 | 11 | range.to_enum 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /lib/net/http/request.gb: -------------------------------------------------------------------------------- 1 | module Net 2 | class HTTP 3 | class Request 4 | attr_accessor :method, :protocol, :body, :content_length, :transfer_encoding, :host, :path, :url, :params 5 | attr_reader :headers 6 | 7 | def initialize(headers = {}) 8 | @headers = headers 9 | end 10 | 11 | def set_header(key, value) 12 | if @headers.nil? 13 | @headers = {} 14 | end 15 | @headers[key] = value 16 | end 17 | 18 | def get_header(key) 19 | @headers[key] 20 | end 21 | 22 | def remove_header(key) 23 | @headers.delete(key) 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /lib/net/http/response.gb: -------------------------------------------------------------------------------- 1 | module Net 2 | class HTTP 3 | class Response 4 | attr_accessor :body, :status, :status_code, :protocol, :transfer_encoding, :http_version, :request_http_version, :request 5 | attr_reader :headers 6 | 7 | def initialize(headers = {}) 8 | @headers = headers 9 | end 10 | 11 | def set_header(key, value) 12 | if @headers.nil? 13 | @headers = {} 14 | end 15 | @headers[key] = value 16 | end 17 | 18 | def get_header(key) 19 | @headers[key] 20 | end 21 | 22 | def remove_header(key) 23 | @headers.delete(key) 24 | end 25 | end 26 | end 27 | end -------------------------------------------------------------------------------- /lib/net/simple_server.gb: -------------------------------------------------------------------------------- 1 | module Net 2 | class SimpleServer 3 | attr_reader :port 4 | attr_accessor :file_root 5 | 6 | def initialize(port) 7 | @port = port 8 | end 9 | 10 | def get(path) 11 | mount(path, "GET") do |req, res| 12 | yield(req, res) 13 | end 14 | end 15 | 16 | def post(path) 17 | mount(path, "POST") do |req, res| 18 | yield(req, res) 19 | end 20 | end 21 | 22 | def put(path) 23 | mount(path, "PUT") do |req, res| 24 | yield(req, res) 25 | end 26 | end 27 | 28 | def delete(path) 29 | mount(path, "DELETE") do |req, res| 30 | yield(req, res) 31 | end 32 | end 33 | 34 | def head(path) 35 | mount(path, "HEAD") do |req, res| 36 | yield(req, res) 37 | end 38 | end 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /lib/plugin.gb: -------------------------------------------------------------------------------- 1 | class Plugin 2 | attr_accessor :context 3 | 4 | def self.generate(name) 5 | p = config(name) do |c| 6 | yield(c) 7 | end 8 | 9 | p.compile 10 | end 11 | 12 | def self.config(name) 13 | plugin = new(name) 14 | plugin.context = PluginContext.new 15 | yield(plugin.context) 16 | plugin 17 | end 18 | 19 | class PluginContext 20 | attr_accessor :functions, :packages 21 | 22 | def initialize 23 | @functions = [] 24 | @packages = [] 25 | end 26 | 27 | def link_function(prefix, name) 28 | @functions.push({ prefix: prefix, name: name }) 29 | end 30 | 31 | def import_pkg(prefix, name) 32 | @packages.push({ prefix: prefix, name: name }) 33 | end 34 | end 35 | end -------------------------------------------------------------------------------- /lib/range.gb: -------------------------------------------------------------------------------- 1 | class Range 2 | def lazy 3 | LazyEnumerator.new(to_enum) 4 | end 5 | 6 | def to_enum 7 | RangeEnumerator.new(self) 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /lib/range_enumerator.gb: -------------------------------------------------------------------------------- 1 | # Minimail implementation of a range enumerator. 2 | # 3 | # Assumes that the Enumerator interface has two methods: #has_next? and #next. 4 | # 5 | # It is also implicitly that a range never has a nil value. 6 | # 7 | class RangeEnumerator 8 | def initialize(range) 9 | @range = range 10 | @current_value = nil 11 | 12 | if @range.first < @range.last 13 | @delta = 1 14 | else 15 | @delta = -1 16 | end 17 | end 18 | 19 | # Returns true if there is another element is available. 20 | # 21 | def has_next? 22 | if @current_value.nil? 23 | return true 24 | end 25 | 26 | if @range.last < @range.first 27 | return @current_value > @range.last 28 | end 29 | 30 | @current_value < @range.last 31 | end 32 | 33 | # Returns the next element, and advances the internal position. 34 | # 35 | # Raises an error if there are no elements available. 36 | # 37 | def next 38 | if !has_next? 39 | raise StopIteration, "No more elements!" 40 | end 41 | 42 | if @current_value.nil? 43 | @current_value = @range.first 44 | else 45 | @current_value += @delta 46 | end 47 | 48 | @current_value 49 | end 50 | 51 | def each 52 | while has_next? do 53 | next_value = self.next 54 | yield next_value 55 | end 56 | end 57 | 58 | def map 59 | a = [] 60 | self.each do |value| 61 | a.push(yield(value)) 62 | end 63 | a 64 | end 65 | end 66 | -------------------------------------------------------------------------------- /lib/result.gb: -------------------------------------------------------------------------------- 1 | class Result 2 | end -------------------------------------------------------------------------------- /lib/ripper.gb: -------------------------------------------------------------------------------- 1 | # A dummy class for ripper.go 2 | class Ripper 3 | end 4 | -------------------------------------------------------------------------------- /native/plugin/plugin_generator.go: -------------------------------------------------------------------------------- 1 | package plugin 2 | 3 | import ( 4 | "bytes" 5 | "text/template" 6 | ) 7 | 8 | type importSection struct { 9 | HasLib bool 10 | Pkgs []*pkg 11 | } 12 | 13 | type pluginSections struct { 14 | ImportSection, VarSection string 15 | } 16 | 17 | type pkg struct { 18 | Prefix string 19 | Name string 20 | } 21 | 22 | type function struct { 23 | Prefix string 24 | Name string 25 | } 26 | 27 | func compileTemplate(obj interface{}, sn, tn string) string { 28 | buffer := &bytes.Buffer{} 29 | 30 | t := template.Must(template.New(sn).Parse(tn)) 31 | err := t.Execute(buffer, obj) 32 | 33 | if err != nil { 34 | panic(err.Error()) 35 | } 36 | 37 | return buffer.String() 38 | } 39 | 40 | func compilePluginTemplate(pkgs []*pkg, funcs []*function) string { 41 | is := compileImportSection(pkgs) 42 | vs := compileVarsSection(funcs) 43 | p := pluginSections{ImportSection: is, VarSection: vs} 44 | 45 | return compileTemplate(p, "pluginSections", pluginTemplate) 46 | } 47 | 48 | func compileImportSection(pkgs []*pkg) string { 49 | return compileTemplate(pkgs, "importSection", importSectionTemplate) 50 | } 51 | 52 | func compileVarsSection(funcs []*function) string { 53 | return compileTemplate(funcs, "functionSection", functionSectionTemplate) 54 | } 55 | 56 | const importSectionTemplate = ` 57 | import( 58 | {{- range $pkg := .}} 59 | {{printf "%s \"%s\"\n" $pkg.Prefix $pkg.Name -}} 60 | {{- end}} 61 | ) 62 | ` 63 | 64 | const functionSectionTemplate = ` 65 | 66 | {{- range $f := . }} 67 | {{printf "var %s = %s.%s\n" $f.Name $f.Prefix $f.Name -}} 68 | {{- end}} 69 | ` 70 | 71 | const pluginTemplate = ` 72 | package main 73 | 74 | {{ .ImportSection -}} 75 | 76 | {{- .VarSection -}} 77 | 78 | func main() {} 79 | ` 80 | -------------------------------------------------------------------------------- /native/plugin/plugin_generator_test.go: -------------------------------------------------------------------------------- 1 | package plugin 2 | 3 | import ( 4 | "strings" 5 | "testing" 6 | ) 7 | 8 | func TestCompilePluginTemplate(t *testing.T) { 9 | pkgs := []*pkg{ 10 | { 11 | Prefix: "", 12 | Name: "database/sql", 13 | }, 14 | { 15 | Prefix: "_", 16 | Name: "github.com/lib/pq", 17 | }, 18 | } 19 | 20 | funcs := []*function{ 21 | { 22 | Prefix: "sql", 23 | Name: "Open", 24 | }, 25 | } 26 | 27 | result := strings.TrimSpace(compilePluginTemplate(pkgs, funcs)) 28 | expected := strings.TrimSpace(` 29 | package main 30 | 31 | 32 | import( 33 | "database/sql" 34 | 35 | _ "github.com/lib/pq" 36 | 37 | ) 38 | 39 | var Open = sql.Open 40 | 41 | func main() {} 42 | `) 43 | 44 | if result != expected { 45 | t.Errorf("Expect result template:\n `%q`.\n got:\n `%q`", expected, result) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /native/plugin/plugin_integration_test.go: -------------------------------------------------------------------------------- 1 | package plugin 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | 7 | "github.com/goby-lang/goby/vm" 8 | ) 9 | 10 | func TestCallingPluginFunctionNoRaceDetection(t *testing.T) { 11 | skipPluginTestIfEnvNotSet(t) 12 | 13 | input := ` 14 | require "plugin" 15 | 16 | p = Plugin.use "../test_fixtures/import_test/plugin/plugin.go" 17 | p.go_func("Foo", "!") 18 | p.go_func("Baz") 19 | ` 20 | 21 | // We don't test the result here for two reasons: 22 | // - If it doesn't work it'll returns error or panic 23 | // - It's hard to test a plugin obj 24 | vm.ExecAndReturn(t, input) 25 | } 26 | 27 | func TestCallingPluginFunctionWithReturnValueNoRaceDetection(t *testing.T) { 28 | skipPluginTestIfEnvNotSet(t) 29 | 30 | input := ` 31 | require "plugin" 32 | 33 | p = Plugin.use "../test_fixtures/import_test/plugin/plugin.go" 34 | p.go_func("Bar") 35 | ` 36 | 37 | evaluated := vm.ExecAndReturn(t, input) 38 | vm.VerifyExpected(t, 0, evaluated, "Bar") 39 | } 40 | 41 | func TestCallingLibFuncFromPluginNoRaceDetection(t *testing.T) { 42 | skipPluginTestIfEnvNotSet(t) 43 | 44 | input := ` 45 | require "plugin" 46 | 47 | p = Plugin.use "../test_fixtures/import_test/plugin/plugin.go" 48 | p.go_func("ReturnLibName") 49 | ` 50 | 51 | evaluated := vm.ExecAndReturn(t, input) 52 | vm.VerifyExpected(t, 0, evaluated, "lib") 53 | } 54 | 55 | func TestPluginGenerationNoRaceDetection(t *testing.T) { 56 | skipPluginTestIfEnvNotSet(t) 57 | 58 | input := ` 59 | require "plugin" 60 | 61 | p = Plugin.generate("db") do |p| 62 | p.import_pkg("", "database/sql") 63 | p.import_pkg("_", "github.com/lib/pq") 64 | p.link_function("sql", "Open") 65 | end 66 | 67 | conn, err = p.go_func("Open", "postgres", "") 68 | err = conn.go_func("Ping") 69 | err.nil? 70 | ` 71 | 72 | evaluated := vm.ExecAndReturn(t, input) 73 | vm.VerifyExpected(t, 0, evaluated, true) 74 | } 75 | 76 | func skipPluginTestIfEnvNotSet(t *testing.T) { 77 | t.Helper() 78 | if os.Getenv("NO_RACE_DETECTION") == "" { 79 | t.Skip("skipping plugin related tests") 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /native/plugin/plugin_test.go: -------------------------------------------------------------------------------- 1 | package plugin 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/goby-lang/goby/vm" 7 | ) 8 | 9 | func TestPluginInitialization(t *testing.T) { 10 | tests := []struct { 11 | input string 12 | expected interface{} 13 | }{ 14 | {` 15 | require "plugin" 16 | 17 | p = Plugin.config("db") do |c| 18 | c.import_pkg("", "database/sql") 19 | c.link_function("sql", "Open") 20 | end 21 | 22 | c = p.context 23 | c.packages.first[:name] 24 | `, "database/sql"}, 25 | {` 26 | require "plugin" 27 | 28 | p = Plugin.config("db") do |c| 29 | c.import_pkg("", "database/sql") 30 | c.link_function("sql", "Open") 31 | end 32 | 33 | c = p.context 34 | c.functions.first[:prefix] 35 | `, "sql"}, 36 | {` 37 | require "plugin" 38 | 39 | p = Plugin.config("db") do |c| 40 | c.import_pkg("", "database/sql") 41 | c.link_function("sql", "Open") 42 | end 43 | 44 | c = p.context 45 | c.functions.first[:name] 46 | `, "Open"}, 47 | } 48 | 49 | for i, tt := range tests { 50 | evaluated := vm.ExecAndReturn(t, tt.input) 51 | vm.VerifyExpected(t, i, evaluated, tt.expected) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /samples/channel.gb: -------------------------------------------------------------------------------- 1 | def f(from) 2 | i = 0 3 | while i < 3 do 4 | puts(from + ": " + i.to_s) 5 | i += 1 6 | end 7 | end 8 | 9 | f("direct") 10 | 11 | c = Channel.new 12 | 13 | 14 | thread do 15 | puts(c.receive) 16 | f("thread") 17 | end 18 | 19 | thread do 20 | puts("going") 21 | c.deliver(10) 22 | end 23 | 24 | sleep(2) # This is to prevent main program finished before goroutine. -------------------------------------------------------------------------------- /samples/constant_resolution.gb: -------------------------------------------------------------------------------- 1 | module Out 2 | ModVal = "out" 3 | 4 | module Mid 5 | ModVal = "mid" 6 | 7 | module In 8 | puts ModVal 9 | end 10 | end 11 | end -------------------------------------------------------------------------------- /samples/error-report.gb: -------------------------------------------------------------------------------- 1 | # run this file with the -e flag to test goby's issue reporting feature 2 | 3 | oops 4 | 5 | def hello 6 | puts 'hello world' 7 | end -------------------------------------------------------------------------------- /samples/file_lib/file.gb: -------------------------------------------------------------------------------- 1 | puts(File.extname("test.gb")) 2 | puts(File.split("/home/goby/test.sh")) 3 | puts(File.join("home", "goby", "test.sh")) 4 | puts(File.size("file.gb")) 5 | -------------------------------------------------------------------------------- /samples/http-client.gb: -------------------------------------------------------------------------------- 1 | require "net/http" 2 | 3 | c = Net::HTTP::Client.new 4 | 5 | res = c.send do |req| 6 | req.url = "https://google.com" 7 | req.method = "GET" 8 | end 9 | 10 | puts res.body -------------------------------------------------------------------------------- /samples/http.gb: -------------------------------------------------------------------------------- 1 | require "net/http" 2 | 3 | puts(Net::HTTP.get("http://google.com")) 4 | 5 | -------------------------------------------------------------------------------- /samples/import.gb: -------------------------------------------------------------------------------- 1 | # This only works on Linux, where we can compile Go program into plugin 2 | p = import "github.com/goby-lang/goby/test_fixtures/import_test/plugin.go" 3 | result = p.send("NewBar", "xyz") # multiple result, so result is an array 4 | bar = result[0] 5 | puts(bar.send("Name")) -------------------------------------------------------------------------------- /samples/loop.gb: -------------------------------------------------------------------------------- 1 | i = 0 2 | while i < 10 do 3 | i = i + 1 4 | puts(i) 5 | end 6 | 7 | puts(i) 8 | -------------------------------------------------------------------------------- /samples/module.gb: -------------------------------------------------------------------------------- 1 | module Foo 2 | def ten 3 | 10 4 | end 5 | end 6 | 7 | class Baz 8 | def ten 9 | 1 10 | end 11 | 12 | def five 13 | 5 14 | end 15 | end 16 | 17 | class Bar < Baz 18 | include Foo 19 | end 20 | 21 | b = Bar.new 22 | 23 | puts(b.ten * b.five) 24 | -------------------------------------------------------------------------------- /samples/one_thousand_threads.gb: -------------------------------------------------------------------------------- 1 | c = Channel.new 2 | 3 | 1001.times do |i| # i start from 0 to 1000 4 | thread do 5 | c.deliver(i) 6 | end 7 | end 8 | 9 | r = 0 10 | 1001.times do 11 | r = r + c.receive 12 | end 13 | 14 | c.close 15 | 16 | puts(r) -------------------------------------------------------------------------------- /samples/print_name.gb: -------------------------------------------------------------------------------- 1 | puts("Hello " + ARGV[0]) -------------------------------------------------------------------------------- /samples/require_relative/bar.gb: -------------------------------------------------------------------------------- 1 | class Bar 2 | def self.foo 3 | yield(10) 4 | end 5 | end -------------------------------------------------------------------------------- /samples/require_relative/foo.gb: -------------------------------------------------------------------------------- 1 | require_relative("bar") 2 | 3 | class Foo 4 | def self.bar(x) 5 | Bar.foo do |ten| 6 | x * ten 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /samples/require_relative/main.gb: -------------------------------------------------------------------------------- 1 | require_relative("./foo") 2 | 3 | puts(Foo.bar(5)) #=> 50 -------------------------------------------------------------------------------- /samples/sample-1.gb: -------------------------------------------------------------------------------- 1 | class Foo 2 | def set(x) 3 | @x = x 4 | end 5 | def get 6 | @x 7 | end 8 | end 9 | 10 | class Bar < Foo; end 11 | class Baz < Foo; end 12 | 13 | bar = Bar.new 14 | baz = Baz.new 15 | foo = Foo.new 16 | bar.set(10) 17 | baz.set(1) 18 | foo.set(5) 19 | 20 | puts(bar.get + baz.get + foo.get) #=> 16 21 | -------------------------------------------------------------------------------- /samples/sample-2.gb: -------------------------------------------------------------------------------- 1 | class User 2 | def initialize(name, age) 3 | @name = name 4 | @age = age 5 | end 6 | 7 | def name 8 | @name 9 | end 10 | 11 | def age 12 | @age 13 | end 14 | 15 | def say_hi(user) 16 | puts(@name + " says hi to " + user.name) 17 | end 18 | 19 | def self.sum_age(user1, user2) 20 | user1.age + user2.age 21 | end 22 | end 23 | 24 | stan = User.new("Stan", 22) 25 | john = User.new("John", 40) 26 | puts(User.sum_age(stan, john)) #=> 62 27 | stan.say_hi(john) #=> Stan says hi to John -------------------------------------------------------------------------------- /samples/sample-3.gb: -------------------------------------------------------------------------------- 1 | class JobPosition 2 | def initialize(name) 3 | @name = name 4 | end 5 | 6 | def name 7 | @name 8 | end 9 | 10 | def salary=(salary) 11 | @salary = salary 12 | end 13 | 14 | def salary 15 | @salary 16 | end 17 | 18 | def self.engineer 19 | new("Engineer") 20 | end 21 | end 22 | 23 | job = JobPosition.engineer 24 | job.salary = 1000 25 | puts(job.name) #=> "Engineer" 26 | puts(job.salary) #=> 1000 -------------------------------------------------------------------------------- /samples/sample-4.gb: -------------------------------------------------------------------------------- 1 | puts("123".class.name) #=> String 2 | puts(123.class.name) #=> Integer 3 | puts(true.class.name) #=> Boolean -------------------------------------------------------------------------------- /samples/sample-5.gb: -------------------------------------------------------------------------------- 1 | class Foo 2 | def bar 3 | 10 4 | end 5 | end 6 | 7 | h = {} 8 | a = [1, 2, 3] 9 | f = Foo.new 10 | h["foo"] = f 11 | h["array"] = a 12 | 13 | puts(h["foo"].bar + h["array"][2]) #=> 13 -------------------------------------------------------------------------------- /samples/sample-6.gb: -------------------------------------------------------------------------------- 1 | class Car 2 | def initialize 3 | yield(self) 4 | end 5 | 6 | def color=(c) 7 | @color = c 8 | end 9 | 10 | def color 11 | @color 12 | end 13 | 14 | def doors=(ds) 15 | @doors = ds 16 | end 17 | 18 | def doors 19 | @doors 20 | end 21 | end 22 | 23 | car = Car.new do |c| 24 | c.color = "Red" 25 | c.doors = 4 26 | end 27 | 28 | puts("My car's color is " + car.color + " and it's got " + car.doors.to_s + " doors.") -------------------------------------------------------------------------------- /samples/sample-7.gb: -------------------------------------------------------------------------------- 1 | class Foo 2 | def bar 3 | yield 4 | end 5 | end 6 | 7 | a = 100 8 | i = 10 9 | b = 1000 10 | 11 | f = Foo.new 12 | 13 | f.bar do 14 | i = 3 * a 15 | f.bar do 16 | i = 3 + i 17 | end 18 | end 19 | i 20 | -------------------------------------------------------------------------------- /samples/server/blocking_server.gb: -------------------------------------------------------------------------------- 1 | # Run: ab -n 10000 -c 100 http://localhost:3000/ 2 | 3 | require "net/simple_server" 4 | 5 | server = Net::SimpleServer.new("3000") 6 | 7 | i = 0 8 | 9 | server.get("/") do |req, res| 10 | puts(i) 11 | i = i+1 12 | 13 | if i % 20 == 0 14 | puts("===========Start Sleep=============") 15 | sleep(1) 16 | puts("-----------End Sleep-------------") 17 | end 18 | 19 | res.body = req.method + " Hello World" 20 | res.status = 200 21 | end 22 | 23 | server.start -------------------------------------------------------------------------------- /samples/server/server.gb: -------------------------------------------------------------------------------- 1 | require "net/simple_server" 2 | 3 | server = Net::SimpleServer.new("3000") 4 | 5 | i = 0 6 | 7 | server.get("/") do |req, res| 8 | puts(i) 9 | i = i+1 10 | res.body = req.method + " Hello World" 11 | res.status = 200 12 | end 13 | 14 | server.get("/not_found") do |req, res| 15 | res.body = "Not Found" 16 | res.status = 404 17 | end 18 | 19 | server.start -------------------------------------------------------------------------------- /samples/server/static_file_server.gb: -------------------------------------------------------------------------------- 1 | require "net/simple_server" 2 | 3 | server = Net::SimpleServer.new("3000") 4 | server.file_root = "./samples" 5 | 6 | server.start -------------------------------------------------------------------------------- /samples/stack.gb: -------------------------------------------------------------------------------- 1 | class Stack 2 | def initialize 3 | @data = [] 4 | end 5 | 6 | def push(x) 7 | @data.push(x) 8 | end 9 | 10 | def pop 11 | @data.pop 12 | end 13 | 14 | def top 15 | @data[@data.length - 1] 16 | end 17 | end 18 | 19 | s = Stack.new 20 | s.push(1) 21 | s.push(2) 22 | s.push(3) 23 | s.push(4) 24 | s.push(10) 25 | puts(s.pop) #=> 10 26 | puts(s.top) #=> 4 -------------------------------------------------------------------------------- /samples/stdin.gb: -------------------------------------------------------------------------------- 1 | puts "Type your name" 2 | 3 | name = STDIN.read 4 | puts("Your name is " + name) -------------------------------------------------------------------------------- /samples/thread.gb: -------------------------------------------------------------------------------- 1 | def f(from) 2 | i = 0 3 | while i < 3 do 4 | puts(from + ": " + i.to_s) 5 | i += 1 6 | end 7 | end 8 | 9 | f("direct") 10 | 11 | thread do 12 | f("thread") 13 | end 14 | 15 | thread do 16 | puts("going") 17 | end 18 | 19 | sleep(2) # This is to prevent main program finished before goroutine. -------------------------------------------------------------------------------- /samples/to_json.gb: -------------------------------------------------------------------------------- 1 | class JobTitle 2 | def initialize(name) 3 | @name = name 4 | end 5 | 6 | def to_json 7 | { title: @name }.to_json 8 | end 9 | end 10 | 11 | class Person 12 | def initialize(name, age) 13 | @name = name 14 | @age = age 15 | @job = JobTitle.new("software engineer") 16 | end 17 | 18 | def to_json 19 | { name: @name, age: @age, job: @job }.to_json 20 | end 21 | end 22 | 23 | stan = Person.new("Stan", 23) 24 | 25 | h = { a: 1, b: [1, "2", [4, 5, nil], { person: stan }]}.to_json 26 | puts(h) #=> {"b":[1, "2", [4, 5, null], {"person":{"name":"Stan","job":{"title":"software engineer"},"age":23}}],"a":1} 27 | 28 | -------------------------------------------------------------------------------- /samples/unused-variable.gb: -------------------------------------------------------------------------------- 1 | 2 | _ = "foo" 3 | 4 | a, _, c = [1, 2, 3] 5 | puts c # prints 3 6 | puts _ # undefined method error -------------------------------------------------------------------------------- /snap/snapcraft.yaml: -------------------------------------------------------------------------------- 1 | name: goby-lang 2 | version: git 3 | summary: A new language helps you develop microservices 4 | description: | 5 | Goby is an object-oriented interpreter language deeply inspired by Ruby as 6 | well as its core implementation by 100% pure Go. Moreover, it has standard 7 | libraries to provide several features such as the Plugin system. 8 | 9 | grade: stable 10 | confinement: classic 11 | 12 | apps: 13 | goby: 14 | environment: 15 | GOBY_ROOT: $SNAP 16 | command: bin/goby 17 | 18 | parts: 19 | goby: 20 | source: . 21 | plugin: go 22 | go-importpath: github.com/goby-lang/goby 23 | install: 24 | cp -R lib/ $SNAPCRAFT_PART_INSTALL 25 | after: [go] 26 | go: 27 | source-tag: go1.9 28 | -------------------------------------------------------------------------------- /specs/spec_spec.gb: -------------------------------------------------------------------------------- 1 | require "spec" 2 | 3 | # Note that #to is tested functionally, as a base for (almost) all the UTs. 4 | # 5 | Spec.describe Spec do 6 | describe "comparison" do 7 | describe "#to eq" do 8 | it "compares if two values are equal" do 9 | expect(1).to eq(1) 10 | end 11 | end 12 | 13 | describe "#not_to eq" do 14 | it "compares if two values are not equal" do 15 | expect(1).not_to eq(2) 16 | end 17 | end 18 | end 19 | 20 | describe "indentation" do 21 | it "indents four spaces" do 22 | end 23 | describe "nest another level" do 24 | it "indents six spaces" do 25 | end 26 | end 27 | end 28 | 29 | describe "callbacks" do 30 | describe "before" do 31 | i = 0 32 | 33 | before do 34 | i += 1 35 | end 36 | 37 | it "runs before block before the test case" do 38 | expect(i).to eq(1) 39 | end 40 | end 41 | describe "after" do 42 | i = 0 43 | 44 | after do 45 | i = 2 46 | end 47 | 48 | it "changes i" do 49 | i += 5 50 | end 51 | 52 | it "i should be changed by the after block" do 53 | expect(i).to eq(2) 54 | end 55 | end 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /specs/times_spec.gb: -------------------------------------------------------------------------------- 1 | require "spec" 2 | 3 | Spec.describe Integer do 4 | describe "#times" do 5 | it "iterates block when block is provided" do 6 | a = [] 7 | 3.times do |i| 8 | a.push(i) 9 | end 10 | 11 | expect(a).to eq([0, 1, 2]) 12 | end 13 | it "yields enumerator when no block is given" do 14 | a = 3.times.map do |i| 15 | i * 2 16 | end 17 | 18 | expect(a).to eq([0, 2, 4]) 19 | end 20 | end 21 | end -------------------------------------------------------------------------------- /test_fixtures/file_test/size.gb: -------------------------------------------------------------------------------- 1 | this file's size is 2 | 22 -------------------------------------------------------------------------------- /test_fixtures/file_with_error.gb: -------------------------------------------------------------------------------- 1 | foo -------------------------------------------------------------------------------- /test_fixtures/import_test/plugin/lib/lib.go: -------------------------------------------------------------------------------- 1 | package lib 2 | 3 | // ReturnLibName ... 4 | func ReturnLibName() string { 5 | return "lib" 6 | } 7 | -------------------------------------------------------------------------------- /test_fixtures/import_test/plugin/plugin.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/goby-lang/goby/test_fixtures/import_test/plugin/lib" 7 | ) 8 | 9 | // ReturnLibName is an alias type of the target "lib' 10 | var ReturnLibName = lib.ReturnLibName 11 | 12 | // Bar ... 13 | func Bar() string { 14 | return "Bar" 15 | } 16 | 17 | // Foo ... 18 | func Foo(s string) { 19 | fmt.Println("Foo" + s) 20 | } 21 | 22 | // Baz ... 23 | func Baz() { 24 | fmt.Println("Baz") 25 | } 26 | 27 | func main() { 28 | fmt.Println("Main") 29 | } 30 | -------------------------------------------------------------------------------- /test_fixtures/import_test/struct/struct.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | // Bar ... 6 | type Bar struct { 7 | name string 8 | } 9 | 10 | // Name ... 11 | func (b *Bar) Name(s string) (string, error) { 12 | return b.name + s, nil 13 | } 14 | 15 | // Add ... 16 | func (b *Bar) Add(x int, y int64) int64 { 17 | return int64(x) + y 18 | } 19 | 20 | // NewBar ... 21 | func NewBar(name string) (*Bar, error) { 22 | return &Bar{name: name}, nil 23 | } 24 | 25 | // GetBarName ... 26 | func GetBarName(b *Bar) string { 27 | return b.name 28 | } 29 | 30 | func main() { 31 | fmt.Println("Main") 32 | } 33 | -------------------------------------------------------------------------------- /test_fixtures/require_test/bar.gb: -------------------------------------------------------------------------------- 1 | class Bar 2 | def self.foo 3 | yield(10) 4 | end 5 | 6 | def self.baz 7 | 10 8 | end 9 | end -------------------------------------------------------------------------------- /test_fixtures/require_test/foo.gb: -------------------------------------------------------------------------------- 1 | require_relative("bar") 2 | 3 | class Foo 4 | def self.bar(x) 5 | Bar.foo do |ten| 6 | x * ten 7 | end 8 | end 9 | 10 | def self.baz 11 | yield(100) 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /test_fixtures/server.gb: -------------------------------------------------------------------------------- 1 | # Run: ab -n 10000 -c 100 http://localhost:3000/ 2 | 3 | require "net/simple_server" 4 | 5 | server = Net::SimpleServer.new("3000") 6 | 7 | i = 0 8 | 9 | server.get("/") do |req, res| 10 | puts(i) 11 | i = i+1 12 | 13 | if i % 20 == 0 14 | puts("===========Start Sleep=============") 15 | sleep(1) 16 | puts("-----------End Sleep-------------") 17 | end 18 | 19 | 20 | res.body = req.method + " Hello World" 21 | res.status = 200 22 | end 23 | 24 | server.start -------------------------------------------------------------------------------- /test_fixtures/test_command_test/test_spec.gb: -------------------------------------------------------------------------------- 1 | require "spec" 2 | 3 | Spec.describe Spec do 4 | describe "comparison" do 5 | describe "#to eq" do 6 | it "compares if two values are equal" do 7 | expect(1).to eq(1) 8 | end 9 | end 10 | 11 | describe "#not_to eq" do 12 | it "compares if two values are not equal" do 13 | expect(1).not_to eq(2) 14 | end 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /test_fixtures/test_command_test/test_spec2.gb: -------------------------------------------------------------------------------- 1 | require "spec" 2 | 3 | Spec.describe "Spec test 2" do 4 | describe "comparison" do 5 | describe "#to eq" do 6 | it "compares if two values are equal" do 7 | expect(1).to eq(1) 8 | end 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /travis.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | SLEEP=0.5 4 | 5 | set -e 6 | echo "" > coverage.txt 7 | 8 | for d in $(go list ./...); do 9 | if [ $d == "github.com/goby-lang/goby/vm" ]; then 10 | # Test vm's code without running race detection because that breaks plugin tests. 11 | # This can generate full coverage report of vm package. 12 | # Test that need to run without race detection include NoRaceDetection in the name, 13 | # otherwise, they will run twice (in the run below). 14 | NO_RACE_DETECTION=true go test -coverprofile=profile.out -covermode=atomic $d -run NoRaceDetection 15 | if [ -f profile.out ]; then 16 | cat profile.out >> coverage.txt 17 | rm profile.out 18 | fi 19 | 20 | # TODO: Add -race flag back when ready 21 | # Then we test other tests with race detection 22 | go test -coverprofile=profile.out -covermode=atomic $d 23 | if [ -f profile.out ]; then 24 | cat profile.out >> coverage.txt 25 | rm profile.out 26 | fi 27 | continue 28 | fi 29 | # TODO: Add -race flag back when ready 30 | go test -coverprofile=profile.out -covermode=atomic $d 31 | if [ -f profile.out ]; then 32 | cat profile.out >> coverage.txt 33 | rm profile.out 34 | fi 35 | done 36 | 37 | # Test if libs that require built in Goby script would work. 38 | # TODO: Write a test for this specific case 39 | make install 40 | goby test specs 41 | 42 | ./benchmark.rb -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.5 4 | - 1.7 5 | script: 6 | - GOOS=windows go install github.com/chzyer/readline/example/... 7 | - GOOS=linux go install github.com/chzyer/readline/example/... 8 | - GOOS=darwin go install github.com/chzyer/readline/example/... 9 | - go test -race -v 10 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Chzyer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/complete_segment.go: -------------------------------------------------------------------------------- 1 | package readline 2 | 3 | type SegmentCompleter interface { 4 | // a 5 | // |- a1 6 | // |--- a11 7 | // |- a2 8 | // b 9 | // input: 10 | // DoTree([], 0) [a, b] 11 | // DoTree([a], 1) [a] 12 | // DoTree([a, ], 0) [a1, a2] 13 | // DoTree([a, a], 1) [a1, a2] 14 | // DoTree([a, a1], 2) [a1] 15 | // DoTree([a, a1, ], 0) [a11] 16 | // DoTree([a, a1, a], 1) [a11] 17 | DoSegment([][]rune, int) [][]rune 18 | } 19 | 20 | type dumpSegmentCompleter struct { 21 | f func([][]rune, int) [][]rune 22 | } 23 | 24 | func (d *dumpSegmentCompleter) DoSegment(segment [][]rune, n int) [][]rune { 25 | return d.f(segment, n) 26 | } 27 | 28 | func SegmentFunc(f func([][]rune, int) [][]rune) AutoCompleter { 29 | return &SegmentComplete{&dumpSegmentCompleter{f}} 30 | } 31 | 32 | func SegmentAutoComplete(completer SegmentCompleter) *SegmentComplete { 33 | return &SegmentComplete{ 34 | SegmentCompleter: completer, 35 | } 36 | } 37 | 38 | type SegmentComplete struct { 39 | SegmentCompleter 40 | } 41 | 42 | func RetSegment(segments [][]rune, cands [][]rune, idx int) ([][]rune, int) { 43 | ret := make([][]rune, 0, len(cands)) 44 | lastSegment := segments[len(segments)-1] 45 | for _, cand := range cands { 46 | if !runes.HasPrefix(cand, lastSegment) { 47 | continue 48 | } 49 | ret = append(ret, cand[len(lastSegment):]) 50 | } 51 | return ret, idx 52 | } 53 | 54 | func SplitSegment(line []rune, pos int) ([][]rune, int) { 55 | segs := [][]rune{} 56 | lastIdx := -1 57 | line = line[:pos] 58 | pos = 0 59 | for idx, l := range line { 60 | if l == ' ' { 61 | pos = 0 62 | segs = append(segs, line[lastIdx+1:idx]) 63 | lastIdx = idx 64 | } else { 65 | pos++ 66 | } 67 | } 68 | segs = append(segs, line[lastIdx+1:]) 69 | return segs, pos 70 | } 71 | 72 | func (c *SegmentComplete) Do(line []rune, pos int) (newLine [][]rune, offset int) { 73 | 74 | segment, idx := SplitSegment(line, pos) 75 | 76 | cands := c.DoSegment(segment, idx) 77 | newLine, offset = RetSegment(segment, cands, idx) 78 | for idx := range newLine { 79 | newLine[idx] = append(newLine[idx], ' ') 80 | } 81 | return newLine, offset 82 | } 83 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/password.go: -------------------------------------------------------------------------------- 1 | package readline 2 | 3 | type opPassword struct { 4 | o *Operation 5 | backupCfg *Config 6 | } 7 | 8 | func newOpPassword(o *Operation) *opPassword { 9 | return &opPassword{o: o} 10 | } 11 | 12 | func (o *opPassword) ExitPasswordMode() { 13 | o.o.SetConfig(o.backupCfg) 14 | o.backupCfg = nil 15 | } 16 | 17 | func (o *opPassword) EnterPasswordMode(cfg *Config) (err error) { 18 | o.backupCfg, err = o.o.SetConfig(cfg) 19 | return 20 | } 21 | 22 | func (o *opPassword) PasswordConfig() *Config { 23 | return &Config{ 24 | EnableMask: true, 25 | InterruptPrompt: "\n", 26 | EOFPrompt: "\n", 27 | HistoryLimit: -1, 28 | 29 | Stdout: o.o.cfg.Stdout, 30 | Stderr: o.o.cfg.Stderr, 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/std_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package readline 4 | 5 | func init() { 6 | Stdin = NewRawReader() 7 | Stdout = NewANSIWriter(Stdout) 8 | Stderr = NewANSIWriter(Stderr) 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/term_bsd.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 darwin dragonfly freebsd netbsd openbsd 6 | 7 | package readline 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func getTermios(fd int) (*Termios, error) { 15 | termios := new(Termios) 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), syscall.TIOCGETA, uintptr(unsafe.Pointer(termios)), 0, 0, 0) 17 | if err != 0 { 18 | return nil, err 19 | } 20 | return termios, nil 21 | } 22 | 23 | func setTermios(fd int, termios *Termios) error { 24 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), syscall.TIOCSETA, uintptr(unsafe.Pointer(termios)), 0, 0, 0) 25 | if err != 0 { 26 | return err 27 | } 28 | return nil 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/term_linux.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 readline 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | // These constants are declared here, rather than importing 13 | // them from the syscall package as some syscall packages, even 14 | // on linux, for example gccgo, do not declare them. 15 | const ioctlReadTermios = 0x5401 // syscall.TCGETS 16 | const ioctlWriteTermios = 0x5402 // syscall.TCSETS 17 | 18 | func getTermios(fd int) (*Termios, error) { 19 | termios := new(Termios) 20 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(termios)), 0, 0, 0) 21 | if err != 0 { 22 | return nil, err 23 | } 24 | return termios, nil 25 | } 26 | 27 | func setTermios(fd int, termios *Termios) error { 28 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlWriteTermios, uintptr(unsafe.Pointer(termios)), 0, 0, 0) 29 | if err != 0 { 30 | return err 31 | } 32 | return nil 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/term_solaris.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 solaris 6 | 7 | package readline 8 | 9 | import "golang.org/x/sys/unix" 10 | 11 | // GetSize returns the dimensions of the given terminal. 12 | func GetSize(fd int) (int, int, error) { 13 | ws, err := unix.IoctlGetWinsize(fd, unix.TIOCGWINSZ) 14 | if err != nil { 15 | return 0, 0, err 16 | } 17 | return int(ws.Col), int(ws.Row), nil 18 | } 19 | 20 | type Termios unix.Termios 21 | 22 | func getTermios(fd int) (*Termios, error) { 23 | termios, err := unix.IoctlGetTermios(fd, unix.TCGETS) 24 | if err != nil { 25 | return nil, err 26 | } 27 | return (*Termios)(termios), nil 28 | } 29 | 30 | func setTermios(fd int, termios *Termios) error { 31 | return unix.IoctlSetTermios(fd, unix.TCSETSF, (*unix.Termios)(termios)) 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/term_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux,!appengine netbsd openbsd 6 | 7 | package readline 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | type Termios syscall.Termios 15 | 16 | // GetSize returns the dimensions of the given terminal. 17 | func GetSize(fd int) (int, int, error) { 18 | var dimensions [4]uint16 19 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), uintptr(syscall.TIOCGWINSZ), uintptr(unsafe.Pointer(&dimensions)), 0, 0, 0) 20 | if err != 0 { 21 | return 0, 0, err 22 | } 23 | return int(dimensions[1]), int(dimensions[0]), nil 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/utils_unix.go: -------------------------------------------------------------------------------- 1 | // +build darwin dragonfly freebsd linux,!appengine netbsd openbsd solaris 2 | 3 | package readline 4 | 5 | import ( 6 | "io" 7 | "os" 8 | "os/signal" 9 | "sync" 10 | "syscall" 11 | ) 12 | 13 | type winsize struct { 14 | Row uint16 15 | Col uint16 16 | Xpixel uint16 17 | Ypixel uint16 18 | } 19 | 20 | // SuspendMe use to send suspend signal to myself, when we in the raw mode. 21 | // For OSX it need to send to parent's pid 22 | // For Linux it need to send to myself 23 | func SuspendMe() { 24 | p, _ := os.FindProcess(os.Getppid()) 25 | p.Signal(syscall.SIGTSTP) 26 | p, _ = os.FindProcess(os.Getpid()) 27 | p.Signal(syscall.SIGTSTP) 28 | } 29 | 30 | // get width of the terminal 31 | func getWidth(stdoutFd int) int { 32 | cols, _, err := GetSize(stdoutFd) 33 | if err != nil { 34 | return -1 35 | } 36 | return cols 37 | } 38 | 39 | func GetScreenWidth() int { 40 | w := getWidth(syscall.Stdout) 41 | if w < 0 { 42 | w = getWidth(syscall.Stderr) 43 | } 44 | return w 45 | } 46 | 47 | // ClearScreen clears the console screen 48 | func ClearScreen(w io.Writer) (int, error) { 49 | return w.Write([]byte("\033[H")) 50 | } 51 | 52 | func DefaultIsTerminal() bool { 53 | return IsTerminal(syscall.Stdin) && (IsTerminal(syscall.Stdout) || IsTerminal(syscall.Stderr)) 54 | } 55 | 56 | func GetStdin() int { 57 | return syscall.Stdin 58 | } 59 | 60 | // ----------------------------------------------------------------------------- 61 | 62 | var ( 63 | widthChange sync.Once 64 | widthChangeCallback func() 65 | ) 66 | 67 | func DefaultOnWidthChanged(f func()) { 68 | widthChangeCallback = f 69 | widthChange.Do(func() { 70 | ch := make(chan os.Signal, 1) 71 | signal.Notify(ch, syscall.SIGWINCH) 72 | 73 | go func() { 74 | for { 75 | _, ok := <-ch 76 | if !ok { 77 | break 78 | } 79 | widthChangeCallback() 80 | } 81 | }() 82 | }) 83 | } 84 | -------------------------------------------------------------------------------- /vendor/github.com/chzyer/readline/utils_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package readline 4 | 5 | import ( 6 | "io" 7 | "syscall" 8 | ) 9 | 10 | func SuspendMe() { 11 | } 12 | 13 | func GetStdin() int { 14 | return int(syscall.Stdin) 15 | } 16 | 17 | func init() { 18 | isWindows = true 19 | } 20 | 21 | // get width of the terminal 22 | func GetScreenWidth() int { 23 | info, _ := GetConsoleScreenBufferInfo() 24 | if info == nil { 25 | return -1 26 | } 27 | return int(info.dwSize.x) 28 | } 29 | 30 | // ClearScreen clears the console screen 31 | func ClearScreen(_ io.Writer) error { 32 | return SetConsoleCursorPosition(&_COORD{0, 0}) 33 | } 34 | 35 | func DefaultIsTerminal() bool { 36 | return true 37 | } 38 | 39 | func DefaultOnWidthChanged(func()) { 40 | 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/dave/jennifer/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 David Brophy 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/dave/jennifer/jen/add.go: -------------------------------------------------------------------------------- 1 | package jen 2 | 3 | // Add appends the provided items to the statement. 4 | func Add(code ...Code) *Statement { 5 | return newStatement().Add(code...) 6 | } 7 | 8 | // Add appends the provided items to the statement. 9 | func (g *Group) Add(code ...Code) *Statement { 10 | s := Add(code...) 11 | g.items = append(g.items, s) 12 | return s 13 | } 14 | 15 | // Add appends the provided items to the statement. 16 | func (s *Statement) Add(code ...Code) *Statement { 17 | *s = append(*s, code...) 18 | return s 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/dave/jennifer/jen/dict.go: -------------------------------------------------------------------------------- 1 | package jen 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | "sort" 7 | ) 8 | 9 | // Dict renders as key/value pairs. Use with Values for map or composite 10 | // literals. 11 | type Dict map[Code]Code 12 | 13 | // DictFunc executes a func(Dict) to generate the value. Use with Values for 14 | // map or composite literals. 15 | func DictFunc(f func(Dict)) Dict { 16 | d := Dict{} 17 | f(d) 18 | return d 19 | } 20 | 21 | func (d Dict) render(f *File, w io.Writer, s *Statement) error { 22 | first := true 23 | // must order keys to ensure repeatable source 24 | type kv struct { 25 | k Code 26 | v Code 27 | } 28 | lookup := map[string]kv{} 29 | keys := []string{} 30 | for k, v := range d { 31 | if k.isNull(f) || v.isNull(f) { 32 | continue 33 | } 34 | buf := &bytes.Buffer{} 35 | if err := k.render(f, buf, nil); err != nil { 36 | return err 37 | } 38 | keys = append(keys, buf.String()) 39 | lookup[buf.String()] = kv{k: k, v: v} 40 | } 41 | sort.Strings(keys) 42 | for _, key := range keys { 43 | k := lookup[key].k 44 | v := lookup[key].v 45 | if first && len(keys) > 1 { 46 | if _, err := w.Write([]byte("\n")); err != nil { 47 | return err 48 | } 49 | first = false 50 | } 51 | if err := k.render(f, w, nil); err != nil { 52 | return err 53 | } 54 | if _, err := w.Write([]byte(":")); err != nil { 55 | return err 56 | } 57 | if err := v.render(f, w, nil); err != nil { 58 | return err 59 | } 60 | if len(keys) > 1 { 61 | if _, err := w.Write([]byte(",\n")); err != nil { 62 | return err 63 | } 64 | } 65 | } 66 | return nil 67 | } 68 | 69 | func (d Dict) isNull(f *File) bool { 70 | if d == nil || len(d) == 0 { 71 | return true 72 | } 73 | for k, v := range d { 74 | if !k.isNull(f) && !v.isNull(f) { 75 | // if any of the key/value pairs are both not null, the Dict is not 76 | // null 77 | return false 78 | } 79 | } 80 | return true 81 | } 82 | -------------------------------------------------------------------------------- /vendor/github.com/dave/jennifer/jen/do.go: -------------------------------------------------------------------------------- 1 | package jen 2 | 3 | // Do calls the provided function with the statement as a parameter. Use for 4 | // embedding logic. 5 | func Do(f func(*Statement)) *Statement { 6 | return newStatement().Do(f) 7 | } 8 | 9 | // Do calls the provided function with the statement as a parameter. Use for 10 | // embedding logic. 11 | func (g *Group) Do(f func(*Statement)) *Statement { 12 | s := Do(f) 13 | g.items = append(g.items, s) 14 | return s 15 | } 16 | 17 | // Do calls the provided function with the statement as a parameter. Use for 18 | // embedding logic. 19 | func (s *Statement) Do(f func(*Statement)) *Statement { 20 | f(s) 21 | return s 22 | } 23 | -------------------------------------------------------------------------------- /vendor/github.com/dave/jennifer/jen/tag.go: -------------------------------------------------------------------------------- 1 | package jen 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "sort" 7 | "strconv" 8 | ) 9 | 10 | // Tag renders a struct tag 11 | func Tag(items map[string]string) *Statement { 12 | return newStatement().Tag(items) 13 | } 14 | 15 | // Tag renders a struct tag 16 | func (g *Group) Tag(items map[string]string) *Statement { 17 | // notest 18 | // don't think this can ever be used in valid code? 19 | s := Tag(items) 20 | g.items = append(g.items, s) 21 | return s 22 | } 23 | 24 | // Tag renders a struct tag 25 | func (s *Statement) Tag(items map[string]string) *Statement { 26 | c := tag{ 27 | items: items, 28 | } 29 | *s = append(*s, c) 30 | return s 31 | } 32 | 33 | type tag struct { 34 | items map[string]string 35 | } 36 | 37 | func (t tag) isNull(f *File) bool { 38 | return len(t.items) == 0 39 | } 40 | 41 | func (t tag) render(f *File, w io.Writer, s *Statement) error { 42 | 43 | if t.isNull(f) { 44 | // notest 45 | // render won't be called if t is null 46 | return nil 47 | } 48 | 49 | var str string 50 | 51 | var sorted []string 52 | for k := range t.items { 53 | sorted = append(sorted, k) 54 | } 55 | sort.Strings(sorted) 56 | 57 | for _, k := range sorted { 58 | v := t.items[k] 59 | if len(str) > 0 { 60 | str += " " 61 | } 62 | str += fmt.Sprintf(`%s:"%s"`, k, v) 63 | } 64 | 65 | if strconv.CanBackquote(str) { 66 | str = "`" + str + "`" 67 | } else { 68 | str = strconv.Quote(str) 69 | } 70 | 71 | if _, err := w.Write([]byte(str)); err != nil { 72 | return err 73 | } 74 | 75 | return nil 76 | } 77 | -------------------------------------------------------------------------------- /vendor/github.com/dlclark/regexp2/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | *.out -------------------------------------------------------------------------------- /vendor/github.com/dlclark/regexp2/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.5 5 | - tip -------------------------------------------------------------------------------- /vendor/github.com/dlclark/regexp2/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Doug Clark 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/dlclark/regexp2/syntax/escape.go: -------------------------------------------------------------------------------- 1 | package syntax 2 | 3 | import ( 4 | "bytes" 5 | "strconv" 6 | "strings" 7 | "unicode" 8 | ) 9 | 10 | func Escape(input string) string { 11 | b := &bytes.Buffer{} 12 | for _, r := range input { 13 | escape(b, r, false) 14 | } 15 | return b.String() 16 | } 17 | 18 | const meta = `\.+*?()|[]{}^$# ` 19 | 20 | func escape(b *bytes.Buffer, r rune, force bool) { 21 | if unicode.IsPrint(r) { 22 | if strings.IndexRune(meta, r) >= 0 || force { 23 | b.WriteRune('\\') 24 | } 25 | b.WriteRune(r) 26 | return 27 | } 28 | 29 | switch r { 30 | case '\a': 31 | b.WriteString(`\a`) 32 | case '\f': 33 | b.WriteString(`\f`) 34 | case '\n': 35 | b.WriteString(`\n`) 36 | case '\r': 37 | b.WriteString(`\r`) 38 | case '\t': 39 | b.WriteString(`\t`) 40 | case '\v': 41 | b.WriteString(`\v`) 42 | default: 43 | if r < 0x100 { 44 | b.WriteString(`\x`) 45 | s := strconv.FormatInt(int64(r), 16) 46 | if len(s) == 1 { 47 | b.WriteRune('0') 48 | } 49 | b.WriteString(s) 50 | break 51 | } 52 | b.WriteString(`\u`) 53 | b.WriteString(strconv.FormatInt(int64(r), 16)) 54 | } 55 | } 56 | 57 | func Unescape(input string) (string, error) { 58 | idx := strings.IndexRune(input, '\\') 59 | // no slashes means no unescape needed 60 | if idx == -1 { 61 | return input, nil 62 | } 63 | 64 | buf := bytes.NewBufferString(input[:idx]) 65 | // get the runes for the rest of the string -- we're going full parser scan on this 66 | 67 | p := parser{} 68 | p.setPattern(input[idx+1:]) 69 | for { 70 | if p.rightMost() { 71 | return "", p.getErr(ErrIllegalEndEscape) 72 | } 73 | r, err := p.scanCharEscape() 74 | if err != nil { 75 | return "", err 76 | } 77 | buf.WriteRune(r) 78 | // are we done? 79 | if p.rightMost() { 80 | return buf.String(), nil 81 | } 82 | 83 | r = p.moveRightGetChar() 84 | for r != '\\' { 85 | buf.WriteRune(r) 86 | if p.rightMost() { 87 | // we're done, no more slashes 88 | return buf.String(), nil 89 | } 90 | // keep scanning until we get another slash 91 | r = p.moveRightGetChar() 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /vendor/github.com/dlclark/regexp2/syntax/fuzz.go: -------------------------------------------------------------------------------- 1 | // +build gofuzz 2 | 3 | package syntax 4 | 5 | // Fuzz is the input point for go-fuzz 6 | func Fuzz(data []byte) int { 7 | sdata := string(data) 8 | tree, err := Parse(sdata, RegexOptions(0)) 9 | if err != nil { 10 | return 0 11 | } 12 | 13 | // translate it to code 14 | _, err = Write(tree) 15 | if err != nil { 16 | panic(err) 17 | } 18 | 19 | return 1 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/dlclark/regexp2/syntax/replacerdata.go: -------------------------------------------------------------------------------- 1 | package syntax 2 | 3 | import ( 4 | "bytes" 5 | "errors" 6 | ) 7 | 8 | type ReplacerData struct { 9 | Rep string 10 | Strings []string 11 | Rules []int 12 | } 13 | 14 | const ( 15 | replaceSpecials = 4 16 | replaceLeftPortion = -1 17 | replaceRightPortion = -2 18 | replaceLastGroup = -3 19 | replaceWholeString = -4 20 | ) 21 | 22 | //ErrReplacementError is a general error during parsing the replacement text 23 | var ErrReplacementError = errors.New("Replacement pattern error.") 24 | 25 | // NewReplacerData will populate a reusable replacer data struct based on the given replacement string 26 | // and the capture group data from a regexp 27 | func NewReplacerData(rep string, caps map[int]int, capsize int, capnames map[string]int, op RegexOptions) (*ReplacerData, error) { 28 | p := parser{ 29 | options: op, 30 | caps: caps, 31 | capsize: capsize, 32 | capnames: capnames, 33 | } 34 | p.setPattern(rep) 35 | concat, err := p.scanReplacement() 36 | if err != nil { 37 | return nil, err 38 | } 39 | 40 | if concat.t != ntConcatenate { 41 | panic(ErrReplacementError) 42 | } 43 | 44 | sb := &bytes.Buffer{} 45 | var ( 46 | strings []string 47 | rules []int 48 | ) 49 | 50 | for _, child := range concat.children { 51 | switch child.t { 52 | case ntMulti: 53 | child.writeStrToBuf(sb) 54 | 55 | case ntOne: 56 | sb.WriteRune(child.ch) 57 | 58 | case ntRef: 59 | if sb.Len() > 0 { 60 | rules = append(rules, len(strings)) 61 | strings = append(strings, sb.String()) 62 | sb.Reset() 63 | } 64 | slot := child.m 65 | 66 | if len(caps) > 0 && slot >= 0 { 67 | slot = caps[slot] 68 | } 69 | 70 | rules = append(rules, -replaceSpecials-1-slot) 71 | 72 | default: 73 | panic(ErrReplacementError) 74 | } 75 | } 76 | 77 | if sb.Len() > 0 { 78 | rules = append(rules, len(strings)) 79 | strings = append(strings, sb.String()) 80 | } 81 | 82 | return &ReplacerData{ 83 | Rep: rep, 84 | Strings: strings, 85 | Rules: rules, 86 | }, nil 87 | } 88 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/camelcase/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 1.x 3 | 4 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/camelcase/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Fatih Arslan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/structs/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/structs/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.7.x 4 | - 1.8.x 5 | - tip 6 | sudo: false 7 | before_install: 8 | - go get github.com/axw/gocov/gocov 9 | - go get github.com/mattn/goveralls 10 | - if ! go get github.com/golang/tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi 11 | script: 12 | - $HOME/gopath/bin/goveralls -service=travis-ci 13 | -------------------------------------------------------------------------------- /vendor/github.com/fatih/structs/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Fatih Arslan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /vendor/github.com/fatih/structs/tags.go: -------------------------------------------------------------------------------- 1 | package structs 2 | 3 | import "strings" 4 | 5 | // tagOptions contains a slice of tag options 6 | type tagOptions []string 7 | 8 | // Has returns true if the given optiton is available in tagOptions 9 | func (t tagOptions) Has(opt string) bool { 10 | for _, tagOpt := range t { 11 | if tagOpt == opt { 12 | return true 13 | } 14 | } 15 | 16 | return false 17 | } 18 | 19 | // parseTag splits a struct field's tag into its name and a list of options 20 | // which comes after a name. A tag is in the form of: "name,option1,option2". 21 | // The name can be neglectected. 22 | func parseTag(tag string) (string, tagOptions) { 23 | // tag is one of followings: 24 | // "" 25 | // "name" 26 | // "name,opt" 27 | // "name,opt,opt2" 28 | // ",opt" 29 | 30 | res := strings.Split(tag, ",") 31 | return res[0], res[1:] 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.0 5 | - 1.1 6 | - 1.2 7 | - 1.3 8 | - 1.4 9 | - tip 10 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/context/README.md: -------------------------------------------------------------------------------- 1 | context 2 | ======= 3 | [![Build Status](https://travis-ci.org/gorilla/context.png?branch=master)](https://travis-ci.org/gorilla/context) 4 | 5 | gorilla/context is a general purpose registry for global request variables. 6 | 7 | Read the full documentation here: http://www.gorillatoolkit.org/pkg/context 8 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.0 5 | - 1.1 6 | - 1.2 7 | - tip 8 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Rodrigo Moraes. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/README.md: -------------------------------------------------------------------------------- 1 | mux 2 | === 3 | [![Build Status](https://travis-ci.org/gorilla/mux.png?branch=master)](https://travis-ci.org/gorilla/mux) 4 | 5 | gorilla/mux is a powerful URL router and dispatcher. 6 | 7 | Read the full documentation here: http://www.gorillatoolkit.org/pkg/mux 8 | -------------------------------------------------------------------------------- /vendor/github.com/jmoiron/sqlx/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | tags 24 | environ 25 | -------------------------------------------------------------------------------- /vendor/github.com/jmoiron/sqlx/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Jason Moiron 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------------- /vendor/github.com/jmoiron/sqlx/doc.go: -------------------------------------------------------------------------------- 1 | // Package sqlx provides general purpose extensions to database/sql. 2 | // 3 | // It is intended to seamlessly wrap database/sql and provide convenience 4 | // methods which are useful in the development of database driven applications. 5 | // None of the underlying database/sql methods are changed. Instead all extended 6 | // behavior is implemented through new methods defined on wrapper types. 7 | // 8 | // Additions include scanning into structs, named query support, rebinding 9 | // queries for different drivers, convenient shorthands for common error handling 10 | // and more. 11 | // 12 | package sqlx 13 | -------------------------------------------------------------------------------- /vendor/github.com/jmoiron/sqlx/reflectx/README.md: -------------------------------------------------------------------------------- 1 | # reflectx 2 | 3 | The sqlx package has special reflect needs. In particular, it needs to: 4 | 5 | * be able to map a name to a field 6 | * understand embedded structs 7 | * understand mapping names to fields by a particular tag 8 | * user specified name -> field mapping functions 9 | 10 | These behaviors mimic the behaviors by the standard library marshallers and also the 11 | behavior of standard Go accessors. 12 | 13 | The first two are amply taken care of by `Reflect.Value.FieldByName`, and the third is 14 | addressed by `Reflect.Value.FieldByNameFunc`, but these don't quite understand struct 15 | tags in the ways that are vital to most marshalers, and they are slow. 16 | 17 | This reflectx package extends reflect to achieve these goals. 18 | -------------------------------------------------------------------------------- /vendor/github.com/lib/pq/.gitignore: -------------------------------------------------------------------------------- 1 | .db 2 | *.test 3 | *~ 4 | *.swp 5 | -------------------------------------------------------------------------------- /vendor/github.com/lib/pq/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing to pq 2 | 3 | `pq` has a backlog of pull requests, but contributions are still very 4 | much welcome. You can help with patch review, submitting bug reports, 5 | or adding new functionality. There is no formal style guide, but 6 | please conform to the style of existing code and general Go formatting 7 | conventions when submitting patches. 8 | 9 | ### Patch review 10 | 11 | Help review existing open pull requests by commenting on the code or 12 | proposed functionality. 13 | 14 | ### Bug reports 15 | 16 | We appreciate any bug reports, but especially ones with self-contained 17 | (doesn't depend on code outside of pq), minimal (can't be simplified 18 | further) test cases. It's especially helpful if you can submit a pull 19 | request with just the failing test case (you'll probably want to 20 | pattern it after the tests in 21 | [conn_test.go](https://github.com/lib/pq/blob/master/conn_test.go). 22 | 23 | ### New functionality 24 | 25 | There are a number of pending patches for new functionality, so 26 | additional feature patches will take a while to merge. Still, patches 27 | are generally reviewed based on usefulness and complexity in addition 28 | to time-in-queue, so if you have a knockout idea, take a shot. Feel 29 | free to open an issue discussion your proposed patch beforehand. 30 | -------------------------------------------------------------------------------- /vendor/github.com/lib/pq/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2013, 'pq' Contributors 2 | Portions Copyright (C) 2011 Blake Mizerany 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | -------------------------------------------------------------------------------- /vendor/github.com/lib/pq/buf.go: -------------------------------------------------------------------------------- 1 | package pq 2 | 3 | import ( 4 | "bytes" 5 | "encoding/binary" 6 | 7 | "github.com/lib/pq/oid" 8 | ) 9 | 10 | type readBuf []byte 11 | 12 | func (b *readBuf) int32() (n int) { 13 | n = int(int32(binary.BigEndian.Uint32(*b))) 14 | *b = (*b)[4:] 15 | return 16 | } 17 | 18 | func (b *readBuf) oid() (n oid.Oid) { 19 | n = oid.Oid(binary.BigEndian.Uint32(*b)) 20 | *b = (*b)[4:] 21 | return 22 | } 23 | 24 | // N.B: this is actually an unsigned 16-bit integer, unlike int32 25 | func (b *readBuf) int16() (n int) { 26 | n = int(binary.BigEndian.Uint16(*b)) 27 | *b = (*b)[2:] 28 | return 29 | } 30 | 31 | func (b *readBuf) string() string { 32 | i := bytes.IndexByte(*b, 0) 33 | if i < 0 { 34 | errorf("invalid message format; expected string terminator") 35 | } 36 | s := (*b)[:i] 37 | *b = (*b)[i+1:] 38 | return string(s) 39 | } 40 | 41 | func (b *readBuf) next(n int) (v []byte) { 42 | v = (*b)[:n] 43 | *b = (*b)[n:] 44 | return 45 | } 46 | 47 | func (b *readBuf) byte() byte { 48 | return b.next(1)[0] 49 | } 50 | 51 | type writeBuf struct { 52 | buf []byte 53 | pos int 54 | } 55 | 56 | func (b *writeBuf) int32(n int) { 57 | x := make([]byte, 4) 58 | binary.BigEndian.PutUint32(x, uint32(n)) 59 | b.buf = append(b.buf, x...) 60 | } 61 | 62 | func (b *writeBuf) int16(n int) { 63 | x := make([]byte, 2) 64 | binary.BigEndian.PutUint16(x, uint16(n)) 65 | b.buf = append(b.buf, x...) 66 | } 67 | 68 | func (b *writeBuf) string(s string) { 69 | b.buf = append(b.buf, (s + "\000")...) 70 | } 71 | 72 | func (b *writeBuf) byte(c byte) { 73 | b.buf = append(b.buf, c) 74 | } 75 | 76 | func (b *writeBuf) bytes(v []byte) { 77 | b.buf = append(b.buf, v...) 78 | } 79 | 80 | func (b *writeBuf) wrap() []byte { 81 | p := b.buf[b.pos:] 82 | binary.BigEndian.PutUint32(p, uint32(len(p))) 83 | return b.buf 84 | } 85 | 86 | func (b *writeBuf) next(c byte) { 87 | p := b.buf[b.pos:] 88 | binary.BigEndian.PutUint32(p, uint32(len(p))) 89 | b.pos = len(b.buf) + 1 90 | b.buf = append(b.buf, c, 0, 0, 0, 0) 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/lib/pq/oid/doc.go: -------------------------------------------------------------------------------- 1 | // Package oid contains OID constants 2 | // as defined by the Postgres server. 3 | package oid 4 | 5 | // Oid is a Postgres Object ID. 6 | type Oid uint32 7 | -------------------------------------------------------------------------------- /vendor/github.com/lib/pq/oid/gen.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | // Generate the table of OID values 4 | // Run with 'go run gen.go'. 5 | package main 6 | 7 | import ( 8 | "database/sql" 9 | "fmt" 10 | "log" 11 | "os" 12 | "os/exec" 13 | 14 | _ "github.com/lib/pq" 15 | ) 16 | 17 | func main() { 18 | datname := os.Getenv("PGDATABASE") 19 | sslmode := os.Getenv("PGSSLMODE") 20 | 21 | if datname == "" { 22 | os.Setenv("PGDATABASE", "pqgotest") 23 | } 24 | 25 | if sslmode == "" { 26 | os.Setenv("PGSSLMODE", "disable") 27 | } 28 | 29 | db, err := sql.Open("postgres", "") 30 | if err != nil { 31 | log.Fatal(err) 32 | } 33 | cmd := exec.Command("gofmt") 34 | cmd.Stderr = os.Stderr 35 | w, err := cmd.StdinPipe() 36 | if err != nil { 37 | log.Fatal(err) 38 | } 39 | f, err := os.Create("types.go") 40 | if err != nil { 41 | log.Fatal(err) 42 | } 43 | cmd.Stdout = f 44 | err = cmd.Start() 45 | if err != nil { 46 | log.Fatal(err) 47 | } 48 | fmt.Fprintln(w, "// generated by 'go run gen.go'; do not edit") 49 | fmt.Fprintln(w, "\npackage oid") 50 | fmt.Fprintln(w, "const (") 51 | rows, err := db.Query(` 52 | SELECT typname, oid 53 | FROM pg_type WHERE oid < 10000 54 | ORDER BY oid; 55 | `) 56 | if err != nil { 57 | log.Fatal(err) 58 | } 59 | var name string 60 | var oid int 61 | for rows.Next() { 62 | err = rows.Scan(&name, &oid) 63 | if err != nil { 64 | log.Fatal(err) 65 | } 66 | fmt.Fprintf(w, "T_%s Oid = %d\n", name, oid) 67 | } 68 | if err = rows.Err(); err != nil { 69 | log.Fatal(err) 70 | } 71 | fmt.Fprintln(w, ")") 72 | w.Close() 73 | cmd.Wait() 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/lib/pq/url.go: -------------------------------------------------------------------------------- 1 | package pq 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | nurl "net/url" 7 | "sort" 8 | "strings" 9 | ) 10 | 11 | // ParseURL no longer needs to be used by clients of this library since supplying a URL as a 12 | // connection string to sql.Open() is now supported: 13 | // 14 | // sql.Open("postgres", "postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full") 15 | // 16 | // It remains exported here for backwards-compatibility. 17 | // 18 | // ParseURL converts a url to a connection string for driver.Open. 19 | // Example: 20 | // 21 | // "postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full" 22 | // 23 | // converts to: 24 | // 25 | // "user=bob password=secret host=1.2.3.4 port=5432 dbname=mydb sslmode=verify-full" 26 | // 27 | // A minimal example: 28 | // 29 | // "postgres://" 30 | // 31 | // This will be blank, causing driver.Open to use all of the defaults 32 | func ParseURL(url string) (string, error) { 33 | u, err := nurl.Parse(url) 34 | if err != nil { 35 | return "", err 36 | } 37 | 38 | if u.Scheme != "postgres" && u.Scheme != "postgresql" { 39 | return "", fmt.Errorf("invalid connection protocol: %s", u.Scheme) 40 | } 41 | 42 | var kvs []string 43 | escaper := strings.NewReplacer(` `, `\ `, `'`, `\'`, `\`, `\\`) 44 | accrue := func(k, v string) { 45 | if v != "" { 46 | kvs = append(kvs, k+"="+escaper.Replace(v)) 47 | } 48 | } 49 | 50 | if u.User != nil { 51 | v := u.User.Username() 52 | accrue("user", v) 53 | 54 | v, _ = u.User.Password() 55 | accrue("password", v) 56 | } 57 | 58 | if host, port, err := net.SplitHostPort(u.Host); err != nil { 59 | accrue("host", u.Host) 60 | } else { 61 | accrue("host", host) 62 | accrue("port", port) 63 | } 64 | 65 | if u.Path != "" { 66 | accrue("dbname", u.Path[1:]) 67 | } 68 | 69 | q := u.Query() 70 | for k := range q { 71 | accrue(k, q.Get(k)) 72 | } 73 | 74 | sort.Strings(kvs) // Makes testing easier (not a performance concern) 75 | return strings.Join(kvs, " "), nil 76 | } 77 | -------------------------------------------------------------------------------- /vendor/github.com/lib/pq/user_posix.go: -------------------------------------------------------------------------------- 1 | // Package pq is a pure Go Postgres driver for the database/sql package. 2 | 3 | // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris 4 | 5 | package pq 6 | 7 | import ( 8 | "os" 9 | "os/user" 10 | ) 11 | 12 | func userCurrent() (string, error) { 13 | u, err := user.Current() 14 | if err == nil { 15 | return u.Username, nil 16 | } 17 | 18 | name := os.Getenv("USER") 19 | if name != "" { 20 | return name, nil 21 | } 22 | 23 | return "", ErrCouldNotDetectUsername 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/lib/pq/user_windows.go: -------------------------------------------------------------------------------- 1 | // Package pq is a pure Go Postgres driver for the database/sql package. 2 | package pq 3 | 4 | import ( 5 | "path/filepath" 6 | "syscall" 7 | ) 8 | 9 | // Perform Windows user name lookup identically to libpq. 10 | // 11 | // The PostgreSQL code makes use of the legacy Win32 function 12 | // GetUserName, and that function has not been imported into stock Go. 13 | // GetUserNameEx is available though, the difference being that a 14 | // wider range of names are available. To get the output to be the 15 | // same as GetUserName, only the base (or last) component of the 16 | // result is returned. 17 | func userCurrent() (string, error) { 18 | pw_name := make([]uint16, 128) 19 | pwname_size := uint32(len(pw_name)) - 1 20 | err := syscall.GetUserNameEx(syscall.NameSamCompatible, &pw_name[0], &pwname_size) 21 | if err != nil { 22 | return "", ErrCouldNotDetectUsername 23 | } 24 | s := syscall.UTF16ToString(pw_name) 25 | u := filepath.Base(s) 26 | return u, nil 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/looplab/fsm/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | 24 | *.sublime-project 25 | *.sublime-workspace 26 | 27 | .DS_Store 28 | .wercker 29 | -------------------------------------------------------------------------------- /vendor/github.com/looplab/fsm/event.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2013 - Max Persson 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package fsm 16 | 17 | // Event is the info that get passed as a reference in the callbacks. 18 | type Event struct { 19 | // FSM is a reference to the current FSM. 20 | FSM *FSM 21 | 22 | // Event is the event name. 23 | Event string 24 | 25 | // Src is the state before the transition. 26 | Src string 27 | 28 | // Dst is the state after the transition. 29 | Dst string 30 | 31 | // Err is an optional error that can be returned from a callback. 32 | Err error 33 | 34 | // Args is a optinal list of arguments passed to the callback. 35 | Args []interface{} 36 | 37 | // canceled is an internal flag set if the transition is canceled. 38 | canceled bool 39 | 40 | // async is an internal flag set if the transition should be asynchronous 41 | async bool 42 | } 43 | 44 | // Cancel can be called in before_ or leave_ to cancel the 45 | // current transition before it happens. It takes an opitonal error, which will 46 | // overwrite e.Err if set before. 47 | func (e *Event) Cancel(err ...error) { 48 | e.canceled = true 49 | 50 | if len(err) > 0 { 51 | e.Err = err[0] 52 | } 53 | } 54 | 55 | // Async can be called in leave_ to do an asynchronous state transition. 56 | // 57 | // The current state transition will be on hold in the old state until a final 58 | // call to Transition is made. This will comlete the transition and possibly 59 | // call the other callbacks. 60 | func (e *Event) Async() { 61 | e.async = true 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/looplab/fsm/wercker.yml: -------------------------------------------------------------------------------- 1 | box: golang 2 | 3 | dev: 4 | steps: 5 | - internal/watch: 6 | code: | 7 | go build ./... 8 | reload: true 9 | 10 | build: 11 | steps: 12 | - wercker/setup-go-workspace: 13 | package-dir: github.com/looplab/fsm 14 | 15 | - wercker/golint 16 | 17 | - script: 18 | name: go get 19 | code: | 20 | cd $WERCKER_SOURCE_DIR 21 | go version 22 | go get -t ./... 23 | 24 | - script: 25 | name: go build 26 | code: | 27 | go build ./... 28 | 29 | - script: 30 | name: go test 31 | code: | 32 | go get github.com/mattn/goveralls 33 | goveralls -v -service wercker.com -flags -race 34 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - tip 4 | 5 | before_install: 6 | - go get github.com/mattn/goveralls 7 | - go get golang.org/x/tools/cmd/cover 8 | script: 9 | - $HOME/gopath/bin/goveralls -repotoken xnXqRGwgW3SXIguzxf90ZSK1GPYZPaGrw 10 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Yasuhiro Matsumoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/README.md: -------------------------------------------------------------------------------- 1 | # go-colorable 2 | 3 | [![Godoc Reference](https://godoc.org/github.com/mattn/go-colorable?status.svg)](http://godoc.org/github.com/mattn/go-colorable) 4 | [![Build Status](https://travis-ci.org/mattn/go-colorable.svg?branch=master)](https://travis-ci.org/mattn/go-colorable) 5 | [![Coverage Status](https://coveralls.io/repos/github/mattn/go-colorable/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-colorable?branch=master) 6 | [![Go Report Card](https://goreportcard.com/badge/mattn/go-colorable)](https://goreportcard.com/report/mattn/go-colorable) 7 | 8 | Colorable writer for windows. 9 | 10 | For example, most of logger packages doesn't show colors on windows. (I know we can do it with ansicon. But I don't want.) 11 | This package is possible to handle escape sequence for ansi color on windows. 12 | 13 | ## Too Bad! 14 | 15 | ![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/bad.png) 16 | 17 | 18 | ## So Good! 19 | 20 | ![](https://raw.githubusercontent.com/mattn/go-colorable/gh-pages/good.png) 21 | 22 | ## Usage 23 | 24 | ```go 25 | logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true}) 26 | logrus.SetOutput(colorable.NewColorableStdout()) 27 | 28 | logrus.Info("succeeded") 29 | logrus.Warn("not correct") 30 | logrus.Error("something error") 31 | logrus.Fatal("panic") 32 | ``` 33 | 34 | You can compile above code on non-windows OSs. 35 | 36 | ## Installation 37 | 38 | ``` 39 | $ go get github.com/mattn/go-colorable 40 | ``` 41 | 42 | # License 43 | 44 | MIT 45 | 46 | # Author 47 | 48 | Yasuhiro Matsumoto (a.k.a mattn) 49 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/colorable_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package colorable 4 | 5 | import ( 6 | "io" 7 | "os" 8 | 9 | _ "github.com/mattn/go-isatty" 10 | ) 11 | 12 | // NewColorable return new instance of Writer which handle escape sequence. 13 | func NewColorable(file *os.File) io.Writer { 14 | if file == nil { 15 | panic("nil passed instead of *os.File to NewColorable()") 16 | } 17 | 18 | return file 19 | } 20 | 21 | // NewColorableStdout return new instance of Writer which handle escape sequence for stdout. 22 | func NewColorableStdout() io.Writer { 23 | return os.Stdout 24 | } 25 | 26 | // NewColorableStderr return new instance of Writer which handle escape sequence for stderr. 27 | func NewColorableStderr() io.Writer { 28 | return os.Stderr 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/colorable_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | // +build !appengine 3 | 4 | package colorable 5 | 6 | import ( 7 | "io" 8 | "os" 9 | 10 | _ "github.com/mattn/go-isatty" 11 | ) 12 | 13 | // NewColorable return new instance of Writer which handle escape sequence. 14 | func NewColorable(file *os.File) io.Writer { 15 | if file == nil { 16 | panic("nil passed instead of *os.File to NewColorable()") 17 | } 18 | 19 | return file 20 | } 21 | 22 | // NewColorableStdout return new instance of Writer which handle escape sequence for stdout. 23 | func NewColorableStdout() io.Writer { 24 | return os.Stdout 25 | } 26 | 27 | // NewColorableStderr return new instance of Writer which handle escape sequence for stderr. 28 | func NewColorableStderr() io.Writer { 29 | return os.Stderr 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-colorable/noncolorable.go: -------------------------------------------------------------------------------- 1 | package colorable 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | ) 7 | 8 | // NonColorable hold writer but remove escape sequence. 9 | type NonColorable struct { 10 | out io.Writer 11 | } 12 | 13 | // NewNonColorable return new instance of Writer which remove escape sequence from Writer. 14 | func NewNonColorable(w io.Writer) io.Writer { 15 | return &NonColorable{out: w} 16 | } 17 | 18 | // Write write data on console 19 | func (w *NonColorable) Write(data []byte) (n int, err error) { 20 | er := bytes.NewReader(data) 21 | var bw [1]byte 22 | loop: 23 | for { 24 | c1, err := er.ReadByte() 25 | if err != nil { 26 | break loop 27 | } 28 | if c1 != 0x1b { 29 | bw[0] = c1 30 | w.out.Write(bw[:]) 31 | continue 32 | } 33 | c2, err := er.ReadByte() 34 | if err != nil { 35 | break loop 36 | } 37 | if c2 != 0x5b { 38 | continue 39 | } 40 | 41 | var buf bytes.Buffer 42 | for { 43 | c, err := er.ReadByte() 44 | if err != nil { 45 | break loop 46 | } 47 | if ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || c == '@' { 48 | break 49 | } 50 | buf.Write([]byte(string(c))) 51 | } 52 | } 53 | 54 | return len(data), nil 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - tip 4 | 5 | before_install: 6 | - go get github.com/mattn/goveralls 7 | - go get golang.org/x/tools/cmd/cover 8 | script: 9 | - $HOME/gopath/bin/goveralls -repotoken 3gHdORO5k5ziZcWMBxnd9LrMZaJs8m9x5 10 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) Yasuhiro MATSUMOTO 2 | 3 | MIT License (Expat) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/README.md: -------------------------------------------------------------------------------- 1 | # go-isatty 2 | 3 | [![Godoc Reference](https://godoc.org/github.com/mattn/go-isatty?status.svg)](http://godoc.org/github.com/mattn/go-isatty) 4 | [![Build Status](https://travis-ci.org/mattn/go-isatty.svg?branch=master)](https://travis-ci.org/mattn/go-isatty) 5 | [![Coverage Status](https://coveralls.io/repos/github/mattn/go-isatty/badge.svg?branch=master)](https://coveralls.io/github/mattn/go-isatty?branch=master) 6 | [![Go Report Card](https://goreportcard.com/badge/mattn/go-isatty)](https://goreportcard.com/report/mattn/go-isatty) 7 | 8 | isatty for golang 9 | 10 | ## Usage 11 | 12 | ```go 13 | package main 14 | 15 | import ( 16 | "fmt" 17 | "github.com/mattn/go-isatty" 18 | "os" 19 | ) 20 | 21 | func main() { 22 | if isatty.IsTerminal(os.Stdout.Fd()) { 23 | fmt.Println("Is Terminal") 24 | } else if isatty.IsCygwinTerminal(os.Stdout.Fd()) { 25 | fmt.Println("Is Cygwin/MSYS2 Terminal") 26 | } else { 27 | fmt.Println("Is Not Terminal") 28 | } 29 | } 30 | ``` 31 | 32 | ## Installation 33 | 34 | ``` 35 | $ go get github.com/mattn/go-isatty 36 | ``` 37 | 38 | ## License 39 | 40 | MIT 41 | 42 | ## Author 43 | 44 | Yasuhiro Matsumoto (a.k.a mattn) 45 | 46 | ## Thanks 47 | 48 | * k-takata: base idea for IsCygwinTerminal 49 | 50 | https://github.com/k-takata/go-iscygpty 51 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/doc.go: -------------------------------------------------------------------------------- 1 | // Package isatty implements interface to isatty 2 | package isatty 3 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package isatty 4 | 5 | // IsTerminal returns true if the file descriptor is terminal which 6 | // is always false on on appengine classic which is a sandboxed PaaS. 7 | func IsTerminal(fd uintptr) bool { 8 | return false 9 | } 10 | 11 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 12 | // terminal. This is also always false on this environment. 13 | func IsCygwinTerminal(fd uintptr) bool { 14 | return false 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_linux.go: -------------------------------------------------------------------------------- 1 | // +build linux 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "syscall" 8 | "unsafe" 9 | ) 10 | 11 | const ioctlReadTermios = syscall.TCGETS 12 | 13 | // IsTerminal return true if the file descriptor is terminal. 14 | func IsTerminal(fd uintptr) bool { 15 | var termios syscall.Termios 16 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 17 | return err == 0 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_others.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 7 | // terminal. This is also always false on this environment. 8 | func IsCygwinTerminal(fd uintptr) bool { 9 | return false 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-isatty/isatty_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import ( 7 | "golang.org/x/sys/unix" 8 | ) 9 | 10 | // IsTerminal returns true if the given file descriptor is a terminal. 11 | // see: http://src.illumos.org/source/xref/illumos-gate/usr/src/lib/libbc/libc/gen/common/isatty.c 12 | func IsTerminal(fd uintptr) bool { 13 | var termio unix.Termio 14 | err := unix.IoctlSetTermio(int(fd), unix.TCGETA, &termio) 15 | return err == nil 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/profile/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go_import_path: github.com/pkg/profile 3 | go: 4 | - 1.4.3 5 | - 1.5.2 6 | - 1.6.3 7 | - tip 8 | 9 | script: 10 | - go test github.com/pkg/profile 11 | - go test -race github.com/pkg/profile 12 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/profile/AUTHORS: -------------------------------------------------------------------------------- 1 | Dave Cheney 2 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/profile/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Dave Cheney. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/profile/README.md: -------------------------------------------------------------------------------- 1 | profile 2 | ======= 3 | 4 | Simple profiling support package for Go 5 | 6 | [![Build Status](https://travis-ci.org/pkg/profile.svg?branch=master)](https://travis-ci.org/pkg/profile) [![GoDoc](http://godoc.org/github.com/pkg/profile?status.svg)](http://godoc.org/github.com/pkg/profile) 7 | 8 | 9 | installation 10 | ------------ 11 | 12 | go get github.com/pkg/profile 13 | 14 | usage 15 | ----- 16 | 17 | Enabling profiling in your application is as simple as one line at the top of your main function 18 | 19 | ```go 20 | import "github.com/pkg/profile" 21 | 22 | func main() { 23 | defer profile.Start().Stop() 24 | ... 25 | } 26 | ``` 27 | 28 | options 29 | ------- 30 | 31 | What to profile is controlled by config value passed to profile.Start. 32 | By default CPU profiling is enabled. 33 | 34 | ```go 35 | import "github.com/pkg/profile" 36 | 37 | func main() { 38 | // p.Stop() must be called before the program exits to 39 | // ensure profiling information is written to disk. 40 | p := profile.Start(profile.MemProfile, profile.ProfilePath("."), profile.NoShutdownHook) 41 | ... 42 | } 43 | ``` 44 | 45 | Several convenience package level values are provided for cpu, memory, and block (contention) profiling. 46 | 47 | For more complex options, consult the [documentation](http://godoc.org/github.com/pkg/profile). 48 | 49 | contributing 50 | ------------ 51 | 52 | We welcome pull requests, bug fixes and issue reports. 53 | 54 | Before proposing a change, please discuss it first by raising an issue. 55 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/profile/mutex.go: -------------------------------------------------------------------------------- 1 | // +build go1.8 2 | 3 | package profile 4 | 5 | import "runtime" 6 | 7 | func enableMutexProfile() { 8 | runtime.SetMutexProfileFraction(1) 9 | } 10 | 11 | func disableMutexProfile() { 12 | runtime.SetMutexProfileFraction(0) 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/profile/mutex17.go: -------------------------------------------------------------------------------- 1 | // +build !go1.8 2 | 3 | package profile 4 | 5 | // mock mutex support for Go 1.7 and earlier. 6 | 7 | func enableMutexProfile() {} 8 | 9 | func disableMutexProfile() {} 10 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/profile/trace.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | 3 | package profile 4 | 5 | import "runtime/trace" 6 | 7 | var startTrace = trace.Start 8 | var stopTrace = trace.Stop 9 | -------------------------------------------------------------------------------- /vendor/github.com/pkg/profile/trace16.go: -------------------------------------------------------------------------------- 1 | // +build !go1.7 2 | 3 | package profile 4 | 5 | import "io" 6 | 7 | // mock trace support for Go 1.6 and earlier. 8 | 9 | func startTrace(w io.Writer) error { return nil } 10 | func stopTrace() {} 11 | -------------------------------------------------------------------------------- /vendor/github.com/st0012/metago/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ -------------------------------------------------------------------------------- /vendor/github.com/st0012/metago/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.5 5 | - 1.6 6 | - 1.7 7 | - 1.8.x 8 | 9 | script: 10 | - ./test.sh 11 | 12 | after_script: 13 | - go build . 14 | 15 | after_success: 16 | - bash <(curl -s https://codecov.io/bash) 17 | 18 | notifications: 19 | email: 20 | recipients: 21 | - stan001212@gmail.com 22 | on_failure: change 23 | on_success: never 24 | -------------------------------------------------------------------------------- /vendor/github.com/st0012/metago/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Stan Lo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/st0012/metago/README.md: -------------------------------------------------------------------------------- 1 | # metago 2 | 3 | [![Build Status](https://travis-ci.org/st0012/metago.svg?branch=master)](https://travis-ci.org/st0012/metago) 4 | [![codecov](https://codecov.io/gh/st0012/metago/branch/master/graph/badge.svg)](https://codecov.io/gh/st0012/metago) 5 | 6 | `metago` is trying to provide Ruby-like meta-programming features to Go. Mostly just for fun. 7 | 8 | ## Install 9 | 10 | ``` 11 | go get github.com/st0012/metago 12 | ``` 13 | 14 | ## Usage 15 | 16 | Currently `metago` only has one function: `CallFunc` 17 | 18 | ``` 19 | CallFunc(receiver interface{}, methodName string, args ...interface{}) interface{} 20 | ``` 21 | 22 | Here's how you can use it: 23 | 24 | ```go 25 | package main 26 | 27 | import ( 28 | "fmt" 29 | "github.com/st0012/metago" 30 | ) 31 | 32 | type Bar struct { 33 | name string 34 | } 35 | 36 | func (b *Bar) Name() string { 37 | return b.name 38 | } 39 | 40 | func (b *Bar) SetName(n string) { 41 | b.name = n 42 | } 43 | 44 | func (b *Bar) Send(methodName string, args ...interface{}) interface{} { 45 | return metago.CallFunc(b, methodName, args...) 46 | } 47 | 48 | func main() { 49 | b := &Bar{} 50 | b.Send("SetName", "Stan") // This is like Object#send in Ruby 51 | fmt.Println(b.name) // Should be "Stan" 52 | fmt.Println(b.Send("Name")) // Should also be "Stan" 53 | } 54 | ``` 55 | 56 | As you can see, you can call `*Bar` dynamically. Just like Ruby: 57 | 58 | ```ruby 59 | b = Bar.new 60 | b.send(:set_name, "Stan") 61 | ``` 62 | 63 | ## Future work 64 | 65 | I'll trying to add more meta-programming features in Ruby like `method_missing` or `define_method`...etc. -------------------------------------------------------------------------------- /vendor/github.com/st0012/metago/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | SLEEP=0.5 4 | 5 | set -e 6 | echo "" > coverage.txt 7 | 8 | for d in $(go list ./... | grep -v vendor); do 9 | go test -race -coverprofile=profile.out -covermode=atomic $d 10 | if [ -f profile.out ]; then 11 | cat profile.out >> coverage.txt 12 | rm profile.out 13 | fi 14 | done 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/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 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/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 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/.gitignore: -------------------------------------------------------------------------------- 1 | _obj/ 2 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-64 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-112 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-64 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-88 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for 386, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·socketcall(SB),NOSPLIT,$0-36 29 | JMP syscall·socketcall(SB) 30 | 31 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 32 | JMP syscall·rawsocketcall(SB) 33 | 34 | TEXT ·seek(SB),NOSPLIT,$0-28 35 | JMP syscall·seek(SB) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 29 | JMP syscall·gettimeofday(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | B syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | B syscall·RawSyscall6(SB) 27 | 28 | TEXT ·seek(SB),NOSPLIT,$0-32 29 | B syscall·seek(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 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 linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 21 | B syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | B syscall·RawSyscall6(SB) 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 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 linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | JMP syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | JMP syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_mipsx.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips mipsle 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-28 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 25 | JMP syscall·Syscall9(SB) 26 | 27 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 28 | JMP syscall·RawSyscall(SB) 29 | 30 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 31 | JMP syscall·RawSyscall6(SB) 32 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 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 linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm.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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 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 !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-88 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 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 dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_big.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build ppc64 s390x mips mips64 6 | 7 | package unix 8 | 9 | const isBigEndian = true 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/endian_little.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le 6 | 7 | package unix 8 | 9 | const isBigEndian = false 10 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.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 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unset.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 unix 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd openbsd netbsd dragonfly 2 | 3 | // Copyright 2014 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 | // +build darwin dragonfly freebsd linux netbsd openbsd 8 | 9 | package unix 10 | 11 | import "unsafe" 12 | 13 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 14 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 15 | var fcntl64Syscall uintptr = SYS_FCNTL 16 | 17 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 18 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 19 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 20 | if errno == 0 { 21 | return nil 22 | } 23 | return errno 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm linux,mips linux,mipsle 2 | 3 | // Copyright 2014 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 unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // We can't use the gc-syntax .s files for gccgo. On the plus side 12 | // much of the functionality can be written directly in Go. 13 | 14 | //extern gccgoRealSyscall 15 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 16 | 17 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 18 | syscall.Entersyscall() 19 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 20 | syscall.Exitsyscall() 21 | return r, 0, syscall.Errno(errno) 22 | } 23 | 24 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 25 | syscall.Entersyscall() 26 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 27 | syscall.Exitsyscall() 28 | return r, 0, syscall.Errno(errno) 29 | } 30 | 31 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 32 | syscall.Entersyscall() 33 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 34 | syscall.Exitsyscall() 35 | return r, 0, syscall.Errno(errno) 36 | } 37 | 38 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 39 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 40 | return r, 0, syscall.Errno(errno) 41 | } 42 | 43 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 45 | return r, 0, syscall.Errno(errno) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #define _STRINGIFY2_(x) #x 12 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 13 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 14 | 15 | // Call syscall from C code because the gccgo support for calling from 16 | // Go to C does not support varargs functions. 17 | 18 | struct ret { 19 | uintptr_t r; 20 | uintptr_t err; 21 | }; 22 | 23 | struct ret 24 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 25 | { 26 | struct ret r; 27 | 28 | errno = 0; 29 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 30 | r.err = errno; 31 | return r; 32 | } 33 | 34 | // Define the use function in C so that it is not inlined. 35 | 36 | extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline)); 37 | 38 | void 39 | use(void *p __attribute__ ((unused))) 40 | { 41 | } 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,amd64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern gettimeofday 12 | func realGettimeofday(*Timeval, *byte) int32 13 | 14 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 15 | r := realGettimeofday(tv, nil) 16 | if r < 0 { 17 | return syscall.GetErrno() 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_sparc64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,sparc64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern sysconf 12 | func realSysconf(name int) int64 13 | 14 | func sysconf(name int) (n int64, err syscall.Errno) { 15 | r := realSysconf(name) 16 | if r < 0 { 17 | return 0, syscall.GetErrno() 18 | } 19 | return r, 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_darwin.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for Darwin from sys/syscall.h 7 | 8 | use strict; 9 | 10 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 11 | print STDERR "GOARCH or GOOS not defined in environment\n"; 12 | exit 1; 13 | } 14 | 15 | my $command = "mksysnum_darwin.pl " . join(' ', @ARGV); 16 | 17 | print <){ 29 | if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){ 30 | my $name = $1; 31 | my $num = $2; 32 | $name =~ y/a-z/A-Z/; 33 | print " SYS_$name = $num;" 34 | } 35 | } 36 | 37 | print <){ 30 | if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <){ 30 | if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | if($name =~ /^SYS_CAP_+/ || $name =~ /^SYS___CAP_+/){ 44 | next 45 | } 46 | 47 | print " $name = $num; // $proto\n"; 48 | 49 | # We keep Capsicum syscall numbers for FreeBSD 50 | # 9-STABLE here because we are not sure whether they 51 | # are mature and stable. 52 | if($num == 513){ 53 | print " SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }\n"; 54 | print " SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \\\n"; 55 | print " SYS_CAP_ENTER = 516 // { int cap_enter(void); }\n"; 56 | print " SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }\n"; 57 | } 58 | } 59 | } 60 | 61 | print <){ 31 | if($line =~ /^(.*)\\$/) { 32 | # Handle continuation 33 | $line = $1; 34 | $_ =~ s/^\s+//; 35 | $line .= $_; 36 | } else { 37 | # New line 38 | $line = $_; 39 | } 40 | next if $line =~ /\\$/; 41 | if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) { 42 | my $num = $1; 43 | my $proto = $6; 44 | my $compat = $8; 45 | my $name = "$7_$9"; 46 | 47 | $name = "$7_$11" if $11 ne ''; 48 | $name =~ y/a-z/A-Z/; 49 | 50 | if($compat eq '' || $compat eq '30' || $compat eq '50') { 51 | print " $name = $num; // $proto\n"; 52 | } 53 | } 54 | } 55 | 56 | print <){ 30 | if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $3; 33 | my $name = $4; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 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 unix 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func Getpagesize() int { return 4096 } 13 | 14 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 15 | 16 | func NsecToTimespec(nsec int64) (ts Timespec) { 17 | ts.Sec = int32(nsec / 1e9) 18 | ts.Nsec = int32(nsec % 1e9) 19 | return 20 | } 21 | 22 | func NsecToTimeval(nsec int64) (tv Timeval) { 23 | nsec += 999 // round up to microsecond 24 | tv.Usec = int32(nsec % 1e9 / 1e3) 25 | tv.Sec = int32(nsec / 1e9) 26 | return 27 | } 28 | 29 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 30 | func Gettimeofday(tv *Timeval) (err error) { 31 | // The tv passed to gettimeofday must be non-nil 32 | // but is otherwise unused. The answers come back 33 | // in the two registers. 34 | sec, usec, err := gettimeofday(tv) 35 | tv.Sec = int32(sec) 36 | tv.Usec = int32(usec) 37 | return err 38 | } 39 | 40 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 41 | k.Ident = uint32(fd) 42 | k.Filter = int16(mode) 43 | k.Flags = uint16(flags) 44 | } 45 | 46 | func (iov *Iovec) SetLen(length int) { 47 | iov.Len = uint32(length) 48 | } 49 | 50 | func (msghdr *Msghdr) SetControllen(length int) { 51 | msghdr.Controllen = uint32(length) 52 | } 53 | 54 | func (cmsg *Cmsghdr) SetLen(length int) { 55 | cmsg.Len = uint32(length) 56 | } 57 | 58 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 59 | var length = uint64(count) 60 | 61 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 62 | 63 | written = int(length) 64 | 65 | if e1 != 0 { 66 | err = e1 67 | } 68 | return 69 | } 70 | 71 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 72 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 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 arm64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 16384 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = sec 38 | tv.Usec = usec 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint64(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint64(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 74 | 75 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 76 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 77 | const SYS___SYSCTL = SYS_SYSCTL 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = nsec % 1e9 / 1e3 27 | tv.Sec = int64(nsec / 1e9) 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint64(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint64(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm.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 arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = nsec / 1e9 28 | return 29 | } 30 | 31 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 32 | k.Ident = uint32(fd) 33 | k.Filter = int16(mode) 34 | k.Flags = uint16(flags) 35 | } 36 | 37 | func (iov *Iovec) SetLen(length int) { 38 | iov.Len = uint32(length) 39 | } 40 | 41 | func (msghdr *Msghdr) SetControllen(length int) { 42 | msghdr.Controllen = uint32(length) 43 | } 44 | 45 | func (cmsg *Cmsghdr) SetLen(length int) { 46 | cmsg.Len = uint32(length) 47 | } 48 | 49 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 50 | var writtenOut uint64 = 0 51 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 52 | 53 | written = int(writtenOut) 54 | 55 | if e1 != 0 { 56 | err = e1 57 | } 58 | return 59 | } 60 | 61 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 62 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,linux 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | //go:noescape 13 | func gettimeofday(tv *Timeval) (err syscall.Errno) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int64(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.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 arm,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = uint32(mode) 29 | k.Flags = uint32(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_no_getwd.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 dragonfly freebsd netbsd openbsd 6 | 7 | package unix 8 | 9 | const ImplementsGetwd = false 10 | 11 | func Getwd() (string, error) { return "", ENOTSUP } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = int32(nsec % 1e9 / 1e3) 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint32(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint32(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = nsec / 1e9 15 | ts.Nsec = nsec % 1e9 16 | return 17 | } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = nsec % 1e9 / 1e3 22 | tv.Sec = nsec / 1e9 23 | return 24 | } 25 | 26 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 27 | k.Ident = uint64(fd) 28 | k.Filter = int16(mode) 29 | k.Flags = uint16(flags) 30 | } 31 | 32 | func (iov *Iovec) SetLen(length int) { 33 | iov.Len = uint64(length) 34 | } 35 | 36 | func (msghdr *Msghdr) SetControllen(length int) { 37 | msghdr.Controllen = uint32(length) 38 | } 39 | 40 | func (cmsg *Cmsghdr) SetLen(length int) { 41 | cmsg.Len = uint32(length) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 10 | 11 | func NsecToTimespec(nsec int64) (ts Timespec) { 12 | ts.Sec = nsec / 1e9 13 | ts.Nsec = nsec % 1e9 14 | return 15 | } 16 | 17 | func NsecToTimeval(nsec int64) (tv Timeval) { 18 | nsec += 999 // round up to microsecond 19 | tv.Usec = nsec % 1e9 / 1e3 20 | tv.Sec = int64(nsec / 1e9) 21 | return 22 | } 23 | 24 | func (iov *Iovec) SetLen(length int) { 25 | iov.Len = uint64(length) 26 | } 27 | 28 | func (cmsg *Cmsghdr) SetLen(length int) { 29 | cmsg.Len = uint32(length) 30 | } 31 | 32 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 33 | // TODO(aram): implement this, see issue 5847. 34 | panic("unimplemented") 35 | } 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_unix_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.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 amd64,solaris 6 | 7 | package unix 8 | 9 | // TODO(aram): remove these before Go 1.3. 10 | const ( 11 | SYS_EXECVE = 59 12 | SYS_FCNTL = 62 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/modules.txt: -------------------------------------------------------------------------------- 1 | # github.com/chzyer/readline v0.0.0-20170313234921-41eea22f717c 2 | github.com/chzyer/readline 3 | # github.com/dave/jennifer v0.19.0 4 | github.com/dave/jennifer/jen 5 | # github.com/dlclark/regexp2 v1.1.6 6 | github.com/dlclark/regexp2 7 | github.com/dlclark/regexp2/syntax 8 | # github.com/fatih/camelcase v1.0.0 9 | github.com/fatih/camelcase 10 | # github.com/fatih/structs v0.0.0-20170524075631-74a29b9fac73 11 | github.com/fatih/structs 12 | # github.com/gorilla/context v0.0.0-20141217160251-215affda49ad 13 | github.com/gorilla/context 14 | # github.com/gorilla/mux v0.0.0-20140926153814-e444e69cbd2e 15 | github.com/gorilla/mux 16 | # github.com/jmoiron/sqlx v0.0.0-20160206221533-398dd5876282 17 | github.com/jmoiron/sqlx 18 | github.com/jmoiron/sqlx/reflectx 19 | # github.com/lib/pq v0.0.0-20160316202507-3cd0097429be 20 | github.com/lib/pq 21 | github.com/lib/pq/oid 22 | # github.com/looplab/fsm v0.0.0-20170404094036-bcc3636384ce 23 | github.com/looplab/fsm 24 | # github.com/mattn/go-colorable v0.0.0-20170811043054-6df6d4d004b6 25 | github.com/mattn/go-colorable 26 | # github.com/mattn/go-isatty v0.0.2 27 | github.com/mattn/go-isatty 28 | # github.com/pkg/profile v0.0.0-20170413231811-06b906832ed0 29 | github.com/pkg/profile 30 | # github.com/st0012/metago v0.0.0-20170729114159-0405a10ef6ad 31 | github.com/st0012/metago 32 | # golang.org/x/sys v0.0.0-20170710161658-abf9c25f5445 33 | golang.org/x/sys/unix 34 | -------------------------------------------------------------------------------- /vm/array_enumerator_test.go: -------------------------------------------------------------------------------- 1 | package vm 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestArrayEnumeratorEnumerationWithoutElements(t *testing.T) { 8 | input := ` 9 | enumerator = ArrayEnumerator.new([]) 10 | enumerator.has_next? 11 | ` 12 | 13 | expected := false 14 | 15 | v := initTestVM() 16 | evaluated := v.testEval(t, input, getFilename()) 17 | VerifyExpected(t, 0, evaluated, expected) 18 | v.checkCFP(t, 0, 0) 19 | v.checkSP(t, 0, 1) 20 | } 21 | 22 | func TestArrayEnumeratorEnumerationWithElements(t *testing.T) { 23 | input := ` 24 | iterated_values = [] 25 | 26 | enumerator = ArrayEnumerator.new([1, 2, 4]) 27 | 28 | while enumerator.has_next? do 29 | iterated_values.push(enumerator.next) 30 | end 31 | 32 | iterated_values 33 | ` 34 | 35 | expected := []interface{}{1, 2, 4} 36 | 37 | v := initTestVM() 38 | evaluated := v.testEval(t, input, getFilename()) 39 | verifyArrayObject(t, i, evaluated, expected) 40 | v.checkCFP(t, i, 0) 41 | v.checkSP(t, i, 1) 42 | } 43 | 44 | func TestArrayEnumeratorRaiseErrorWhenNoElementsOnNext(t *testing.T) { 45 | testCase := errorTestCase{` 46 | ArrayEnumerator.new([]).next 47 | `, "StopIteration: \"No more elements!\"", 2} 48 | 49 | v := initTestVM() 50 | evaluated := v.testEval(t, testCase.input, getFilename()) 51 | checkErrorMsg(t, i, evaluated, testCase.expected) 52 | v.checkCFP(t, i, testCase.expectedCFP) 53 | v.checkSP(t, i, 2) 54 | } 55 | -------------------------------------------------------------------------------- /vm/block_test.go: -------------------------------------------------------------------------------- 1 | package vm 2 | 3 | import "testing" 4 | 5 | func TestBlockInitialize(t *testing.T) { 6 | tests := []struct { 7 | input string 8 | expected interface{} 9 | }{ 10 | {` 11 | b = Block.new do 12 | 100 13 | end 14 | 15 | b.call 16 | `, 100}, 17 | 18 | {` 19 | def baz 20 | 1000 21 | end 22 | 23 | class Foo 24 | def exec_block(block) 25 | block.call 26 | end 27 | 28 | def baz 29 | 100 30 | end 31 | end 32 | 33 | b = Block.new do 34 | baz 35 | end 36 | 37 | f = Foo.new 38 | f.exec_block(b) 39 | `, 1000}, 40 | {` 41 | bl = Block.new do |array| 42 | array.reduce do |sum, i| 43 | sum + i 44 | end 45 | end 46 | bl.call([1, 2, 3, 4])`, 10}, 47 | {` 48 | p = Block.new do |i, j, k| 49 | [i, j, k] 50 | end 51 | p.call(1, 2, 3, 4, 5)`, []interface{}{1, 2, 3}}, 52 | } 53 | 54 | for i, tt := range tests { 55 | v := initTestVM() 56 | evaluated := v.testEval(t, tt.input, getFilename()) 57 | VerifyExpected(t, i, evaluated, tt.expected) 58 | v.checkCFP(t, i, 0) 59 | v.checkSP(t, i, 1) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /vm/channel_test.go: -------------------------------------------------------------------------------- 1 | package vm 2 | 3 | import "testing" 4 | 5 | func TestChannelClassSuperclass(t *testing.T) { 6 | tests := []struct { 7 | input string 8 | expected string 9 | }{ 10 | {`Channel.class.name`, "Class"}, 11 | {`Channel.superclass.name`, "Object"}, 12 | } 13 | 14 | for i, tt := range tests { 15 | v := initTestVM() 16 | evaluated := v.testEval(t, tt.input, getFilename()) 17 | VerifyExpected(t, i, evaluated, tt.expected) 18 | v.checkCFP(t, i, 0) 19 | v.checkSP(t, i, 1) 20 | } 21 | } 22 | 23 | func TestChannelCloseFail(t *testing.T) { 24 | testsFail := []errorTestCase{ 25 | {`c = Channel.new; c.close(1)`, "ArgumentError: Expect 0 argument(s). got: 1", 1}, 26 | {`c = Channel.new; c.close;c.close`, "ChannelCloseError: The channel is already closed.", 1}, 27 | } 28 | 29 | for i, tt := range testsFail { 30 | v := initTestVM() 31 | evaluated := v.testEval(t, tt.input, getFilename()) 32 | checkErrorMsg(t, i, evaluated, tt.expected) 33 | v.checkCFP(t, i, tt.expectedCFP) 34 | v.checkSP(t, i, 1) 35 | } 36 | } 37 | 38 | func TestChannelReceiveFail(t *testing.T) { 39 | testsFail := []errorTestCase{ 40 | {`c = Channel.new; c.receive(1)`, "ArgumentError: Expect 0 argument(s). got: 1", 1}, 41 | {`c = Channel.new; c.close; c.receive`, "ChannelCloseError: The channel is already closed.", 1}, 42 | } 43 | 44 | for i, tt := range testsFail { 45 | v := initTestVM() 46 | evaluated := v.testEval(t, tt.input, getFilename()) 47 | checkErrorMsg(t, i, evaluated, tt.expected) 48 | v.checkCFP(t, i, tt.expectedCFP) 49 | v.checkSP(t, i, 1) 50 | } 51 | } 52 | 53 | func TestChannelDeliverFail(t *testing.T) { 54 | testsFail := []errorTestCase{ 55 | {`c = Channel.new; c.deliver`, "ArgumentError: Expect 1 argument(s). got: 0", 1}, 56 | {`c = Channel.new; c.deliver 1, 2`, "ArgumentError: Expect 1 argument(s). got: 2", 1}, 57 | {`c = Channel.new; c.close; c.deliver 1`, "ChannelCloseError: The channel is already closed.", 1}, 58 | } 59 | 60 | for i, tt := range testsFail { 61 | v := initTestVM() 62 | evaluated := v.testEval(t, tt.input, getFilename()) 63 | checkErrorMsg(t, i, evaluated, tt.expected) 64 | v.checkCFP(t, i, tt.expectedCFP) 65 | v.checkSP(t, i, 1) 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /vm/classes/classes.go: -------------------------------------------------------------------------------- 1 | package classes 2 | 3 | // A list of native classes 4 | const ( 5 | ObjectClass = "Object" 6 | ClassClass = "Class" 7 | ModuleClass = "Module" 8 | IntegerClass = "Integer" 9 | FloatClass = "Float" 10 | StringClass = "String" 11 | ArrayClass = "Array" 12 | HashClass = "Hash" 13 | BooleanClass = "Boolean" 14 | NullClass = "Null" 15 | ChannelClass = "Channel" 16 | RangeClass = "Range" 17 | MethodClass = "Method" 18 | PluginClass = "Plugin" 19 | GoObjectClass = "GoObject" 20 | FileClass = "File" 21 | RegexpClass = "Regexp" 22 | MatchDataClass = "MatchData" 23 | GoMapClass = "GoMap" 24 | DecimalClass = "Decimal" 25 | BlockClass = "Block" 26 | ) 27 | -------------------------------------------------------------------------------- /vm/diggable.go: -------------------------------------------------------------------------------- 1 | package vm 2 | 3 | // Diggable represents a class that support the #dig method. 4 | type Diggable interface { 5 | dig(t *Thread, keys []Object, sourceLine int) Object 6 | } 7 | -------------------------------------------------------------------------------- /vm/environment.go: -------------------------------------------------------------------------------- 1 | package vm 2 | 3 | import "sort" 4 | 5 | func newEnvironment() *environment { 6 | s := make(map[string]Object) 7 | return &environment{store: s} 8 | } 9 | 10 | type environment struct { 11 | store map[string]Object 12 | } 13 | 14 | func (e *environment) get(name string) (Object, bool) { 15 | obj, ok := e.store[name] 16 | return obj, ok 17 | } 18 | 19 | func (e *environment) set(name string, val Object) Object { 20 | e.store[name] = val 21 | return val 22 | } 23 | 24 | func (e *environment) names() []string { 25 | keys := []string{} 26 | for key := range e.store { 27 | keys = append(keys, key) 28 | } 29 | sort.Strings(keys) 30 | return keys 31 | } 32 | 33 | func (e *environment) copy() *environment { 34 | newEnv := make(map[string]Object) 35 | for key, value := range e.store { 36 | newEnv[key] = value 37 | } 38 | return &environment{store: newEnv} 39 | } 40 | -------------------------------------------------------------------------------- /vm/http_request_test.go: -------------------------------------------------------------------------------- 1 | package vm 2 | 3 | import ( 4 | "testing" 5 | //"net/http/httptest" 6 | //"net/http" 7 | //"fmt" 8 | ) 9 | 10 | func TestHTTPRequestObject(t *testing.T) { 11 | tests := []struct { 12 | input string 13 | expected interface{} 14 | }{ 15 | {` 16 | require "net/http" 17 | 18 | req = Net::HTTP::Request.new 19 | req.method = "GET" 20 | 21 | req.method 22 | `, "GET"}, 23 | {` 24 | require "net/http" 25 | 26 | req = Net::HTTP::Request.new 27 | req.set_header("Content-Type", "text/plain") 28 | 29 | req.headers["Content-Type"] 30 | `, "text/plain"}, 31 | } 32 | 33 | for i, tt := range tests { 34 | v := initTestVM() 35 | evaluated := v.testEval(t, tt.input, getFilename()) 36 | VerifyExpected(t, i, evaluated, tt.expected) 37 | v.checkCFP(t, i, 0) 38 | v.checkSP(t, i, 1) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /vm/http_response_test.go: -------------------------------------------------------------------------------- 1 | package vm 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "net/http/httptest" 7 | "testing" 8 | ) 9 | 10 | func TestHTTPResponseObject(t *testing.T) { 11 | input := ` 12 | require "net/http" 13 | 14 | res = Net::HTTP::Response.new 15 | 16 | res.body = "test" 17 | res.status = 200 18 | 19 | res.body 20 | ` 21 | 22 | v := initTestVM() 23 | evaluated := v.testEval(t, input, getFilename()) 24 | VerifyExpected(t, 0, evaluated, "test") 25 | v.checkCFP(t, 0, 0) 26 | v.checkSP(t, 0, 1) 27 | } 28 | 29 | func TestNormalGetResponse(t *testing.T) { 30 | expected := "Hello, client" 31 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 32 | fmt.Fprint(w, expected) 33 | })) 34 | 35 | defer ts.Close() 36 | 37 | testScript := fmt.Sprintf(` 38 | require "net/http" 39 | 40 | Net::HTTP.get("%s") 41 | `, ts.URL) 42 | 43 | v := initTestVM() 44 | evaluated := v.testEval(t, testScript, getFilename()) 45 | VerifyExpected(t, 0, evaluated, expected) 46 | v.checkCFP(t, 0, 0) 47 | v.checkSP(t, 0, 1) 48 | } 49 | 50 | func TestNormalGetResponseWithPath(t *testing.T) { 51 | expected := "Hello, client" 52 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 53 | switch r.RequestURI { 54 | case "/path": 55 | fmt.Fprint(w, expected) 56 | default: 57 | http.Error(w, "not found", http.StatusNotFound) 58 | } 59 | })) 60 | 61 | defer ts.Close() 62 | 63 | testScript := fmt.Sprintf(` 64 | require "net/http" 65 | 66 | Net::HTTP.get("%s", "path") 67 | `, ts.URL) 68 | 69 | v := initTestVM() 70 | evaluated := v.testEval(t, testScript, getFilename()) 71 | VerifyExpected(t, 0, evaluated, expected) 72 | v.checkCFP(t, 0, 0) 73 | v.checkSP(t, 0, 1) 74 | } 75 | -------------------------------------------------------------------------------- /vm/inspection_methods.go: -------------------------------------------------------------------------------- 1 | package vm 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "strings" 7 | ) 8 | 9 | // Polymorphic helper functions for inspecting internal info. 10 | 11 | func (is *instructionSet) inspect() string { 12 | var out bytes.Buffer 13 | 14 | for _, i := range is.instructions { 15 | out.WriteString(i.Inspect()) 16 | out.WriteString("\n") 17 | } 18 | 19 | return out.String() 20 | } 21 | 22 | func (cf *goMethodCallFrame) inspect() string { 23 | return fmt.Sprintf("Go method frame. File name: %s. Method name: %s.", cf.FileName(), cf.name) 24 | } 25 | 26 | func (cf *normalCallFrame) inspect() string { 27 | if cf.ep != nil { 28 | return fmt.Sprintf("Normal frame. File name: %s. IS name: %s. is block: %t. ep: %d. source line: %d", cf.FileName(), cf.instructionSet.name, cf.isBlock, len(cf.ep.locals), cf.SourceLine()) 29 | } 30 | return fmt.Sprintf("Normal frame. File name: %s. IS name: %s. is block: %t. source line: %d", cf.FileName(), cf.instructionSet.name, cf.isBlock, cf.SourceLine()) 31 | } 32 | 33 | func (cfs *callFrameStack) inspect() string { 34 | var out bytes.Buffer 35 | 36 | for _, cf := range cfs.callFrames { 37 | if cf != nil { 38 | out.WriteString(fmt.Sprintln(cf.inspect())) 39 | } 40 | } 41 | 42 | return out.String() 43 | } 44 | 45 | func (s *Stack) inspect() string { 46 | var out bytes.Buffer 47 | datas := []string{} 48 | 49 | for i, p := range s.data { 50 | if p != nil { 51 | o := p.Target 52 | if i == s.pointer { 53 | datas = append(datas, fmt.Sprintf("%s (%T) %d <----", o.ToString(), o, i)) 54 | } else { 55 | datas = append(datas, fmt.Sprintf("%s (%T) %d", o.ToString(), o, i)) 56 | } 57 | 58 | } else { 59 | if i == s.pointer { 60 | datas = append(datas, "nil <----") 61 | } else { 62 | datas = append(datas, "nil") 63 | } 64 | 65 | } 66 | 67 | } 68 | 69 | out.WriteString("-----------\n") 70 | out.WriteString(strings.Join(datas, "\n")) 71 | out.WriteString("\n---------\n") 72 | 73 | return out.String() 74 | } 75 | -------------------------------------------------------------------------------- /vm/instruction_translator.go: -------------------------------------------------------------------------------- 1 | package vm 2 | 3 | import ( 4 | "github.com/goby-lang/goby/compiler/bytecode" 5 | ) 6 | 7 | // instructionTranslator is responsible for parsing bytecodes 8 | type instructionTranslator struct { 9 | vm *VM 10 | setTable map[setType]map[string][]*instructionSet 11 | blockTable map[string]*instructionSet 12 | filename filename 13 | program *instructionSet 14 | } 15 | 16 | // newInstructionTranslator initializes instructionTranslator and its instruction set table then returns it 17 | func newInstructionTranslator(file filename) *instructionTranslator { 18 | it := &instructionTranslator{filename: file} 19 | it.blockTable = make(map[string]*instructionSet) 20 | it.setTable = map[setType]map[string][]*instructionSet{ 21 | bytecode.MethodDef: make(map[string][]*instructionSet), 22 | bytecode.ClassDef: make(map[string][]*instructionSet), 23 | } 24 | 25 | return it 26 | } 27 | 28 | func (it *instructionTranslator) setMetadata(is *instructionSet, set *bytecode.InstructionSet) { 29 | t := set.Type() 30 | n := set.Name() 31 | 32 | is.name = n 33 | 34 | switch t { 35 | case bytecode.Program: 36 | it.program = is 37 | case bytecode.Block: 38 | it.blockTable[n] = is 39 | default: 40 | it.setTable[t][n] = append(it.setTable[t][n], is) 41 | } 42 | } 43 | 44 | func (it *instructionTranslator) transferInstructionSets(sets []*bytecode.InstructionSet) { 45 | for _, set := range sets { 46 | is := &instructionSet{filename: it.filename} 47 | is.instructions = set.Instructions 48 | is.paramTypes = set.ArgTypes() 49 | it.setMetadata(is, set) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /vm/issue_vm.go: -------------------------------------------------------------------------------- 1 | package vm 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "os" 7 | "runtime" 8 | 9 | "github.com/goby-lang/goby/compiler/parser" 10 | ) 11 | 12 | // InitIssueReportVM initializes a vm in test mode for issue reporting 13 | func InitIssueReportVM(dir string, args []string) (*VM, error) { 14 | v, err := New(dir, args) 15 | v.mode = parser.TestMode 16 | 17 | return v, err 18 | } 19 | 20 | // PrintError prints an error report string given a vm which evaluated to and Error object 21 | func PrintError(v *VM) { 22 | if v.mainThread.Stack.top() == nil { 23 | fmt.Println("No error detected: stack empty") 24 | return 25 | } 26 | eval := v.mainThread.Stack.top().Target 27 | err, ok := eval.(*Error) 28 | if !ok { 29 | fmt.Println("No error detected") 30 | } 31 | fmt.Printf("# %s\n", err.Type) 32 | fmt.Println(err.Message()) 33 | 34 | fmt.Printf("### Goby version\n%s\n", Version) 35 | fmt.Printf("### GOBY_ROOT\n%s\n", os.Getenv("GOBY_ROOT")) 36 | fmt.Printf("### Go version\n%s\n", runtime.Version()) 37 | fmt.Printf("### GOROOT\n%s\n", os.Getenv("GOROOT")) 38 | fmt.Printf("### GOPATH\n%s\n", os.Getenv("GOPATH")) 39 | fmt.Printf("### Operating system\n%s\n", runtime.GOOS) 40 | 41 | t := &v.mainThread 42 | cf := t.callFrameStack.top() 43 | 44 | file := cf.FileName() 45 | line := cf.SourceLine() 46 | 47 | // Print lines in file surrounding error in markdown code block 48 | f, osErr := os.Open(string(file)) 49 | if osErr != nil { 50 | fmt.Println("Could not open problem file") 51 | } 52 | 53 | scanner := bufio.NewScanner(f) 54 | 55 | scanner.Split(bufio.ScanLines) 56 | 57 | currLine := 0 58 | // Skip lines until at least 20 lines from error 59 | for ; currLine < line-20; currLine++ { 60 | scanner.Scan() 61 | } 62 | fmt.Println("``` ruby") 63 | // Print until 20 lines past error 64 | for ; currLine < line+20 && scanner.Scan(); currLine++ { 65 | fmt.Printf("%s\n", scanner.Text()) 66 | } 67 | fmt.Println("```") 68 | } 69 | -------------------------------------------------------------------------------- /vm/main_object_test.go: -------------------------------------------------------------------------------- 1 | package vm 2 | 3 | import "testing" 4 | 5 | func TestMainToS(t *testing.T) { 6 | tests := []struct { 7 | input string 8 | expected string 9 | }{ 10 | {`to_s`, "main"}, 11 | } 12 | 13 | for i, tt := range tests { 14 | v := initTestVM() 15 | evaluated := v.testEval(t, tt.input, getFilename()) 16 | VerifyExpected(t, i, evaluated, tt.expected) 17 | v.checkCFP(t, i, 0) 18 | v.checkSP(t, i, 1) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /vm/numeric.go: -------------------------------------------------------------------------------- 1 | package vm 2 | 3 | // Numeric currently represents a class that support some numeric conversions. 4 | // At this stage, it's not meant to be a Goby class in a strict sense, but only 5 | // a convenient interface. 6 | type Numeric interface { 7 | floatValue() float64 8 | lessThan(object Object) bool 9 | } 10 | -------------------------------------------------------------------------------- /vm/repl.go: -------------------------------------------------------------------------------- 1 | package vm 2 | 3 | import ( 4 | "github.com/goby-lang/goby/compiler/bytecode" 5 | "github.com/goby-lang/goby/compiler/parser" 6 | ) 7 | 8 | // InitForREPL does following things: 9 | // - Initialize instruction sets' index tables 10 | // - Set vm to REPL mode 11 | // - Create and push main object frame 12 | func (vm *VM) InitForREPL() { 13 | vm.SetClassISIndexTable("REPL") 14 | vm.SetMethodISIndexTable("REPL") 15 | 16 | // REPL should maintain a base call frame so that the whole program won't exit 17 | cf := newNormalCallFrame(&instructionSet{name: "REPL base"}, "REPL", 1) 18 | cf.self = vm.mainObj 19 | vm.mode = parser.REPLMode 20 | vm.mainThread.callFrameStack.push(cf) 21 | } 22 | 23 | // REPLExec executes instructions differently from normal program execution. 24 | func (vm *VM) REPLExec(sets []*bytecode.InstructionSet) { 25 | p := newInstructionTranslator("REPL") 26 | p.vm = vm 27 | p.transferInstructionSets(sets) 28 | 29 | for setType, table := range p.setTable { 30 | for name, is := range table { 31 | vm.isTables[setType][name] = is 32 | } 33 | } 34 | 35 | vm.blockTables[p.filename] = p.blockTable 36 | 37 | oldFrame := vm.mainThread.callFrameStack.pop() 38 | cf := newNormalCallFrame(p.program, p.filename, oldFrame.SourceLine()) 39 | cf.self = vm.mainObj 40 | cf.locals = oldFrame.Locals() 41 | cf.ep = oldFrame.EP() 42 | cf.isBlock = oldFrame.IsBlock() 43 | cf.isSourceBlock = oldFrame.IsSourceBlock() 44 | cf.self = oldFrame.Self() 45 | cf.lPr = oldFrame.LocalPtr() 46 | vm.mainThread.callFrameStack.push(cf) 47 | 48 | defer func() { 49 | e := recover() 50 | 51 | switch err := e.(type) { 52 | case error: 53 | panic(err) 54 | } 55 | }() 56 | 57 | vm.mainThread.startFromTopFrame() 58 | } 59 | 60 | // GetExecResult returns stack's top most value. Normally it's used in tests. 61 | func (vm *VM) GetExecResult() Object { 62 | top := vm.mainThread.Stack.top() 63 | if top != nil { 64 | return top.Target 65 | } 66 | return NULL 67 | } 68 | 69 | // GetREPLResult returns strings that should be showed after each evaluation. 70 | func (vm *VM) GetREPLResult() string { 71 | top := vm.mainThread.Stack.Pop() 72 | 73 | if top != nil { 74 | return top.Target.ToString() 75 | } 76 | 77 | return "" 78 | } 79 | -------------------------------------------------------------------------------- /vm/spec.go: -------------------------------------------------------------------------------- 1 | package vm 2 | 3 | func initSpecClass(vm *VM) { 4 | vm.mainThread.execGobyLib("spec.gb") 5 | } 6 | -------------------------------------------------------------------------------- /vm/spec_test.go: -------------------------------------------------------------------------------- 1 | package vm 2 | 3 | import ( 4 | "os" 5 | "os/exec" 6 | "testing" 7 | ) 8 | 9 | func TestSpecSuccessWithExitCode0(t *testing.T) { 10 | input := ` 11 | require "spec" 12 | 13 | Spec.describe Spec do 14 | it "passes" do 15 | expect(1).to eq(1) 16 | end 17 | end 18 | 19 | Spec.run 20 | ` 21 | if os.Getenv("TEST_SPEC_NOT_EXIT") == "1" { 22 | v := initTestVM() 23 | result := v.testEval(t, input, getFilename()) 24 | VerifyExpected(t, 0, result, 10) 25 | return 26 | } 27 | 28 | cmd := exec.Command(os.Args[0], "-test.run=TestSpecSuccessWithExitCode0") 29 | cmd.Env = append(os.Environ(), "TEST_SPEC_NOT_EXIT=1") 30 | err := cmd.Run() 31 | if e, ok := err.(*exec.ExitError); ok && !e.Success() { 32 | t.Fatalf("Spec should exit with status 0.") 33 | } 34 | } 35 | 36 | func TestSpecFailWithExitCode1(t *testing.T) { 37 | input := ` 38 | require "spec" 39 | 40 | Spec.describe Spec do 41 | it "fails and exit with code 1" do 42 | expect(1).to eq(2) 43 | end 44 | end 45 | 46 | Spec.run 47 | ` 48 | if os.Getenv("TEST_SPEC_EXIT") == "1" { 49 | v := initTestVM() 50 | v.testEval(t, input, getFilename()) 51 | return 52 | } 53 | 54 | cmd := exec.Command(os.Args[0], "-test.run=TestSpecFailWithExitCode1") 55 | cmd.Env = append(os.Environ(), "TEST_SPEC_EXIT=1") 56 | err := cmd.Run() 57 | if e, ok := err.(*exec.ExitError); ok && !e.Success() { 58 | return 59 | } 60 | t.Fatalf("Spec fail should exit with status 1.") 61 | } 62 | -------------------------------------------------------------------------------- /vm/stack.go: -------------------------------------------------------------------------------- 1 | package vm 2 | 3 | import ( 4 | "sync" 5 | ) 6 | 7 | // Stack is a basic stack implementation 8 | type Stack struct { 9 | data []*Pointer 10 | pointer int 11 | // Although every thread has its own stack, vm's main thread still can be accessed by other threads. 12 | // This is why we need a lock in stack 13 | // TODO: Find a way to fix this instead of put lock on every stack. 14 | sync.RWMutex 15 | } 16 | 17 | // Set a value at a given index in the stack. TODO: Maybe we should be checking for size before we do this. 18 | func (s *Stack) Set(index int, pointer *Pointer) { 19 | s.Lock() 20 | 21 | s.data[index] = pointer 22 | 23 | s.Unlock() 24 | } 25 | 26 | // Push an element to the top of the stack 27 | func (s *Stack) Push(v *Pointer) { 28 | s.Lock() 29 | 30 | if len(s.data) <= s.pointer { 31 | s.data = append(s.data, v) 32 | } else { 33 | s.data[s.pointer] = v 34 | } 35 | 36 | s.pointer++ 37 | s.Unlock() 38 | } 39 | 40 | // Pop an element off the top of the stack 41 | func (s *Stack) Pop() *Pointer { 42 | s.Lock() 43 | 44 | if len(s.data) < 1 { 45 | panic("Nothing to pop!") 46 | } 47 | 48 | if s.pointer < 0 { 49 | panic("SP is not normal!") 50 | } 51 | 52 | if s.pointer > 0 { 53 | s.pointer-- 54 | } 55 | 56 | v := s.data[s.pointer] 57 | s.data[s.pointer] = nil 58 | s.Unlock() 59 | return v 60 | } 61 | 62 | func (s *Stack) top() *Pointer { 63 | var r *Pointer 64 | s.RLock() 65 | 66 | if len(s.data) == 0 { 67 | r = nil 68 | } else if s.pointer > 0 { 69 | r = s.data[s.pointer-1] 70 | } else { 71 | r = s.data[0] 72 | } 73 | 74 | s.RUnlock() 75 | 76 | return r 77 | } 78 | -------------------------------------------------------------------------------- /wiki/Introduction_to_Goby_slide_preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goby-lang/goby/0589a71a10e0b73524db57ec13108b86f2ef61cf/wiki/Introduction_to_Goby_slide_preview.png -------------------------------------------------------------------------------- /wiki/goby_codebase_gocity-min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goby-lang/goby/0589a71a10e0b73524db57ec13108b86f2ef61cf/wiki/goby_codebase_gocity-min.png -------------------------------------------------------------------------------- /wiki/goby_structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goby-lang/goby/0589a71a10e0b73524db57ec13108b86f2ef61cf/wiki/goby_structure.png -------------------------------------------------------------------------------- /wiki/goland_logo-text.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goby-lang/goby/0589a71a10e0b73524db57ec13108b86f2ef61cf/wiki/goland_logo-text.png -------------------------------------------------------------------------------- /wiki/goland_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goby-lang/goby/0589a71a10e0b73524db57ec13108b86f2ef61cf/wiki/goland_logo.png -------------------------------------------------------------------------------- /wiki/organization1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goby-lang/goby/0589a71a10e0b73524db57ec13108b86f2ef61cf/wiki/organization1.png -------------------------------------------------------------------------------- /wiki/organization2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goby-lang/goby/0589a71a10e0b73524db57ec13108b86f2ef61cf/wiki/organization2.png --------------------------------------------------------------------------------