├── .gitignore ├── LICENSE ├── README.md ├── caches ├── cache.go ├── encode.go ├── leveldb.go ├── leveldb_test.go ├── lru.go ├── lru_test.go ├── manager.go ├── memory_store.go └── memory_store_test.go ├── cipher.go ├── context_cache.go ├── contexts ├── context_cache.go ├── hook.go └── hook_test.go ├── convert.go ├── convert └── conversion.go ├── core ├── db.go ├── db_test.go ├── error.go ├── interface.go ├── rows.go ├── scan.go ├── stmt.go └── tx.go ├── databook.go ├── dataset.go ├── dialects ├── dialect.go ├── driver.go ├── filter.go ├── filter_test.go ├── gen_reserved.sh ├── mssql.go ├── mssql_test.go ├── mysql.go ├── oracle.go ├── oracle_test.go ├── pg_reserved.txt ├── postgres.go ├── postgres_test.go ├── quote.go ├── sqlite3.go ├── sqlite3_test.go ├── table_name.go ├── table_name_test.go └── time.go ├── encrypt_aes.go ├── encrypt_des.go ├── encrypt_rsa.go ├── engine.go ├── engine_group.go ├── engine_group_policy.go ├── engine_sqlmap.go ├── engine_sqltemplate.go ├── engineplus.go ├── error.go ├── fswatcher.go ├── helpers_plus.go ├── integrations ├── cache_test.go ├── engine_group_test.go ├── engine_test.go ├── main_test.go ├── processors_test.go ├── rows_test.go ├── session_cols_test.go ├── session_cond_test.go ├── session_delete_test.go ├── session_exist_test.go ├── session_find_test.go ├── session_get_test.go ├── session_insert_test.go ├── session_iterate_test.go ├── session_pk_test.go ├── session_query_test.go ├── session_raw_test.go ├── session_schema_test.go ├── session_stats_test.go ├── session_test.go ├── session_tx_test.go ├── session_update_test.go ├── tags_test.go ├── tests.go ├── time_test.go ├── types_null_test.go └── types_test.go ├── interface.go ├── internal ├── json │ └── json.go ├── statements │ ├── cache.go │ ├── column_map.go │ ├── expr_param.go │ ├── insert.go │ ├── pk.go │ ├── query.go │ ├── statement.go │ ├── statement_args.go │ ├── statement_test.go │ ├── update.go │ └── values.go └── utils │ ├── name.go │ ├── reflect.go │ ├── slice.go │ ├── sql.go │ ├── strings.go │ ├── uuid.go │ ├── zero.go │ └── zero_test.go ├── json.go ├── log ├── logger.go ├── logger_context.go └── syslogger.go ├── migrate ├── migrate.go └── migrate_test.go ├── names ├── mapper.go ├── mapper_test.go ├── table_name.go └── table_name_test.go ├── null.go ├── null_bool.go ├── null_float32.go ├── null_float64.go ├── null_int.go ├── null_int16.go ├── null_int32.go ├── null_int64.go ├── null_int8.go ├── null_string.go ├── null_time.go ├── null_uint.go ├── null_uint16.go ├── null_uint32.go ├── null_uint64.go ├── null_uint8.go ├── pg_reserved.txt ├── processors.go ├── rows.go ├── schemas ├── column.go ├── index.go ├── pk.go ├── pk_test.go ├── quote.go ├── quote_test.go ├── table.go ├── table_test.go └── type.go ├── session.go ├── session_cols.go ├── session_cond.go ├── session_convert.go ├── session_delete.go ├── session_exist.go ├── session_find.go ├── session_get.go ├── session_insert.go ├── session_iterate.go ├── session_plus.go ├── session_query.go ├── session_raw.go ├── session_schema.go ├── session_stats.go ├── session_tx.go ├── session_tx_plus.go ├── session_update.go ├── sql_executor.go ├── sql_expr.go ├── sqlmap.go ├── sqlmap_json.go ├── sqlmap_xml.go ├── sqlmap_xsql.go ├── sqlmaps_executor.go ├── sqltemplate.go ├── sqltemplate_default.go ├── sqltemplate_jet.go ├── sqltemplate_pongo2.go ├── sqltemplates_executor.go ├── string_builder.go ├── tags ├── parser.go ├── parser_test.go ├── tag.go └── tag_test.go ├── test ├── sql │ └── oracle │ │ ├── fxi.xx │ │ ├── select.example.jet │ │ ├── select.example.stpl │ │ ├── select.example.tpl │ │ ├── studygolang.xml │ │ └── test.json └── xorm_test.go ├── value.go ├── vendor ├── github.com │ ├── Chronokeeper │ │ └── anyxml │ │ │ ├── LICENSE │ │ │ ├── anyxml.go │ │ │ └── xml.go │ ├── CloudyKit │ │ ├── fastprinter │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── decimal.go │ │ │ ├── extfloat.go │ │ │ ├── float.go │ │ │ └── printers.go │ │ └── jet │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── constructors.go │ │ │ ├── default.go │ │ │ ├── eval.go │ │ │ ├── func.go │ │ │ ├── lex.go │ │ │ ├── loader.go │ │ │ ├── node.go │ │ │ ├── parse.go │ │ │ ├── profile.sh │ │ │ ├── stress.bash │ │ │ └── template.go │ ├── Unknwon │ │ └── goconfig │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── README_ZH.md │ │ │ ├── conf.go │ │ │ ├── read.go │ │ │ └── write.go │ ├── agrison │ │ ├── go-tablib │ │ │ ├── HISTORY.md │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── tablib_csv.go │ │ │ ├── tablib_databook.go │ │ │ ├── tablib_dataset.go │ │ │ ├── tablib_errors.go │ │ │ ├── tablib_exportable.go │ │ │ ├── tablib_html.go │ │ │ ├── tablib_json.go │ │ │ ├── tablib_sort.go │ │ │ ├── tablib_sql.go │ │ │ ├── tablib_tabular.go │ │ │ ├── tablib_util.go │ │ │ ├── tablib_xlsx.go │ │ │ ├── tablib_xml.go │ │ │ └── tablib_yaml.go │ │ └── mxj │ │ │ ├── LICENSE │ │ │ ├── anyxml.go │ │ │ ├── atomFeedString.xml │ │ │ ├── doc.go │ │ │ ├── exists.go │ │ │ ├── files.go │ │ │ ├── files_test.badjson │ │ │ ├── files_test.badxml │ │ │ ├── files_test.json │ │ │ ├── files_test.xml │ │ │ ├── files_test_dup.json │ │ │ ├── files_test_dup.xml │ │ │ ├── files_test_indent.json │ │ │ ├── files_test_indent.xml │ │ │ ├── json.go │ │ │ ├── keyvalues.go │ │ │ ├── leafnode.go │ │ │ ├── misc.go │ │ │ ├── mxj.go │ │ │ ├── newmap.go │ │ │ ├── readme.md │ │ │ ├── remove.go │ │ │ ├── rename.go │ │ │ ├── set.go │ │ │ ├── songtext.xml │ │ │ ├── struct.go │ │ │ ├── updatevalues.go │ │ │ ├── xml.go │ │ │ └── xmlseq.go │ ├── bndr │ │ └── gotabulate │ │ │ ├── AUTHOR │ │ │ ├── CHANGELOG │ │ │ ├── CONTRIBUTORS │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── tabulate.go │ │ │ └── utils.go │ ├── fatih │ │ └── structs │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── field.go │ │ │ ├── structs.go │ │ │ └── tags.go │ ├── fsnotify │ │ └── fsnotify │ │ │ ├── AUTHORS │ │ │ ├── CHANGELOG.md │ │ │ ├── CONTRIBUTING.md │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── fen.go │ │ │ ├── fsnotify.go │ │ │ ├── inotify.go │ │ │ ├── inotify_poller.go │ │ │ ├── kqueue.go │ │ │ ├── open_mode_bsd.go │ │ │ ├── open_mode_darwin.go │ │ │ └── windows.go │ ├── mattn │ │ └── go-runewidth │ │ │ ├── LICENSE │ │ │ ├── README.mkd │ │ │ ├── runewidth.go │ │ │ ├── runewidth_js.go │ │ │ ├── runewidth_posix.go │ │ │ └── runewidth_windows.go │ ├── syndtr │ │ └── goleveldb │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── leveldb │ │ │ ├── batch.go │ │ │ ├── batch_test.go │ │ │ ├── bench_test.go │ │ │ ├── cache │ │ │ │ ├── bench_test.go │ │ │ │ ├── cache.go │ │ │ │ ├── cache_test.go │ │ │ │ └── lru.go │ │ │ ├── comparer.go │ │ │ ├── comparer │ │ │ │ ├── bytes_comparer.go │ │ │ │ └── comparer.go │ │ │ ├── corrupt_test.go │ │ │ ├── db.go │ │ │ ├── db_compaction.go │ │ │ ├── db_iter.go │ │ │ ├── db_snapshot.go │ │ │ ├── db_state.go │ │ │ ├── db_test.go │ │ │ ├── db_transaction.go │ │ │ ├── db_util.go │ │ │ ├── db_write.go │ │ │ ├── doc.go │ │ │ ├── errors.go │ │ │ ├── errors │ │ │ │ └── errors.go │ │ │ ├── external_test.go │ │ │ ├── filter.go │ │ │ ├── filter │ │ │ │ ├── bloom.go │ │ │ │ ├── bloom_test.go │ │ │ │ └── filter.go │ │ │ ├── iterator │ │ │ │ ├── array_iter.go │ │ │ │ ├── array_iter_test.go │ │ │ │ ├── indexed_iter.go │ │ │ │ ├── indexed_iter_test.go │ │ │ │ ├── iter.go │ │ │ │ ├── iter_suite_test.go │ │ │ │ ├── merged_iter.go │ │ │ │ └── merged_iter_test.go │ │ │ ├── journal │ │ │ │ ├── journal.go │ │ │ │ └── journal_test.go │ │ │ ├── key.go │ │ │ ├── key_test.go │ │ │ ├── leveldb_suite_test.go │ │ │ ├── memdb │ │ │ │ ├── bench_test.go │ │ │ │ ├── memdb.go │ │ │ │ ├── memdb_suite_test.go │ │ │ │ └── memdb_test.go │ │ │ ├── opt │ │ │ │ └── options.go │ │ │ ├── options.go │ │ │ ├── session.go │ │ │ ├── session_compaction.go │ │ │ ├── session_record.go │ │ │ ├── session_record_test.go │ │ │ ├── session_util.go │ │ │ ├── storage.go │ │ │ ├── storage │ │ │ │ ├── file_storage.go │ │ │ │ ├── file_storage_nacl.go │ │ │ │ ├── file_storage_plan9.go │ │ │ │ ├── file_storage_solaris.go │ │ │ │ ├── file_storage_test.go │ │ │ │ ├── file_storage_unix.go │ │ │ │ ├── file_storage_windows.go │ │ │ │ ├── mem_storage.go │ │ │ │ ├── mem_storage_test.go │ │ │ │ └── storage.go │ │ │ ├── table.go │ │ │ ├── table │ │ │ │ ├── block_test.go │ │ │ │ ├── reader.go │ │ │ │ ├── table.go │ │ │ │ ├── table_suite_test.go │ │ │ │ ├── table_test.go │ │ │ │ └── writer.go │ │ │ ├── table_test.go │ │ │ ├── testutil │ │ │ │ ├── db.go │ │ │ │ ├── ginkgo.go │ │ │ │ ├── iter.go │ │ │ │ ├── kv.go │ │ │ │ ├── kvtest.go │ │ │ │ ├── storage.go │ │ │ │ └── util.go │ │ │ ├── testutil_test.go │ │ │ ├── util.go │ │ │ ├── util │ │ │ │ ├── buffer.go │ │ │ │ ├── buffer_pool.go │ │ │ │ ├── buffer_test.go │ │ │ │ ├── crc32.go │ │ │ │ ├── hash.go │ │ │ │ ├── hash_test.go │ │ │ │ ├── range.go │ │ │ │ └── util.go │ │ │ ├── version.go │ │ │ └── version_test.go │ │ │ └── manualtest │ │ │ ├── dbstress │ │ │ ├── key.go │ │ │ └── main.go │ │ │ └── filelock │ │ │ └── main.go │ └── tealeg │ │ └── xlsx │ │ ├── AUTHORS.txt │ │ ├── CODE_OF_CONDUCT.md │ │ ├── LICENSE │ │ ├── README.org │ │ ├── cell.go │ │ ├── col.go │ │ ├── date.go │ │ ├── doc.go │ │ ├── file.go │ │ ├── format_code.go │ │ ├── hsl.go │ │ ├── lib.go │ │ ├── read.go │ │ ├── reftable.go │ │ ├── row.go │ │ ├── sheet.go │ │ ├── stream_file.go │ │ ├── stream_file_builder.go │ │ ├── style.go │ │ ├── templates.go │ │ ├── theme.go │ │ ├── write.go │ │ ├── xmlContentTypes.go │ │ ├── xmlSharedStrings.go │ │ ├── xmlStyle.go │ │ ├── xmlTheme.go │ │ ├── xmlWorkbook.go │ │ └── xmlWorksheet.go ├── golang.org │ └── x │ │ └── sys │ │ ├── LICENSE │ │ ├── PATENTS │ │ └── unix │ │ ├── asm.s │ │ ├── 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 │ │ ├── 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_linux.pl │ │ ├── mksysnum_netbsd.pl │ │ ├── mksysnum_openbsd.pl │ │ ├── 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_linux.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 ├── gopkg.in │ ├── flosch │ │ └── pongo2.v3 │ │ │ ├── AUTHORS │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── context.go │ │ │ ├── doc.go │ │ │ ├── error.go │ │ │ ├── filters.go │ │ │ ├── filters_builtin.go │ │ │ ├── helpers.go │ │ │ ├── lexer.go │ │ │ ├── nodes.go │ │ │ ├── nodes_html.go │ │ │ ├── nodes_wrapper.go │ │ │ ├── parser.go │ │ │ ├── parser_document.go │ │ │ ├── parser_expression.go │ │ │ ├── pongo2.go │ │ │ ├── tags.go │ │ │ ├── tags_autoescape.go │ │ │ ├── tags_block.go │ │ │ ├── tags_comment.go │ │ │ ├── tags_cycle.go │ │ │ ├── tags_extends.go │ │ │ ├── tags_filter.go │ │ │ ├── tags_firstof.go │ │ │ ├── tags_for.go │ │ │ ├── tags_if.go │ │ │ ├── tags_ifchanged.go │ │ │ ├── tags_ifequal.go │ │ │ ├── tags_ifnotequal.go │ │ │ ├── tags_import.go │ │ │ ├── tags_include.go │ │ │ ├── tags_lorem.go │ │ │ ├── tags_macro.go │ │ │ ├── tags_now.go │ │ │ ├── tags_set.go │ │ │ ├── tags_spaceless.go │ │ │ ├── tags_ssi.go │ │ │ ├── tags_templatetag.go │ │ │ ├── tags_widthratio.go │ │ │ ├── tags_with.go │ │ │ ├── template.go │ │ │ ├── template_sets.go │ │ │ ├── value.go │ │ │ └── variable.go │ └── yaml.v2 │ │ ├── LICENSE │ │ ├── LICENSE.libyaml │ │ ├── README.md │ │ ├── apic.go │ │ ├── decode.go │ │ ├── emitterc.go │ │ ├── encode.go │ │ ├── parserc.go │ │ ├── readerc.go │ │ ├── resolve.go │ │ ├── scannerc.go │ │ ├── sorter.go │ │ ├── writerc.go │ │ ├── yaml.go │ │ ├── yamlh.go │ │ └── yamlprivateh.go └── vendor.json ├── xorm.go └── xormplus.go /.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 | /test.db 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 - 2015 The Xorm Authors 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the {organization} nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (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 | -------------------------------------------------------------------------------- /caches/encode.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Xorm 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 caches 6 | 7 | import ( 8 | "bytes" 9 | "crypto/md5" 10 | "encoding/gob" 11 | "encoding/json" 12 | "fmt" 13 | "io" 14 | ) 15 | 16 | // md5 hash string 17 | func Md5(str string) string { 18 | m := md5.New() 19 | io.WriteString(m, str) 20 | return fmt.Sprintf("%x", m.Sum(nil)) 21 | } 22 | func Encode(data interface{}) ([]byte, error) { 23 | //return JsonEncode(data) 24 | return GobEncode(data) 25 | } 26 | 27 | func Decode(data []byte, to interface{}) error { 28 | //return JsonDecode(data, to) 29 | return GobDecode(data, to) 30 | } 31 | 32 | func GobEncode(data interface{}) ([]byte, error) { 33 | var buf bytes.Buffer 34 | enc := gob.NewEncoder(&buf) 35 | err := enc.Encode(&data) 36 | if err != nil { 37 | return nil, err 38 | } 39 | return buf.Bytes(), nil 40 | } 41 | 42 | func GobDecode(data []byte, to interface{}) error { 43 | buf := bytes.NewBuffer(data) 44 | dec := gob.NewDecoder(buf) 45 | return dec.Decode(to) 46 | } 47 | 48 | func JsonEncode(data interface{}) ([]byte, error) { 49 | val, err := json.Marshal(data) 50 | if err != nil { 51 | return nil, err 52 | } 53 | return val, nil 54 | } 55 | 56 | func JsonDecode(data []byte, to interface{}) error { 57 | return json.Unmarshal(data, to) 58 | } 59 | -------------------------------------------------------------------------------- /caches/leveldb_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Xorm 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 caches 6 | 7 | import ( 8 | "testing" 9 | 10 | "github.com/stretchr/testify/assert" 11 | ) 12 | 13 | func TestLevelDBStore(t *testing.T) { 14 | store, err := NewLevelDBStore("./level.db") 15 | assert.NoError(t, err) 16 | 17 | var kvs = map[string]interface{}{ 18 | "a": "b", 19 | } 20 | for k, v := range kvs { 21 | assert.NoError(t, store.Put(k, v)) 22 | } 23 | 24 | for k, v := range kvs { 25 | val, err := store.Get(k) 26 | assert.NoError(t, err) 27 | assert.EqualValues(t, v, val) 28 | } 29 | 30 | for k := range kvs { 31 | err := store.Del(k) 32 | assert.NoError(t, err) 33 | } 34 | 35 | for k := range kvs { 36 | _, err := store.Get(k) 37 | assert.EqualValues(t, ErrNotExist, err) 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /caches/lru_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm 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 caches 6 | 7 | import ( 8 | "testing" 9 | 10 | "github.com/stretchr/testify/assert" 11 | "github.com/xormplus/xorm/schemas" 12 | ) 13 | 14 | func TestLRUCache(t *testing.T) { 15 | type CacheObject1 struct { 16 | Id int64 17 | } 18 | 19 | store := NewMemoryStore() 20 | cacher := NewLRUCacher(store, 10000) 21 | 22 | tableName := "cache_object1" 23 | pks := []schemas.PK{ 24 | {1}, 25 | {2}, 26 | } 27 | 28 | for _, pk := range pks { 29 | sid, err := pk.ToString() 30 | assert.NoError(t, err) 31 | 32 | cacher.PutIds(tableName, "select * from cache_object1", sid) 33 | ids := cacher.GetIds(tableName, "select * from cache_object1") 34 | assert.EqualValues(t, sid, ids) 35 | 36 | cacher.ClearIds(tableName) 37 | ids2 := cacher.GetIds(tableName, "select * from cache_object1") 38 | assert.Nil(t, ids2) 39 | 40 | obj2 := cacher.GetBean(tableName, sid) 41 | assert.Nil(t, obj2) 42 | 43 | var obj = new(CacheObject1) 44 | cacher.PutBean(tableName, sid, obj) 45 | obj3 := cacher.GetBean(tableName, sid) 46 | assert.EqualValues(t, obj, obj3) 47 | 48 | cacher.DelBean(tableName, sid) 49 | obj4 := cacher.GetBean(tableName, sid) 50 | assert.Nil(t, obj4) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /caches/manager.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Xorm 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 caches 6 | 7 | import "sync" 8 | 9 | type Manager struct { 10 | cacher Cacher 11 | disableGlobalCache bool 12 | 13 | cachers map[string]Cacher 14 | cacherLock sync.RWMutex 15 | } 16 | 17 | func NewManager() *Manager { 18 | return &Manager{ 19 | cachers: make(map[string]Cacher), 20 | } 21 | } 22 | 23 | // SetDisableGlobalCache disable global cache or not 24 | func (mgr *Manager) SetDisableGlobalCache(disable bool) { 25 | if mgr.disableGlobalCache != disable { 26 | mgr.disableGlobalCache = disable 27 | } 28 | } 29 | 30 | func (mgr *Manager) SetCacher(tableName string, cacher Cacher) { 31 | mgr.cacherLock.Lock() 32 | mgr.cachers[tableName] = cacher 33 | mgr.cacherLock.Unlock() 34 | } 35 | 36 | func (mgr *Manager) GetCacher(tableName string) Cacher { 37 | var cacher Cacher 38 | var ok bool 39 | mgr.cacherLock.RLock() 40 | cacher, ok = mgr.cachers[tableName] 41 | mgr.cacherLock.RUnlock() 42 | if !ok && !mgr.disableGlobalCache { 43 | cacher = mgr.cacher 44 | } 45 | return cacher 46 | } 47 | 48 | // SetDefaultCacher set the default cacher. Xorm's default not enable cacher. 49 | func (mgr *Manager) SetDefaultCacher(cacher Cacher) { 50 | mgr.cacher = cacher 51 | } 52 | 53 | // GetDefaultCacher returns the default cacher 54 | func (mgr *Manager) GetDefaultCacher() Cacher { 55 | return mgr.cacher 56 | } 57 | -------------------------------------------------------------------------------- /caches/memory_store.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm 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 caches 6 | 7 | import ( 8 | "sync" 9 | ) 10 | 11 | var _ CacheStore = NewMemoryStore() 12 | 13 | // MemoryStore represents in-memory store 14 | type MemoryStore struct { 15 | store map[interface{}]interface{} 16 | mutex sync.RWMutex 17 | } 18 | 19 | // NewMemoryStore creates a new store in memory 20 | func NewMemoryStore() *MemoryStore { 21 | return &MemoryStore{store: make(map[interface{}]interface{})} 22 | } 23 | 24 | // Put puts object into store 25 | func (s *MemoryStore) Put(key string, value interface{}) error { 26 | s.mutex.Lock() 27 | defer s.mutex.Unlock() 28 | s.store[key] = value 29 | return nil 30 | } 31 | 32 | // Get gets object from store 33 | func (s *MemoryStore) Get(key string) (interface{}, error) { 34 | s.mutex.RLock() 35 | defer s.mutex.RUnlock() 36 | if v, ok := s.store[key]; ok { 37 | return v, nil 38 | } 39 | 40 | return nil, ErrNotExist 41 | } 42 | 43 | // Del deletes object 44 | func (s *MemoryStore) Del(key string) error { 45 | s.mutex.Lock() 46 | defer s.mutex.Unlock() 47 | delete(s.store, key) 48 | return nil 49 | } 50 | -------------------------------------------------------------------------------- /caches/memory_store_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm 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 caches 6 | 7 | import ( 8 | "testing" 9 | 10 | "github.com/stretchr/testify/assert" 11 | ) 12 | 13 | func TestMemoryStore(t *testing.T) { 14 | store := NewMemoryStore() 15 | var kvs = map[string]interface{}{ 16 | "a": "b", 17 | } 18 | for k, v := range kvs { 19 | assert.NoError(t, store.Put(k, v)) 20 | } 21 | 22 | for k, v := range kvs { 23 | val, err := store.Get(k) 24 | assert.NoError(t, err) 25 | assert.EqualValues(t, v, val) 26 | } 27 | 28 | for k := range kvs { 29 | err := store.Del(k) 30 | assert.NoError(t, err) 31 | } 32 | 33 | for k := range kvs { 34 | _, err := store.Get(k) 35 | assert.EqualValues(t, ErrNotExist, err) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /cipher.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm 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 xorm 6 | 7 | type Cipher interface { 8 | Encrypt(strMsg string) ([]byte, error) 9 | Decrypt(src []byte) (decrypted []byte, err error) 10 | } 11 | -------------------------------------------------------------------------------- /context_cache.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Xorm 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 | package xorm 5 | 6 | // ContextCache is the interface that operates the cache data. 7 | type ContextCache interface { 8 | // Put puts value into cache with key. 9 | Put(key string, val interface{}) 10 | // Get gets cached value by given key. 11 | Get(key string) interface{} 12 | } 13 | type memoryContextCache map[string]interface{} 14 | 15 | // NewMemoryContextCache return memoryContextCache 16 | func NewMemoryContextCache() memoryContextCache { 17 | return make(map[string]interface{}) 18 | } 19 | 20 | // Put puts value into cache with key. 21 | func (m memoryContextCache) Put(key string, val interface{}) { 22 | m[key] = val 23 | } 24 | 25 | // Get gets cached value by given key. 26 | func (m memoryContextCache) Get(key string) interface{} { 27 | return m[key] 28 | } 29 | -------------------------------------------------------------------------------- /contexts/context_cache.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Xorm 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 contexts 6 | 7 | // ContextCache is the interface that operates the cache data. 8 | type ContextCache interface { 9 | // Put puts value into cache with key. 10 | Put(key string, val interface{}) 11 | // Get gets cached value by given key. 12 | Get(key string) interface{} 13 | } 14 | 15 | type memoryContextCache map[string]interface{} 16 | 17 | // NewMemoryContextCache return memoryContextCache 18 | func NewMemoryContextCache() memoryContextCache { 19 | return make(map[string]interface{}) 20 | } 21 | 22 | // Put puts value into cache with key. 23 | func (m memoryContextCache) Put(key string, val interface{}) { 24 | m[key] = val 25 | } 26 | 27 | // Get gets cached value by given key. 28 | func (m memoryContextCache) Get(key string) interface{} { 29 | return m[key] 30 | } 31 | -------------------------------------------------------------------------------- /convert/conversion.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Xorm 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 convert 6 | 7 | // Conversion is an interface. A type implements Conversion will according 8 | // the custom method to fill into database and retrieve from database. 9 | type Conversion interface { 10 | FromDB([]byte) error 11 | ToDB() ([]byte, error) 12 | } 13 | -------------------------------------------------------------------------------- /core/error.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Xorm 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 core 6 | 7 | import "errors" 8 | 9 | var ( 10 | // ErrNoMapPointer represents error when no map pointer 11 | ErrNoMapPointer = errors.New("mp should be a map's pointer") 12 | // ErrNoStructPointer represents error when no struct pointer 13 | ErrNoStructPointer = errors.New("mp should be a struct's pointer") 14 | ) 15 | -------------------------------------------------------------------------------- /core/interface.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "context" 5 | "database/sql" 6 | ) 7 | 8 | // Queryer represents an interface to query a SQL to get data from database 9 | type Queryer interface { 10 | QueryContext(ctx context.Context, query string, args ...interface{}) (*Rows, error) 11 | } 12 | 13 | // Executer represents an interface to execute a SQL 14 | type Executer interface { 15 | ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) 16 | } 17 | 18 | // QueryExecuter combines the Queryer and Executer 19 | type QueryExecuter interface { 20 | Queryer 21 | Executer 22 | } 23 | -------------------------------------------------------------------------------- /core/scan.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Xorm 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 core 6 | 7 | import ( 8 | "database/sql/driver" 9 | "fmt" 10 | "time" 11 | ) 12 | 13 | type NullTime time.Time 14 | 15 | var ( 16 | _ driver.Valuer = NullTime{} 17 | ) 18 | 19 | func (ns *NullTime) Scan(value interface{}) error { 20 | if value == nil { 21 | return nil 22 | } 23 | return convertTime(ns, value) 24 | } 25 | 26 | // Value implements the driver Valuer interface. 27 | func (ns NullTime) Value() (driver.Value, error) { 28 | if (time.Time)(ns).IsZero() { 29 | return nil, nil 30 | } 31 | return (time.Time)(ns).Format("2006-01-02 15:04:05"), nil 32 | } 33 | 34 | func convertTime(dest *NullTime, src interface{}) error { 35 | // Common cases, without reflect. 36 | switch s := src.(type) { 37 | case string: 38 | t, err := time.Parse("2006-01-02 15:04:05", s) 39 | if err != nil { 40 | return err 41 | } 42 | *dest = NullTime(t) 43 | return nil 44 | case []uint8: 45 | t, err := time.Parse("2006-01-02 15:04:05", string(s)) 46 | if err != nil { 47 | return err 48 | } 49 | *dest = NullTime(t) 50 | return nil 51 | case time.Time: 52 | *dest = NullTime(s) 53 | return nil 54 | case nil: 55 | default: 56 | return fmt.Errorf("unsupported driver -> Scan pair: %T -> %T", src, dest) 57 | } 58 | return nil 59 | } 60 | 61 | type EmptyScanner struct { 62 | } 63 | 64 | func (EmptyScanner) Scan(src interface{}) error { 65 | return nil 66 | } 67 | -------------------------------------------------------------------------------- /dataset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm 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 xorm 6 | 7 | import ( 8 | tablib "github.com/agrison/go-tablib" 9 | ) 10 | 11 | // NewDataset creates a new Dataset. 12 | func NewDataset(headers []string) *tablib.Dataset { 13 | return tablib.NewDataset(headers) 14 | } 15 | 16 | // NewDatasetWithData creates a new Dataset. 17 | func NewDatasetWithData(headers []string, data interface{}, mustMatch bool) (*tablib.Dataset, error) { 18 | if data == nil { 19 | return tablib.NewDatasetWithData(headers, nil), nil 20 | } 21 | n := len(headers) 22 | 23 | switch data.(type) { 24 | case [][]interface{}: 25 | return tablib.NewDatasetWithData(headers, data.([][]interface{})), nil 26 | case []map[string]interface{}: 27 | dataSlice := data.([]map[string]interface{}) 28 | if len(dataSlice) > 0 { 29 | if len(dataSlice[0]) == 0 { 30 | return tablib.NewDatasetWithData(headers, make([][]interface{}, len(dataSlice))), nil 31 | } else { 32 | if n != len(dataSlice[0]) && mustMatch { 33 | return nil, ErrParamsType 34 | } 35 | mapHeaders := make(map[string]int, n) 36 | for i := 0; i < n; i++ { 37 | mapHeaders[headers[i]] = i 38 | } 39 | 40 | for k, _ := range dataSlice[0] { 41 | if _, ok := mapHeaders[k]; !ok { 42 | return nil, ErrParamsType 43 | } 44 | } 45 | 46 | d := tablib.NewDataset(headers) 47 | var row []interface{} 48 | for i, _ := range dataSlice { 49 | row = nil 50 | for j := 0; j < n; j++ { 51 | row = append(row, dataSlice[i][headers[j]]) 52 | } 53 | d.Append(row) 54 | } 55 | return d, nil 56 | 57 | } 58 | 59 | } else { 60 | return tablib.NewDatasetWithData(headers, nil), nil 61 | } 62 | default: 63 | return nil, ErrParamsType 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /dialects/driver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Xorm 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 dialects 6 | 7 | import ( 8 | "fmt" 9 | ) 10 | 11 | type Driver interface { 12 | Parse(string, string) (*URI, error) 13 | } 14 | 15 | var ( 16 | drivers = map[string]Driver{} 17 | ) 18 | 19 | func RegisterDriver(driverName string, driver Driver) { 20 | if driver == nil { 21 | panic("core: Register driver is nil") 22 | } 23 | if _, dup := drivers[driverName]; dup { 24 | panic("core: Register called twice for driver " + driverName) 25 | } 26 | drivers[driverName] = driver 27 | } 28 | 29 | func QueryDriver(driverName string) Driver { 30 | return drivers[driverName] 31 | } 32 | 33 | func RegisteredDriverSize() int { 34 | return len(drivers) 35 | } 36 | 37 | // OpenDialect opens a dialect via driver name and connection string 38 | func OpenDialect(driverName, connstr string) (Dialect, error) { 39 | driver := QueryDriver(driverName) 40 | if driver == nil { 41 | return nil, fmt.Errorf("Unsupported driver name: %v", driverName) 42 | } 43 | 44 | uri, err := driver.Parse(driverName, connstr) 45 | if err != nil { 46 | return nil, err 47 | } 48 | 49 | dialect := QueryDialect(uri.DBType) 50 | if dialect == nil { 51 | return nil, fmt.Errorf("Unsupported dialect type: %v", uri.DBType) 52 | } 53 | 54 | dialect.Init(uri) 55 | 56 | return dialect, nil 57 | } 58 | -------------------------------------------------------------------------------- /dialects/filter.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Xorm 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 dialects 6 | 7 | import ( 8 | "fmt" 9 | "strings" 10 | ) 11 | 12 | // Filter is an interface to filter SQL 13 | type Filter interface { 14 | Do(sql string) string 15 | } 16 | 17 | // SeqFilter filter SQL replace ?, ? ... to $1, $2 ... 18 | type SeqFilter struct { 19 | Prefix string 20 | Start int 21 | } 22 | 23 | func convertQuestionMark(sql, prefix string, start int) string { 24 | var buf strings.Builder 25 | var beginSingleQuote bool 26 | var index = start 27 | for _, c := range sql { 28 | if !beginSingleQuote && c == '?' { 29 | buf.WriteString(fmt.Sprintf("%s%v", prefix, index)) 30 | index++ 31 | } else { 32 | if c == '\'' { 33 | beginSingleQuote = !beginSingleQuote 34 | } 35 | buf.WriteRune(c) 36 | } 37 | } 38 | return buf.String() 39 | } 40 | 41 | func (s *SeqFilter) Do(sql string) string { 42 | return convertQuestionMark(sql, s.Prefix, s.Start) 43 | } 44 | -------------------------------------------------------------------------------- /dialects/filter_test.go: -------------------------------------------------------------------------------- 1 | package dialects 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/stretchr/testify/assert" 7 | ) 8 | 9 | func TestSeqFilter(t *testing.T) { 10 | var kases = map[string]string{ 11 | "SELECT * FROM TABLE1 WHERE a=? AND b=?": "SELECT * FROM TABLE1 WHERE a=$1 AND b=$2", 12 | "SELECT 1, '???', '2006-01-02 15:04:05' FROM TABLE1 WHERE a=? AND b=?": "SELECT 1, '???', '2006-01-02 15:04:05' FROM TABLE1 WHERE a=$1 AND b=$2", 13 | "select '1''?' from issue": "select '1''?' from issue", 14 | "select '1\\??' from issue": "select '1\\??' from issue", 15 | "select '1\\\\',? from issue": "select '1\\\\',$1 from issue", 16 | "select '1\\''?',? from issue": "select '1\\''?',$1 from issue", 17 | } 18 | for sql, result := range kases { 19 | assert.EqualValues(t, result, convertQuestionMark(sql, "$", 1)) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /dialects/gen_reserved.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -f $1 ];then 3 | cat $1| awk '{printf("\""$1"\":true,\n")}' 4 | else 5 | echo "argument $1 if not a file!" 6 | fi 7 | -------------------------------------------------------------------------------- /dialects/mssql_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Xorm 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 dialects 6 | 7 | import ( 8 | "reflect" 9 | "testing" 10 | ) 11 | 12 | func TestParseMSSQL(t *testing.T) { 13 | tests := []struct { 14 | in string 15 | expected string 16 | valid bool 17 | }{ 18 | {"sqlserver://sa:yourStrong(!)Password@localhost:1433?database=db&connection+timeout=30", "db", true}, 19 | {"server=localhost;user id=sa;password=yourStrong(!)Password;database=db", "db", true}, 20 | } 21 | 22 | driver := QueryDriver("mssql") 23 | 24 | for _, test := range tests { 25 | uri, err := driver.Parse("mssql", test.in) 26 | 27 | if err != nil && test.valid { 28 | t.Errorf("%q got unexpected error: %s", test.in, err) 29 | } else if err == nil && !reflect.DeepEqual(test.expected, uri.DBName) { 30 | t.Errorf("%q got: %#v want: %#v", test.in, uri.DBName, test.expected) 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /dialects/oracle_test.go: -------------------------------------------------------------------------------- 1 | package dialects 2 | 3 | import ( 4 | "reflect" 5 | "testing" 6 | ) 7 | 8 | func TestParseOracleConnStr(t *testing.T) { 9 | tests := []struct { 10 | in string 11 | expected string 12 | valid bool 13 | }{ 14 | {"user/pass@tcp(server:1521)/db", "db", true}, 15 | {"user/pass@server:1521/db", "db", true}, 16 | // test for net service name : https://docs.oracle.com/cd/B13789_01/network.101/b10775/glossary.htm#i998113 17 | {"user/pass@server:1521", "", true}, 18 | {"user/pass@", "", false}, 19 | {"user/pass", "", false}, 20 | {"", "", false}, 21 | } 22 | driver := QueryDriver("oci8") 23 | for _, test := range tests { 24 | t.Run(test.in, func(t *testing.T) { 25 | driver := driver 26 | uri, err := driver.Parse("oci8", test.in) 27 | if err != nil && test.valid { 28 | t.Errorf("%q got unexpected error: %s", test.in, err) 29 | } else if err == nil && !reflect.DeepEqual(test.expected, uri.DBName) { 30 | t.Errorf("%q got: %#v want: %#v", test.in, uri.DBName, test.expected) 31 | } 32 | }) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /dialects/quote.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Xorm 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 dialects 6 | 7 | // QuotePolicy describes quote handle policy 8 | type QuotePolicy int 9 | 10 | // All QuotePolicies 11 | const ( 12 | QuotePolicyAlways QuotePolicy = iota 13 | QuotePolicyNone 14 | QuotePolicyReserved 15 | ) 16 | -------------------------------------------------------------------------------- /dialects/sqlite3_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Xorm 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 dialects 6 | 7 | import ( 8 | "testing" 9 | 10 | "github.com/stretchr/testify/assert" 11 | ) 12 | 13 | func TestSplitColStr(t *testing.T) { 14 | var kases = []struct { 15 | colStr string 16 | fields []string 17 | }{ 18 | { 19 | colStr: "`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL", 20 | fields: []string{ 21 | "`id`", "INTEGER", "PRIMARY", "KEY", "AUTOINCREMENT", "NOT", "NULL", 22 | }, 23 | }, 24 | { 25 | colStr: "`created` DATETIME DEFAULT '2006-01-02 15:04:05' NULL", 26 | fields: []string{ 27 | "`created`", "DATETIME", "DEFAULT", "'2006-01-02 15:04:05'", "NULL", 28 | }, 29 | }, 30 | } 31 | 32 | for _, kase := range kases { 33 | assert.EqualValues(t, kase.fields, splitColStr(kase.colStr)) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /dialects/table_name_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Xorm 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 dialects 6 | 7 | import ( 8 | "testing" 9 | 10 | "github.com/xormplus/xorm/names" 11 | 12 | "github.com/stretchr/testify/assert" 13 | ) 14 | 15 | type MCC struct { 16 | ID int64 `xorm:"pk 'id'"` 17 | Code string `xorm:"'code'"` 18 | Description string `xorm:"'description'"` 19 | } 20 | 21 | func (mcc *MCC) TableName() string { 22 | return "mcc" 23 | } 24 | 25 | func TestFullTableName(t *testing.T) { 26 | dialect := QueryDialect("mysql") 27 | 28 | assert.EqualValues(t, "mcc", FullTableName(dialect, names.SnakeMapper{}, &MCC{})) 29 | assert.EqualValues(t, "mcc", FullTableName(dialect, names.SnakeMapper{}, "mcc")) 30 | } 31 | -------------------------------------------------------------------------------- /dialects/time.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm 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 dialects 6 | 7 | import ( 8 | "time" 9 | 10 | "github.com/xormplus/xorm/schemas" 11 | ) 12 | 13 | // FormatTime format time as column type 14 | func FormatTime(dialect Dialect, sqlTypeName string, t time.Time) (v interface{}) { 15 | // go-oci8 can handler time.Time. you can view the code in go-oci8/statement.go:bindValues() 16 | if dialect.URI().DBType == schemas.ORACLE { 17 | v = t 18 | 19 | return 20 | } 21 | 22 | switch sqlTypeName { 23 | case schemas.Time: 24 | s := t.Format("2006-01-02 15:04:05") // time.RFC3339 25 | v = s[11:19] 26 | case schemas.Date: 27 | v = t.Format("2006-01-02") 28 | case schemas.DateTime, schemas.TimeStamp, schemas.Varchar: // !DarthPestilane! format time when sqlTypeName is schemas.Varchar. 29 | v = t.Format("2006-01-02 15:04:05") 30 | case schemas.TimeStampz: 31 | if dialect.URI().DBType == schemas.MSSQL { 32 | v = t.Format("2006-01-02T15:04:05.9999999Z07:00") 33 | } else { 34 | v = t.Format(time.RFC3339Nano) 35 | } 36 | case schemas.BigInt, schemas.Int: 37 | v = t.Unix() 38 | default: 39 | v = t 40 | } 41 | return 42 | } 43 | 44 | func FormatColumnTime(dialect Dialect, defaultTimeZone *time.Location, col *schemas.Column, t time.Time) (v interface{}) { 45 | if t.IsZero() { 46 | if col.Nullable { 47 | return nil 48 | } 49 | return "" 50 | } 51 | 52 | if col.TimeZone != nil { 53 | return FormatTime(dialect, col.SQLType.Name, t.In(col.TimeZone)) 54 | } 55 | return FormatTime(dialect, col.SQLType.Name, t.In(defaultTimeZone)) 56 | } 57 | -------------------------------------------------------------------------------- /fswatcher.go: -------------------------------------------------------------------------------- 1 | package xorm 2 | 3 | import ( 4 | "strings" 5 | 6 | "github.com/fsnotify/fsnotify" 7 | ) 8 | 9 | //start filesystem watcher 10 | func (engine *Engine) StartFSWatcher() error { 11 | var err error 12 | engine.watcher, err = fsnotify.NewWatcher() 13 | if err != nil { 14 | return err 15 | } 16 | 17 | go func() { 18 | 19 | for { 20 | 21 | select { 22 | case event := <-engine.watcher.Events: 23 | if event.Op&fsnotify.Write == fsnotify.Write { 24 | if strings.HasSuffix(event.Name, engine.SqlTemplate.Extension()) { 25 | err = engine.ReloadSqlTemplate(event.Name) 26 | if err != nil { 27 | engine.logger.Errorf("%v", err) 28 | } 29 | } 30 | 31 | if strings.HasSuffix(event.Name, engine.SqlMap.Extension["xml"]) || strings.HasSuffix(event.Name, engine.SqlMap.Extension["json"]) || strings.HasSuffix(event.Name, engine.SqlMap.Extension["xsql"]) { 32 | err = engine.reloadSqlMap(event.Name) 33 | if err != nil { 34 | engine.logger.Errorf("%v", err) 35 | } 36 | } 37 | } 38 | 39 | case err := <-engine.watcher.Errors: 40 | if err != nil { 41 | engine.logger.Errorf("%v", err) 42 | } 43 | } 44 | } 45 | }() 46 | 47 | if engine.SqlMap.SqlMapRootDir != "" { 48 | err = engine.watcher.Add(engine.SqlMap.SqlMapRootDir) 49 | if err != nil { 50 | return err 51 | } 52 | } 53 | 54 | if engine.SqlTemplate.RootDir() != "" { 55 | err = engine.watcher.Add(engine.SqlTemplate.RootDir()) 56 | if err != nil { 57 | return err 58 | } 59 | } 60 | 61 | return nil 62 | } 63 | 64 | //stop filesystem watcher 65 | func (engine *Engine) StopFSWatcher() error { 66 | return engine.watcher.Close() 67 | } 68 | -------------------------------------------------------------------------------- /integrations/engine_group_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Xorm 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 integrations 6 | 7 | import ( 8 | "testing" 9 | 10 | "github.com/xormplus/xorm" 11 | "github.com/xormplus/xorm/log" 12 | "github.com/xormplus/xorm/schemas" 13 | 14 | "github.com/stretchr/testify/assert" 15 | ) 16 | 17 | func TestEngineGroup(t *testing.T) { 18 | assert.NoError(t, PrepareEngine()) 19 | 20 | main := testEngine.(*xorm.Engine) 21 | if main.Dialect().URI().DBType == schemas.SQLITE { 22 | t.Skip() 23 | return 24 | } 25 | 26 | eg, err := xorm.NewEngineGroup(main, []*xorm.Engine{main}) 27 | assert.NoError(t, err) 28 | 29 | eg.SetMaxIdleConns(10) 30 | eg.SetMaxOpenConns(100) 31 | eg.SetTableMapper(main.GetTableMapper()) 32 | eg.SetColumnMapper(main.GetColumnMapper()) 33 | eg.SetLogLevel(log.LOG_INFO) 34 | eg.ShowSQL(true) 35 | } 36 | -------------------------------------------------------------------------------- /integrations/main_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Xorm 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 integrations 6 | 7 | import ( 8 | "testing" 9 | ) 10 | 11 | func TestMain(m *testing.M) { 12 | MainTest(m) 13 | } 14 | -------------------------------------------------------------------------------- /integrations/session_raw_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Xorm 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 integrations 6 | 7 | import ( 8 | "strconv" 9 | "testing" 10 | 11 | "github.com/stretchr/testify/assert" 12 | ) 13 | 14 | func TestExecAndQuery(t *testing.T) { 15 | assert.NoError(t, PrepareEngine()) 16 | 17 | type UserinfoQuery struct { 18 | Uid int 19 | Name string 20 | } 21 | 22 | assert.NoError(t, testEngine.Sync2(new(UserinfoQuery))) 23 | 24 | res, err := testEngine.Exec("INSERT INTO "+testEngine.TableName("`userinfo_query`", true)+" (uid, name) VALUES (?, ?)", 1, "user") 25 | assert.NoError(t, err) 26 | cnt, err := res.RowsAffected() 27 | assert.NoError(t, err) 28 | assert.EqualValues(t, 1, cnt) 29 | 30 | results, err := testEngine.Query("select * from " + testEngine.TableName("userinfo_query", true)) 31 | assert.NoError(t, err) 32 | assert.EqualValues(t, 1, len(results)) 33 | id, err := strconv.Atoi(string(results[0]["uid"])) 34 | assert.NoError(t, err) 35 | assert.EqualValues(t, 1, id) 36 | assert.Equal(t, "user", string(results[0]["name"])) 37 | } 38 | -------------------------------------------------------------------------------- /integrations/session_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Xorm 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 integrations 6 | 7 | import ( 8 | "database/sql" 9 | "testing" 10 | 11 | "github.com/stretchr/testify/assert" 12 | ) 13 | 14 | func TestClose(t *testing.T) { 15 | assert.NoError(t, PrepareEngine()) 16 | 17 | sess1 := testEngine.NewSession() 18 | sess1.Close() 19 | assert.True(t, sess1.IsClosed()) 20 | 21 | sess2 := testEngine.Where("a = ?", 1) 22 | sess2.Close() 23 | assert.True(t, sess2.IsClosed()) 24 | } 25 | 26 | func TestNullFloatStruct(t *testing.T) { 27 | type MyNullFloat64 sql.NullFloat64 28 | 29 | type MyNullFloatStruct struct { 30 | Uuid string 31 | Amount MyNullFloat64 32 | } 33 | 34 | assert.NoError(t, PrepareEngine()) 35 | assert.NoError(t, testEngine.Sync2(new(MyNullFloatStruct))) 36 | 37 | _, err := testEngine.Insert(&MyNullFloatStruct{ 38 | Uuid: "111111", 39 | Amount: MyNullFloat64(sql.NullFloat64{ 40 | Float64: 0.1111, 41 | Valid: true, 42 | }), 43 | }) 44 | assert.NoError(t, err) 45 | } 46 | 47 | func TestMustLogSQL(t *testing.T) { 48 | assert.NoError(t, PrepareEngine()) 49 | testEngine.ShowSQL(false) 50 | defer testEngine.ShowSQL(true) 51 | 52 | assertSync(t, new(Userinfo)) 53 | 54 | _, err := testEngine.Table("userinfo").MustLogSQL(true).Get(new(Userinfo)) 55 | assert.NoError(t, err) 56 | } 57 | 58 | func TestEnableSessionId(t *testing.T) { 59 | assert.NoError(t, PrepareEngine()) 60 | testEngine.EnableSessionID(true) 61 | assertSync(t, new(Userinfo)) 62 | _, err := testEngine.Table("userinfo").MustLogSQL(true).Get(new(Userinfo)) 63 | assert.NoError(t, err) 64 | } 65 | -------------------------------------------------------------------------------- /internal/json/json.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Xorm 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 json 6 | 7 | import "encoding/json" 8 | 9 | // JSONInterface represents an interface to handle json data 10 | type JSONInterface interface { 11 | Marshal(v interface{}) ([]byte, error) 12 | Unmarshal(data []byte, v interface{}) error 13 | } 14 | 15 | var ( 16 | // DefaultJSONHandler default json handler 17 | DefaultJSONHandler JSONInterface = StdJSON{} 18 | ) 19 | 20 | // StdJSON implements JSONInterface via encoding/json 21 | type StdJSON struct{} 22 | 23 | // Marshal implements JSONInterface 24 | func (StdJSON) Marshal(v interface{}) ([]byte, error) { 25 | return json.Marshal(v) 26 | } 27 | 28 | // Unmarshal implements JSONInterface 29 | func (StdJSON) Unmarshal(data []byte, v interface{}) error { 30 | return json.Unmarshal(data, v) 31 | } 32 | -------------------------------------------------------------------------------- /internal/statements/column_map.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Xorm 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 statements 6 | 7 | import ( 8 | "strings" 9 | 10 | "github.com/xormplus/xorm/schemas" 11 | ) 12 | 13 | type columnMap []string 14 | 15 | func (m columnMap) Contain(colName string) bool { 16 | if len(m) == 0 { 17 | return false 18 | } 19 | 20 | n := len(colName) 21 | for _, mk := range m { 22 | if len(mk) != n { 23 | continue 24 | } 25 | if strings.EqualFold(mk, colName) { 26 | return true 27 | } 28 | } 29 | 30 | return false 31 | } 32 | 33 | func (m columnMap) Len() int { 34 | return len(m) 35 | } 36 | 37 | func (m columnMap) IsEmpty() bool { 38 | return len(m) == 0 39 | } 40 | 41 | func (m *columnMap) Add(colName string) bool { 42 | if m.Contain(colName) { 43 | return false 44 | } 45 | *m = append(*m, colName) 46 | return true 47 | } 48 | 49 | func getFlagForColumn(m map[string]bool, col *schemas.Column) (val bool, has bool) { 50 | if len(m) == 0 { 51 | return false, false 52 | } 53 | 54 | n := len(col.Name) 55 | 56 | for mk := range m { 57 | if len(mk) != n { 58 | continue 59 | } 60 | if strings.EqualFold(mk, col.Name) { 61 | return m[mk], true 62 | } 63 | } 64 | 65 | return false, false 66 | } 67 | -------------------------------------------------------------------------------- /internal/utils/name.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Xorm 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 utils 6 | 7 | import ( 8 | "fmt" 9 | ) 10 | 11 | func IndexName(tableName, idxName string) string { 12 | return fmt.Sprintf("IDX_%v_%v", tableName, idxName) 13 | } 14 | -------------------------------------------------------------------------------- /internal/utils/reflect.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Xorm 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 utils 6 | 7 | import ( 8 | "reflect" 9 | ) 10 | 11 | func ReflectValue(bean interface{}) reflect.Value { 12 | return reflect.Indirect(reflect.ValueOf(bean)) 13 | } 14 | -------------------------------------------------------------------------------- /internal/utils/slice.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Xorm 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 utils 6 | 7 | import "sort" 8 | 9 | // SliceEq return true if two slice have the same elements even if different sort. 10 | func SliceEq(left, right []string) bool { 11 | if len(left) != len(right) { 12 | return false 13 | } 14 | sort.Sort(sort.StringSlice(left)) 15 | sort.Sort(sort.StringSlice(right)) 16 | for i := 0; i < len(left); i++ { 17 | if left[i] != right[i] { 18 | return false 19 | } 20 | } 21 | return true 22 | } 23 | -------------------------------------------------------------------------------- /internal/utils/sql.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Xorm 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 utils 6 | 7 | import ( 8 | "strings" 9 | ) 10 | 11 | func IsSubQuery(tbName string) bool { 12 | const selStr = "select" 13 | if len(tbName) <= len(selStr)+1 { 14 | return false 15 | } 16 | 17 | return strings.EqualFold(tbName[:len(selStr)], selStr) || 18 | strings.EqualFold(tbName[:len(selStr)+1], "("+selStr) 19 | } 20 | -------------------------------------------------------------------------------- /internal/utils/strings.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Xorm 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 utils 6 | 7 | import ( 8 | "strings" 9 | ) 10 | 11 | func IndexNoCase(s, sep string) int { 12 | return strings.Index(strings.ToLower(s), strings.ToLower(sep)) 13 | } 14 | 15 | func SplitNoCase(s, sep string) []string { 16 | idx := IndexNoCase(s, sep) 17 | if idx < 0 { 18 | return []string{s} 19 | } 20 | return strings.Split(s, s[idx:idx+len(sep)]) 21 | } 22 | 23 | func SplitNNoCase(s, sep string, n int) []string { 24 | idx := IndexNoCase(s, sep) 25 | if idx < 0 { 26 | return []string{s} 27 | } 28 | return strings.SplitN(s, s[idx:idx+len(sep)], n) 29 | } 30 | 31 | -------------------------------------------------------------------------------- /internal/utils/zero_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Xorm 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 utils 6 | 7 | import ( 8 | "fmt" 9 | "reflect" 10 | "testing" 11 | "time" 12 | 13 | "github.com/stretchr/testify/assert" 14 | ) 15 | 16 | type MyInt int 17 | type ZeroStruct struct{} 18 | 19 | func TestZero(t *testing.T) { 20 | var zeroValues = []interface{}{ 21 | int8(0), 22 | int16(0), 23 | int(0), 24 | int32(0), 25 | int64(0), 26 | uint8(0), 27 | uint16(0), 28 | uint(0), 29 | uint32(0), 30 | uint64(0), 31 | MyInt(0), 32 | reflect.ValueOf(0), 33 | nil, 34 | time.Time{}, 35 | &time.Time{}, 36 | nilTime, 37 | ZeroStruct{}, 38 | &ZeroStruct{}, 39 | } 40 | 41 | for _, v := range zeroValues { 42 | t.Run(fmt.Sprintf("%#v", v), func(t *testing.T) { 43 | assert.True(t, IsZero(v)) 44 | }) 45 | } 46 | } 47 | 48 | func TestIsValueZero(t *testing.T) { 49 | var zeroReflectValues = []reflect.Value{ 50 | reflect.ValueOf(int8(0)), 51 | reflect.ValueOf(int16(0)), 52 | reflect.ValueOf(int(0)), 53 | reflect.ValueOf(int32(0)), 54 | reflect.ValueOf(int64(0)), 55 | reflect.ValueOf(uint8(0)), 56 | reflect.ValueOf(uint16(0)), 57 | reflect.ValueOf(uint(0)), 58 | reflect.ValueOf(uint32(0)), 59 | reflect.ValueOf(uint64(0)), 60 | reflect.ValueOf(MyInt(0)), 61 | reflect.ValueOf(time.Time{}), 62 | reflect.ValueOf(&time.Time{}), 63 | reflect.ValueOf(nilTime), 64 | reflect.ValueOf(ZeroStruct{}), 65 | reflect.ValueOf(&ZeroStruct{}), 66 | } 67 | 68 | for _, v := range zeroReflectValues { 69 | t.Run(fmt.Sprintf("%#v", v), func(t *testing.T) { 70 | assert.True(t, IsValueZero(v)) 71 | }) 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /json.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Xorm 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 xorm 6 | 7 | import "encoding/json" 8 | 9 | // JSONInterface represents an interface to handle json data 10 | type JSONInterface interface { 11 | Marshal(v interface{}) ([]byte, error) 12 | Unmarshal(data []byte, v interface{}) error 13 | } 14 | 15 | var ( 16 | // DefaultJSONHandler default json handler 17 | DefaultJSONHandler JSONInterface = StdJSON{} 18 | ) 19 | 20 | // StdJSON implements JSONInterface via encoding/json 21 | type StdJSON struct{} 22 | 23 | // Marshal implements JSONInterface 24 | func (StdJSON) Marshal(v interface{}) ([]byte, error) { 25 | return json.Marshal(v) 26 | } 27 | 28 | // Unmarshal implements JSONInterface 29 | func (StdJSON) Unmarshal(data []byte, v interface{}) error { 30 | return json.Unmarshal(data, v) 31 | } 32 | -------------------------------------------------------------------------------- /names/table_name.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Xorm 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 names 6 | 7 | import ( 8 | "reflect" 9 | "sync" 10 | ) 11 | 12 | // TableName table name interface to define customerize table name 13 | type TableName interface { 14 | TableName() string 15 | } 16 | 17 | var ( 18 | tpTableName = reflect.TypeOf((*TableName)(nil)).Elem() 19 | tvCache sync.Map 20 | ) 21 | 22 | func GetTableName(mapper Mapper, v reflect.Value) string { 23 | if v.Type().Implements(tpTableName) { 24 | return v.Interface().(TableName).TableName() 25 | } 26 | 27 | if v.Kind() == reflect.Ptr { 28 | v = v.Elem() 29 | if v.Type().Implements(tpTableName) { 30 | return v.Interface().(TableName).TableName() 31 | } 32 | } else if v.CanAddr() { 33 | v1 := v.Addr() 34 | if v1.Type().Implements(tpTableName) { 35 | return v1.Interface().(TableName).TableName() 36 | } 37 | } else { 38 | name, ok := tvCache.Load(v.Type()) 39 | if ok { 40 | if name.(string) != "" { 41 | return name.(string) 42 | } 43 | } else { 44 | v2 := reflect.New(v.Type()) 45 | if v2.Type().Implements(tpTableName) { 46 | tableName := v2.Interface().(TableName).TableName() 47 | tvCache.Store(v.Type(), tableName) 48 | return tableName 49 | } 50 | 51 | tvCache.Store(v.Type(), "") 52 | } 53 | } 54 | 55 | return mapper.Obj2Table(v.Type().Name()) 56 | } 57 | -------------------------------------------------------------------------------- /null.go: -------------------------------------------------------------------------------- 1 | package xorm 2 | 3 | type NullType interface { 4 | IsNil() bool 5 | } 6 | -------------------------------------------------------------------------------- /null_bool.go: -------------------------------------------------------------------------------- 1 | package xorm 2 | 3 | import ( 4 | "encoding/json" 5 | "errors" 6 | "fmt" 7 | "reflect" 8 | ) 9 | 10 | type NullBool struct { 11 | Bool bool 12 | Valid bool 13 | } 14 | 15 | func (nb NullBool) Ptr() *bool { 16 | if !nb.Valid { 17 | return nil 18 | } 19 | return &nb.Bool 20 | } 21 | 22 | func (nb NullBool) ValueOrZero() bool { 23 | if !nb.Valid { 24 | return false 25 | } 26 | return nb.Bool 27 | } 28 | 29 | func (nb NullBool) IsNil() bool { 30 | return !nb.Valid 31 | } 32 | 33 | func (nb *NullBool) UnmarshalJSON(data []byte) error { 34 | var err error 35 | var v interface{} 36 | if err = json.Unmarshal(data, &v); err != nil { 37 | return err 38 | } 39 | switch x := v.(type) { 40 | case bool: 41 | nb.Bool = x 42 | case map[string]interface{}: 43 | err = json.Unmarshal(data, &nb) 44 | case nil: 45 | nb.Valid = false 46 | return nil 47 | default: 48 | err = fmt.Errorf("json: cannot unmarshal %v into Go value of type xorm.NullBool", reflect.TypeOf(v).Name()) 49 | } 50 | nb.Valid = err == nil 51 | return err 52 | } 53 | 54 | func (nb *NullBool) UnmarshalText(text []byte) error { 55 | str := string(text) 56 | switch str { 57 | case "", "null": 58 | nb.Valid = false 59 | return nil 60 | case "true": 61 | nb.Bool = true 62 | case "false": 63 | nb.Bool = false 64 | default: 65 | nb.Valid = false 66 | return errors.New("invalid input:" + str) 67 | } 68 | nb.Valid = true 69 | return nil 70 | } 71 | 72 | func (nb NullBool) MarshalJSON() ([]byte, error) { 73 | if !nb.Valid { 74 | return []byte("null"), nil 75 | } 76 | if !nb.Bool { 77 | return []byte("false"), nil 78 | } 79 | return []byte("true"), nil 80 | } 81 | 82 | func (nb NullBool) MarshalText() ([]byte, error) { 83 | if !nb.Valid { 84 | return []byte{}, nil 85 | } 86 | if !nb.Bool { 87 | return []byte("false"), nil 88 | } 89 | return []byte("true"), nil 90 | } 91 | -------------------------------------------------------------------------------- /null_int.go: -------------------------------------------------------------------------------- 1 | package xorm 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "reflect" 7 | "strconv" 8 | ) 9 | 10 | type NullInt struct { 11 | Int int 12 | Valid bool 13 | } 14 | 15 | func (ni NullInt) Ptr() *int { 16 | if !ni.Valid { 17 | return nil 18 | } 19 | return &ni.Int 20 | } 21 | 22 | func (ni NullInt) ValueOrZero() int { 23 | if !ni.Valid { 24 | return 0 25 | } 26 | return ni.Int 27 | } 28 | 29 | func (ni NullInt) IsNil() bool { 30 | return !ni.Valid 31 | } 32 | 33 | func (ni *NullInt) UnmarshalJSON(data []byte) error { 34 | var err error 35 | var v interface{} 36 | if err = json.Unmarshal(data, &v); err != nil { 37 | return err 38 | } 39 | switch x := v.(type) { 40 | case float64: 41 | err = json.Unmarshal(data, &ni.Int) 42 | case string: 43 | str := string(x) 44 | if len(str) == 0 { 45 | ni.Valid = false 46 | return nil 47 | } 48 | ni.Int, err = strconv.Atoi(string(str)) 49 | case map[string]interface{}: 50 | err = json.Unmarshal(data, &ni) 51 | case nil: 52 | ni.Valid = false 53 | return nil 54 | default: 55 | err = fmt.Errorf("json: cannot unmarshal %v into Go value of type xorm.NullInt", reflect.TypeOf(v).Name()) 56 | } 57 | ni.Valid = err == nil 58 | return err 59 | } 60 | 61 | func (ni *NullInt) UnmarshalText(text []byte) error { 62 | str := string(text) 63 | if str == "" || str == "null" { 64 | ni.Valid = false 65 | return nil 66 | } 67 | var err error 68 | ni.Int, err = strconv.Atoi(string(text)) 69 | ni.Valid = err == nil 70 | return err 71 | } 72 | 73 | func (ni NullInt) MarshalJSON() ([]byte, error) { 74 | if !ni.Valid { 75 | return []byte("null"), nil 76 | } 77 | return []byte(strconv.Itoa(ni.Int)), nil 78 | } 79 | 80 | func (ni NullInt) MarshalText() ([]byte, error) { 81 | if !ni.Valid { 82 | return []byte{}, nil 83 | } 84 | return []byte(strconv.Itoa(ni.Int)), nil 85 | } 86 | -------------------------------------------------------------------------------- /null_int64.go: -------------------------------------------------------------------------------- 1 | package xorm 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "reflect" 7 | "strconv" 8 | ) 9 | 10 | type NullInt64 struct { 11 | Int64 int64 12 | Valid bool 13 | } 14 | 15 | func (ni NullInt64) Ptr() *int64 { 16 | if !ni.Valid { 17 | return nil 18 | } 19 | return &ni.Int64 20 | } 21 | 22 | func (ni NullInt64) ValueOrZero() int64 { 23 | if !ni.Valid { 24 | return 0 25 | } 26 | return ni.Int64 27 | } 28 | 29 | func (ni NullInt64) IsNil() bool { 30 | return !ni.Valid 31 | } 32 | 33 | func (ni *NullInt64) UnmarshalJSON(data []byte) error { 34 | var err error 35 | var v interface{} 36 | if err = json.Unmarshal(data, &v); err != nil { 37 | return err 38 | } 39 | switch x := v.(type) { 40 | case float64: 41 | err = json.Unmarshal(data, &ni.Int64) 42 | case string: 43 | str := string(x) 44 | if len(str) == 0 { 45 | ni.Valid = false 46 | return nil 47 | } 48 | ni.Int64, err = strconv.ParseInt(str, 10, 64) 49 | case map[string]interface{}: 50 | err = json.Unmarshal(data, &ni) 51 | case nil: 52 | ni.Valid = false 53 | return nil 54 | default: 55 | err = fmt.Errorf("json: cannot unmarshal %v into Go value of type xorm.NullInt64", reflect.TypeOf(v).Name()) 56 | } 57 | ni.Valid = err == nil 58 | return err 59 | } 60 | 61 | func (ni *NullInt64) UnmarshalText(text []byte) error { 62 | str := string(text) 63 | if str == "" || str == "null" { 64 | ni.Valid = false 65 | return nil 66 | } 67 | var err error 68 | ni.Int64, err = strconv.ParseInt(string(text), 10, 64) 69 | ni.Valid = err == nil 70 | return err 71 | } 72 | 73 | func (ni NullInt64) MarshalJSON() ([]byte, error) { 74 | if !ni.Valid { 75 | return []byte("null"), nil 76 | } 77 | return []byte(strconv.FormatInt(ni.Int64, 10)), nil 78 | } 79 | 80 | func (ni NullInt64) MarshalText() ([]byte, error) { 81 | if !ni.Valid { 82 | return []byte{}, nil 83 | } 84 | return []byte(strconv.FormatInt(ni.Int64, 10)), nil 85 | } 86 | -------------------------------------------------------------------------------- /null_string.go: -------------------------------------------------------------------------------- 1 | package xorm 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "reflect" 7 | ) 8 | 9 | type NullString struct { 10 | String string 11 | Valid bool 12 | } 13 | 14 | func (ns NullString) Ptr() *string { 15 | if !ns.Valid { 16 | return nil 17 | } 18 | return &ns.String 19 | } 20 | 21 | func (ns NullString) ValueOrZero() string { 22 | if !ns.Valid { 23 | return "" 24 | } 25 | return ns.String 26 | } 27 | 28 | func (ns NullString) IsNil() bool { 29 | return !ns.Valid 30 | } 31 | 32 | func (ns *NullString) UnmarshalJSON(data []byte) error { 33 | var err error 34 | var v interface{} 35 | if err = json.Unmarshal(data, &v); err != nil { 36 | return err 37 | } 38 | switch x := v.(type) { 39 | case string: 40 | ns.String = x 41 | case map[string]interface{}: 42 | err = json.Unmarshal(data, &ns) 43 | case nil: 44 | ns.Valid = false 45 | return nil 46 | default: 47 | err = fmt.Errorf("json: cannot unmarshal %v into Go value of type xorm.NullString", reflect.TypeOf(v).Name()) 48 | } 49 | ns.Valid = err == nil 50 | return err 51 | } 52 | 53 | func (ns NullString) MarshalJSON() ([]byte, error) { 54 | if !ns.Valid { 55 | return []byte("null"), nil 56 | } 57 | return json.Marshal(ns.String) 58 | } 59 | 60 | func (ns NullString) MarshalText() ([]byte, error) { 61 | if !ns.Valid { 62 | return []byte{}, nil 63 | } 64 | return []byte(ns.String), nil 65 | } 66 | 67 | func (ns *NullString) UnmarshalText(text []byte) error { 68 | ns.String = string(text) 69 | ns.Valid = ns.String != "" 70 | return nil 71 | } 72 | -------------------------------------------------------------------------------- /null_time.go: -------------------------------------------------------------------------------- 1 | package xorm 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | type NullTime struct { 8 | Time time.Time 9 | Valid bool 10 | } 11 | 12 | func (nt NullTime) Ptr() *time.Time { 13 | if !nt.Valid { 14 | return nil 15 | } 16 | return &nt.Time 17 | } 18 | 19 | func (nt NullTime) ValueOrZero() time.Time { 20 | if !nt.Valid { 21 | return time.Time{} 22 | } 23 | return nt.Time 24 | } 25 | 26 | func (nt NullTime) IsNil() bool { 27 | return !nt.Valid 28 | } 29 | -------------------------------------------------------------------------------- /schemas/index.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Xorm 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 schemas 6 | 7 | import ( 8 | "fmt" 9 | "strings" 10 | ) 11 | 12 | // enumerate all index types 13 | const ( 14 | IndexType = iota + 1 15 | UniqueType 16 | ) 17 | 18 | // Index represents a database index 19 | type Index struct { 20 | IsRegular bool 21 | Name string 22 | Type int 23 | Cols []string 24 | } 25 | 26 | // NewIndex new an index object 27 | func NewIndex(name string, indexType int) *Index { 28 | return &Index{true, name, indexType, make([]string, 0)} 29 | } 30 | 31 | func (index *Index) XName(tableName string) string { 32 | if !strings.HasPrefix(index.Name, "UQE_") && 33 | !strings.HasPrefix(index.Name, "IDX_") { 34 | tableParts := strings.Split(strings.Replace(tableName, `"`, "", -1), ".") 35 | tableName = tableParts[len(tableParts)-1] 36 | if index.Type == UniqueType { 37 | return fmt.Sprintf("UQE_%v_%v", tableName, index.Name) 38 | } 39 | return fmt.Sprintf("IDX_%v_%v", tableName, index.Name) 40 | } 41 | return index.Name 42 | } 43 | 44 | // AddColumn add columns which will be composite index 45 | func (index *Index) AddColumn(cols ...string) { 46 | for _, col := range cols { 47 | index.Cols = append(index.Cols, col) 48 | } 49 | } 50 | 51 | func (index *Index) Equal(dst *Index) bool { 52 | if index.Type != dst.Type { 53 | return false 54 | } 55 | if len(index.Cols) != len(dst.Cols) { 56 | return false 57 | } 58 | 59 | for i := 0; i < len(index.Cols); i++ { 60 | var found bool 61 | for j := 0; j < len(dst.Cols); j++ { 62 | if index.Cols[i] == dst.Cols[j] { 63 | found = true 64 | break 65 | } 66 | } 67 | if !found { 68 | return false 69 | } 70 | } 71 | return true 72 | } 73 | -------------------------------------------------------------------------------- /schemas/pk.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Xorm 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 schemas 6 | 7 | import ( 8 | "bytes" 9 | "encoding/gob" 10 | 11 | "github.com/xormplus/xorm/internal/utils" 12 | ) 13 | 14 | type PK []interface{} 15 | 16 | func NewPK(pks ...interface{}) *PK { 17 | p := PK(pks) 18 | return &p 19 | } 20 | 21 | func (p *PK) IsZero() bool { 22 | for _, k := range *p { 23 | if utils.IsZero(k) { 24 | return true 25 | } 26 | } 27 | return false 28 | } 29 | 30 | func (p *PK) ToString() (string, error) { 31 | buf := new(bytes.Buffer) 32 | enc := gob.NewEncoder(buf) 33 | err := enc.Encode(*p) 34 | return buf.String(), err 35 | } 36 | 37 | func (p *PK) FromString(content string) error { 38 | dec := gob.NewDecoder(bytes.NewBufferString(content)) 39 | err := dec.Decode(p) 40 | return err 41 | } 42 | -------------------------------------------------------------------------------- /schemas/pk_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Xorm 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 schemas 6 | 7 | import ( 8 | "reflect" 9 | "testing" 10 | ) 11 | 12 | func TestPK(t *testing.T) { 13 | p := NewPK(1, 3, "string") 14 | str, err := p.ToString() 15 | if err != nil { 16 | t.Error(err) 17 | } 18 | t.Log(str) 19 | 20 | s := &PK{} 21 | err = s.FromString(str) 22 | if err != nil { 23 | t.Error(err) 24 | } 25 | t.Log(s) 26 | 27 | if len(*p) != len(*s) { 28 | t.Fatal("p", *p, "should be equal", *s) 29 | } 30 | 31 | for i, ori := range *p { 32 | if ori != (*s)[i] { 33 | t.Fatal("ori", ori, reflect.ValueOf(ori), "should be equal", (*s)[i], reflect.ValueOf((*s)[i])) 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /session_exist.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Xorm 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 xorm 6 | 7 | // Exist returns true if the record exist otherwise return false 8 | func (session *Session) Exist(bean ...interface{}) (bool, error) { 9 | if session.isAutoClose { 10 | defer session.Close() 11 | } 12 | 13 | if session.statement.LastError != nil { 14 | return false, session.statement.LastError 15 | } 16 | 17 | sqlStr, args, err := session.statement.GenExistSQL(bean...) 18 | if err != nil { 19 | return false, err 20 | } 21 | 22 | rows, err := session.queryRows(sqlStr, args...) 23 | if err != nil { 24 | return false, err 25 | } 26 | defer rows.Close() 27 | 28 | return rows.Next(), nil 29 | } 30 | -------------------------------------------------------------------------------- /sqlmap_json.go: -------------------------------------------------------------------------------- 1 | package xorm 2 | 3 | type JsonSqlMap struct { 4 | sqlMapRootDir string 5 | extension string 6 | } 7 | 8 | func Json(directory, extension string) *JsonSqlMap { 9 | return &JsonSqlMap{ 10 | sqlMapRootDir: directory, 11 | extension: extension, 12 | } 13 | } 14 | 15 | func (sqlMap *JsonSqlMap) RootDir() string { 16 | return sqlMap.sqlMapRootDir 17 | } 18 | 19 | func (sqlMap *JsonSqlMap) Extension() string { 20 | return sqlMap.extension 21 | } 22 | -------------------------------------------------------------------------------- /sqlmap_xml.go: -------------------------------------------------------------------------------- 1 | package xorm 2 | 3 | type XmlSqlMap struct { 4 | sqlMapRootDir string 5 | extension string 6 | } 7 | 8 | type XmlSql struct { 9 | Sql []Sql `xml:"sql"` 10 | } 11 | 12 | type Sql struct { 13 | Value string `xml:",chardata"` 14 | Id string `xml:"id,attr"` 15 | } 16 | 17 | func Xml(directory, extension string) *XmlSqlMap { 18 | return &XmlSqlMap{ 19 | sqlMapRootDir: directory, 20 | extension: extension, 21 | } 22 | } 23 | 24 | func (sqlMap *XmlSqlMap) RootDir() string { 25 | return sqlMap.sqlMapRootDir 26 | } 27 | 28 | func (sqlMap *XmlSqlMap) Extension() string { 29 | return sqlMap.extension 30 | } 31 | -------------------------------------------------------------------------------- /sqlmap_xsql.go: -------------------------------------------------------------------------------- 1 | package xorm 2 | 3 | import ( 4 | "bufio" 5 | "regexp" 6 | "strings" 7 | ) 8 | 9 | type XSqlMap struct { 10 | sqlMapRootDir string 11 | extension string 12 | } 13 | 14 | func XSql(directory, extension string) *XSqlMap { 15 | return &XSqlMap{ 16 | sqlMapRootDir: directory, 17 | extension: extension, 18 | } 19 | } 20 | 21 | func (sqlMap *XSqlMap) RootDir() string { 22 | return sqlMap.sqlMapRootDir 23 | } 24 | 25 | func (sqlMap *XSqlMap) Extension() string { 26 | return sqlMap.extension 27 | } 28 | 29 | type Scanner struct { 30 | line string 31 | queries map[string]string 32 | current string 33 | } 34 | 35 | type stateFn func(*Scanner) stateFn 36 | 37 | func getTag(line string) string { 38 | re := regexp.MustCompile("^\\s*--\\s*id:\\s*(\\S+)") 39 | matches := re.FindStringSubmatch(line) 40 | if matches == nil { 41 | return "" 42 | } 43 | return matches[1] 44 | } 45 | 46 | func initialState(s *Scanner) stateFn { 47 | if tag := getTag(s.line); len(tag) > 0 { 48 | s.current = tag 49 | return queryState 50 | } 51 | return initialState 52 | } 53 | 54 | func queryState(s *Scanner) stateFn { 55 | if tag := getTag(s.line); len(tag) > 0 { 56 | s.current = tag 57 | } else { 58 | s.appendQueryLine() 59 | } 60 | return queryState 61 | } 62 | 63 | func (s *Scanner) appendQueryLine() { 64 | current := s.queries[s.current] 65 | line := strings.Trim(s.line, " \t") 66 | if len(line) == 0 { 67 | return 68 | } 69 | 70 | if len(current) > 0 { 71 | current = current + "\n" 72 | } 73 | 74 | current = current + line 75 | s.queries[s.current] = current 76 | } 77 | 78 | func (s *Scanner) Run(io *bufio.Scanner) map[string]string { 79 | s.queries = make(map[string]string) 80 | 81 | for state := initialState; io.Scan(); { 82 | s.line = io.Text() 83 | state = state(s) 84 | } 85 | 86 | return s.queries 87 | } 88 | -------------------------------------------------------------------------------- /tags/parser_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2020 The Xorm 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 tags 6 | 7 | import ( 8 | "reflect" 9 | "testing" 10 | 11 | "github.com/stretchr/testify/assert" 12 | "github.com/xormplus/xorm/caches" 13 | "github.com/xormplus/xorm/dialects" 14 | "github.com/xormplus/xorm/names" 15 | ) 16 | 17 | type ParseTableName1 struct{} 18 | 19 | type ParseTableName2 struct{} 20 | 21 | func (p ParseTableName2) TableName() string { 22 | return "p_parseTableName" 23 | } 24 | 25 | func TestParseTableName(t *testing.T) { 26 | parser := NewParser( 27 | "xorm", 28 | dialects.QueryDialect("mysql"), 29 | names.SnakeMapper{}, 30 | names.SnakeMapper{}, 31 | caches.NewManager(), 32 | ) 33 | table, err := parser.Parse(reflect.ValueOf(new(ParseTableName1))) 34 | assert.NoError(t, err) 35 | assert.EqualValues(t, "parse_table_name1", table.Name) 36 | 37 | table, err = parser.Parse(reflect.ValueOf(new(ParseTableName2))) 38 | assert.NoError(t, err) 39 | assert.EqualValues(t, "p_parseTableName", table.Name) 40 | 41 | table, err = parser.Parse(reflect.ValueOf(ParseTableName2{})) 42 | assert.NoError(t, err) 43 | assert.EqualValues(t, "p_parseTableName", table.Name) 44 | } 45 | -------------------------------------------------------------------------------- /tags/tag_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Xorm 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 tags 6 | 7 | import ( 8 | "testing" 9 | 10 | "github.com/xormplus/xorm/internal/utils" 11 | ) 12 | 13 | func TestSplitTag(t *testing.T) { 14 | var cases = []struct { 15 | tag string 16 | tags []string 17 | }{ 18 | {"not null default '2000-01-01 00:00:00' TIMESTAMP", []string{"not", "null", "default", "'2000-01-01 00:00:00'", "TIMESTAMP"}}, 19 | {"TEXT", []string{"TEXT"}}, 20 | {"default('2000-01-01 00:00:00')", []string{"default('2000-01-01 00:00:00')"}}, 21 | {"json binary", []string{"json", "binary"}}, 22 | } 23 | 24 | for _, kase := range cases { 25 | tags := splitTag(kase.tag) 26 | if !utils.SliceEq(tags, kase.tags) { 27 | t.Fatalf("[%d]%v is not equal [%d]%v", len(tags), tags, len(kase.tags), kase.tags) 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/sql/oracle/fxi.xx: -------------------------------------------------------------------------------- 1 | 2 | 3 | select id,title,createdatetime,content 4 | from article where id in (?1,?2) 5 | 6 | 7 | select * from article where id=?id and 1=1 8 | 9 | 10 | select id,title,createdatetime,content from article where id = ?id 11 | 12 | 13 | INSERT INTO config(key,value) VALUES (?, ?) 14 | 15 | 16 | INSERT INTO config(key,value) VALUES (?key, ?value) 17 | 18 | -------------------------------------------------------------------------------- /test/sql/oracle/select.example.jet: -------------------------------------------------------------------------------- 1 | select id,userid,title,createdatetime,content 2 | from Article where 3 | {{if data.count > 1 }} 4 | id=?id 5 | {{else}} 6 | userid=?userid 7 | {{end}} 8 | -------------------------------------------------------------------------------- /test/sql/oracle/select.example.stpl: -------------------------------------------------------------------------------- 1 | select id,userid,title,createdatetime,content 2 | from Article where 3 | {% if count>1%} 4 | id=?id 5 | {% else%} 6 | userid=?userid 7 | {% endif %} -------------------------------------------------------------------------------- /test/sql/oracle/select.example.tpl: -------------------------------------------------------------------------------- 1 | select id,userid,title,createdatetime,content 2 | from Article where 3 | {{if gt 1 .count}} 4 | id=?id 5 | {{else}} 6 | userid=?userid 7 | {{end}} 8 | -------------------------------------------------------------------------------- /test/sql/oracle/studygolang.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | select id,title,createdatetime,content 4 | from Article where id in (?1,?2) 5 | 6 | 7 | select * from user where id=?id and 1=1 8 | 9 | 10 | select id,title,createdatetime,content from Article where id = ?id 11 | 12 | 13 | INSERT INTO categories VALUES (?id, ?name, ?counts, ?orders, ?pid) 14 | 15 | 16 | INSERT INTO categories VALUES (?id, ?name, ?counts, ?orders, ?pid) 17 | 18 | 19 | select * from category 20 | 21 | 22 | select * from category where id in (16,17) 23 | 24 | 25 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /test/sql/oracle/test.json: -------------------------------------------------------------------------------- 1 | { 2 | "json_selectAllArticle": "select id,title,createdatetime,content from Article where id in (?1,?2)", 3 | "json_selectStudentById1": "select * from user where id=?id and 1=1", 4 | "json_sql_2_1": "select id,title,createdatetime,content from Article where id = ?id", 5 | "json_sql_i_1": "INSERT INTO categories VALUES (?id, ?name, ?counts, ?orders, ?pid)", 6 | "json_sql_i_2": "INSERT INTO categories VALUES (?id, ?name, ?counts, ?orders, ?pid)", 7 | "json_category": "select * from category", 8 | "json_category-16-17": "select * from category where id in (16,17) and name='dd'" 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/Chronokeeper/anyxml/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Chronokeeper 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/CloudyKit/fastprinter/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 CloudyKit 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/CloudyKit/fastprinter/README.md: -------------------------------------------------------------------------------- 1 | # fastprinter 2 | FastPrinter supports write values in io.Writer without allocation 3 | -------------------------------------------------------------------------------- /vendor/github.com/CloudyKit/jet/profile.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | go test -run="^$" -bench="Range" -benchmem -c -cpuprofile=./pprof.out 4 | go test -run="^$" -bench="Range" -benchmem -cpuprofile=./pprof.out 5 | go tool pprof --pdf --focus="$1" jet.test pprof.out >> out.pdf 6 | rm jet.test 7 | rm pprof.out 8 | open out.pdf -------------------------------------------------------------------------------- /vendor/github.com/CloudyKit/jet/stress.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash -e 2 | 3 | go test -c 4 | # comment above and uncomment below to enable the race builder 5 | #go test -c -race 6 | PKG=$(basename $(pwd)) 7 | 8 | while true ; do 9 | export GOMAXPROCS=$[ 1 + $[ RANDOM % 128 ]] 10 | ./$PKG.test $@ 2>&1 11 | done -------------------------------------------------------------------------------- /vendor/github.com/agrison/go-tablib/HISTORY.md: -------------------------------------------------------------------------------- 1 | ## History 2 | 3 | ### 2016-02-26 4 | - Added support for Markdown tables export 5 | 6 | ### 2016-02-25 7 | 8 | - Constrained columns 9 | - `Dataset.ValidSubset()` 10 | - `Dataset.InvalidSubset()` 11 | - Tagging a specific row after it was already created 12 | - Loading Databooks 13 | - JSON 14 | - YAML 15 | - Loading Datasets 16 | - CSV 17 | - TSV 18 | - XML 19 | - Unit test coverage 20 | 21 | ### 2016-02-24 22 | 23 | - Constrained columns 24 | - Support for `time.Time` in `Dataset.MySQL()` and `Dataset.Postgres()` export. 25 | - Source files refactoring 26 | - Added on travis-ci 27 | - Retrieving specific rows 28 | - `Dataset.Row(int)` 29 | - `Dataset.Rows(int...)` 30 | - `Dataset.Slice(int, int)` 31 | 32 | ### 2016-02-23 33 | 34 | - First release with support for: 35 | - Loading YAML, JSON 36 | - Exporting YAML, JSON, CSV, TSV, XLS, XML, ASCII 37 | - Filtering + Tagging 38 | - Sorting 39 | - ... 40 | -------------------------------------------------------------------------------- /vendor/github.com/agrison/go-tablib/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Alexandre Grison 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/agrison/go-tablib/tablib_databook.go: -------------------------------------------------------------------------------- 1 | package tablib 2 | 3 | // Sheet represents a sheet in a Databook, holding a title (if any) and a dataset. 4 | type Sheet struct { 5 | title string 6 | dataset *Dataset 7 | } 8 | 9 | // Title return the title of the sheet. 10 | func (s Sheet) Title() string { 11 | return s.title 12 | } 13 | 14 | // Dataset returns the dataset of the sheet. 15 | func (s Sheet) Dataset() *Dataset { 16 | return s.dataset 17 | } 18 | 19 | // Databook represents a Databook which is an array of sheets. 20 | type Databook struct { 21 | sheets map[string]Sheet 22 | } 23 | 24 | // NewDatabook constructs a new Databook. 25 | func NewDatabook() *Databook { 26 | return &Databook{make(map[string]Sheet)} 27 | } 28 | 29 | // Sheets returns the sheets in the Databook. 30 | func (d *Databook) Sheets() map[string]Sheet { 31 | return d.sheets 32 | } 33 | 34 | // Sheet returns the sheet with a specific title. 35 | func (d *Databook) Sheet(title string) Sheet { 36 | return d.sheets[title] 37 | } 38 | 39 | // AddSheet adds a sheet to the Databook. 40 | func (d *Databook) AddSheet(title string, dataset *Dataset) { 41 | d.sheets[title] = Sheet{title, dataset} 42 | } 43 | 44 | // Size returns the number of sheets in the Databook. 45 | func (d *Databook) Size() int { 46 | return len(d.sheets) 47 | } 48 | 49 | // Wipe removes all Dataset objects from the Databook. 50 | func (d *Databook) Wipe() { 51 | for k := range d.sheets { 52 | delete(d.sheets, k) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/agrison/go-tablib/tablib_errors.go: -------------------------------------------------------------------------------- 1 | package tablib 2 | 3 | import "errors" 4 | 5 | var ( 6 | // ErrInvalidDimensions is returned when trying to append/insert too much 7 | // or not enough values to a row or column 8 | ErrInvalidDimensions = errors.New("tablib: Invalid dimension") 9 | // ErrInvalidColumnIndex is returned when trying to insert a column at an 10 | // invalid index 11 | ErrInvalidColumnIndex = errors.New("tablib: Invalid column index") 12 | // ErrInvalidRowIndex is returned when trying to insert a row at an 13 | // invalid index 14 | ErrInvalidRowIndex = errors.New("tablib: Invalid row index") 15 | // ErrInvalidDataset is returned when trying to validate a Dataset against 16 | // the constraints that have been set on its columns. 17 | ErrInvalidDataset = errors.New("tablib: Invalid dataset") 18 | // ErrInvalidTag is returned when trying to add a tag which is not a string. 19 | ErrInvalidTag = errors.New("tablib: A tag must be a string") 20 | ) 21 | -------------------------------------------------------------------------------- /vendor/github.com/agrison/go-tablib/tablib_html.go: -------------------------------------------------------------------------------- 1 | package tablib 2 | 3 | // HTML returns the HTML representation of the Dataset as an Exportable. 4 | func (d *Dataset) HTML() *Exportable { 5 | back := d.Records() 6 | b := newBuffer() 7 | 8 | b.WriteString("\n\t") 9 | for i, r := range back { 10 | b.WriteString("\n\t\t") 11 | for _, c := range r { 12 | tag := "td" 13 | if i == 0 { 14 | tag = "th" 15 | } 16 | b.WriteString("\n\t\t\t<" + tag + ">") 17 | b.WriteString(c) 18 | b.WriteString("") 19 | } 20 | b.WriteString("\n\t\t") 21 | if i == 0 { 22 | b.WriteString("\n\t\n\t") 23 | } 24 | } 25 | b.WriteString("\n\t\n
") 26 | 27 | return newExportable(b) 28 | } 29 | 30 | // HTML returns a HTML representation of the Databook as an Exportable. 31 | func (d *Databook) HTML() *Exportable { 32 | b := newBuffer() 33 | 34 | for _, s := range d.sheets { 35 | b.WriteString("

" + s.title + "

\n") 36 | b.Write(s.dataset.HTML().Bytes()) 37 | b.WriteString("\n\n") 38 | } 39 | 40 | return newExportable(b) 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/agrison/go-tablib/tablib_util.go: -------------------------------------------------------------------------------- 1 | package tablib 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | "time" 7 | ) 8 | 9 | // internalLoadFromDict creates a Dataset from an array of map representing columns. 10 | func internalLoadFromDict(input []map[string]interface{}) (*Dataset, error) { 11 | // retrieve columns 12 | headers := make([]string, 0, 10) 13 | for h := range input[0] { 14 | headers = append(headers, h) 15 | } 16 | 17 | ds := NewDataset(headers) 18 | for _, e := range input { 19 | row := make([]interface{}, 0, len(headers)) 20 | for _, h := range headers { 21 | row = append(row, e[h]) 22 | } 23 | ds.AppendValues(row...) 24 | } 25 | 26 | return ds, nil 27 | } 28 | 29 | // isTagged checks if a tag is in an array of tags. 30 | func isTagged(tag string, tags []string) bool { 31 | for _, t := range tags { 32 | if t == tag { 33 | return true 34 | } 35 | } 36 | return false 37 | } 38 | 39 | // asString returns a value as a string. 40 | func (d *Dataset) asString(vv interface{}) string { 41 | var v string 42 | switch vv.(type) { 43 | case string: 44 | v = vv.(string) 45 | case int: 46 | v = strconv.Itoa(vv.(int)) 47 | case int64: 48 | v = strconv.FormatInt(vv.(int64), 10) 49 | case uint64: 50 | v = strconv.FormatUint(vv.(uint64), 10) 51 | case bool: 52 | v = strconv.FormatBool(vv.(bool)) 53 | case float64: 54 | v = strconv.FormatFloat(vv.(float64), 'G', -1, 32) 55 | case time.Time: 56 | v = vv.(time.Time).Format(time.RFC3339) 57 | default: 58 | if d.EmptyValue != "" { 59 | v = d.EmptyValue 60 | } else { 61 | v = fmt.Sprintf("%s", v) 62 | } 63 | } 64 | return v 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/agrison/go-tablib/tablib_xlsx.go: -------------------------------------------------------------------------------- 1 | package tablib 2 | 3 | import ( 4 | "github.com/tealeg/xlsx" 5 | ) 6 | 7 | // XLSX exports the Dataset as a byte array representing the .xlsx format. 8 | func (d *Dataset) XLSX() (*Exportable, error) { 9 | file := xlsx.NewFile() 10 | if err := d.addXlsxSheetToFile(file, "Sheet 1"); err != nil { 11 | return nil, err 12 | } 13 | 14 | b := newBuffer() 15 | file.Write(b) 16 | return newExportable(b), nil 17 | } 18 | 19 | // XLSX returns a XLSX representation of the Databook as an exportable. 20 | func (d *Databook) XLSX() (*Exportable, error) { 21 | file := xlsx.NewFile() 22 | 23 | for _, s := range d.sheets { 24 | s.dataset.addXlsxSheetToFile(file, s.title) 25 | } 26 | 27 | b := newBuffer() 28 | file.Write(b) 29 | return newExportable(b), nil 30 | } 31 | 32 | func (d *Dataset) addXlsxSheetToFile(file *xlsx.File, sheetName string) error { 33 | sheet, err := file.AddSheet(sheetName) 34 | if err != nil { 35 | return nil 36 | } 37 | 38 | back := d.Records() 39 | for i, r := range back { 40 | row := sheet.AddRow() 41 | for _, c := range r { 42 | cell := row.AddCell() 43 | cell.Value = c 44 | if i == 0 { 45 | cell.GetStyle().Font.Bold = true 46 | } 47 | } 48 | } 49 | return nil 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/agrison/mxj/exists.go: -------------------------------------------------------------------------------- 1 | package mxj 2 | 3 | // Checks whether the path exists 4 | func (mv Map) Exists(path string) bool { 5 | v, err := mv.ValuesForPath(path) 6 | return err == nil && len(v) > 0 7 | } 8 | -------------------------------------------------------------------------------- /vendor/github.com/agrison/mxj/files_test.badjson: -------------------------------------------------------------------------------- 1 | { "this":"is", "a":"test", "file":"for", "files_test.go":"case" } 2 | { "with":"some", "bad":JSON, "in":"it" } 3 | -------------------------------------------------------------------------------- /vendor/github.com/agrison/mxj/files_test.badxml: -------------------------------------------------------------------------------- 1 | 2 | test 3 | for files.go 4 | 5 | 6 | some 7 | doc 8 | test case 9 | 10 | -------------------------------------------------------------------------------- /vendor/github.com/agrison/mxj/files_test.json: -------------------------------------------------------------------------------- 1 | { "this":"is", "a":"test", "file":"for", "files_test.go":"case" } 2 | { "with":"just", "two":2, "JSON":"values", "true":true } 3 | -------------------------------------------------------------------------------- /vendor/github.com/agrison/mxj/files_test.xml: -------------------------------------------------------------------------------- 1 | 2 | test 3 | for files.go 4 | 5 | 6 | some 7 | doc 8 | test case 9 | 10 | -------------------------------------------------------------------------------- /vendor/github.com/agrison/mxj/files_test_dup.json: -------------------------------------------------------------------------------- 1 | {"a":"test","file":"for","files_test.go":"case","this":"is"}{"JSON":"values","true":true,"two":2,"with":"just"} -------------------------------------------------------------------------------- /vendor/github.com/agrison/mxj/files_test_dup.xml: -------------------------------------------------------------------------------- 1 | for files.gotestdoctest casesome -------------------------------------------------------------------------------- /vendor/github.com/agrison/mxj/files_test_indent.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": "test", 3 | "file": "for", 4 | "files_test.go": "case", 5 | "this": "is" 6 | } 7 | { 8 | "JSON": "values", 9 | "true": true, 10 | "two": 2, 11 | "with": "just" 12 | } -------------------------------------------------------------------------------- /vendor/github.com/agrison/mxj/files_test_indent.xml: -------------------------------------------------------------------------------- 1 | 2 | for files.go 3 | test 4 | 5 | doc 6 | test case 7 | some 8 | -------------------------------------------------------------------------------- /vendor/github.com/agrison/mxj/remove.go: -------------------------------------------------------------------------------- 1 | package mxj 2 | 3 | import "strings" 4 | 5 | // Removes the path. 6 | func (mv Map) Remove(path string) error { 7 | m := map[string]interface{}(mv) 8 | return remove(m, path) 9 | } 10 | 11 | func remove(m interface{}, path string) error { 12 | val, err := prevValueByPath(m, path) 13 | if err != nil { 14 | return err 15 | } 16 | 17 | lastKey := lastKey(path) 18 | delete(val, lastKey) 19 | 20 | return nil 21 | } 22 | 23 | // returns the last key of the path. 24 | // lastKey("a.b.c") would had returned "c" 25 | func lastKey(path string) string { 26 | keys := strings.Split(path, ".") 27 | key := keys[len(keys)-1] 28 | return key 29 | } 30 | 31 | // returns the path without the last key 32 | // parentPath("a.b.c") whould had returned "a.b" 33 | func parentPath(path string) string { 34 | keys := strings.Split(path, ".") 35 | parentPath := strings.Join(keys[0:len(keys)-1], ".") 36 | return parentPath 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/agrison/mxj/rename.go: -------------------------------------------------------------------------------- 1 | package mxj 2 | 3 | import ( 4 | "errors" 5 | "strings" 6 | ) 7 | 8 | // RenameKey renames a key in a Map. 9 | // It works only for nested maps. It doesn't work for cases when it buried in a list. 10 | func (mv Map) RenameKey(path string, newName string) error { 11 | if !mv.Exists(path) { 12 | return errors.New("RenameKey: the path not found: " + path) 13 | } 14 | if mv.Exists(parentPath(path) + "." + newName) { 15 | return errors.New("RenameKey: the key already exists: " + newName) 16 | } 17 | 18 | m := map[string]interface{}(mv) 19 | return renameKey(m, path, newName) 20 | } 21 | 22 | func renameKey(m interface{}, path string, newName string) error { 23 | val, err := prevValueByPath(m, path) 24 | if err != nil { 25 | return err 26 | } 27 | 28 | oldName := lastKey(path) 29 | val[newName] = val[oldName] 30 | delete(val, oldName) 31 | 32 | return nil 33 | } 34 | 35 | // returns a value which contains a last key in the path 36 | // For example: prevValueByPath("a.b.c", {a{b{c: 3}}}) returns {c: 3} 37 | func prevValueByPath(m interface{}, path string) (map[string]interface{}, error) { 38 | keys := strings.Split(path, ".") 39 | 40 | switch mValue := m.(type) { 41 | case map[string]interface{}: 42 | for key, value := range mValue { 43 | if key == keys[0] { 44 | if len(keys) == 1 { 45 | return mValue, nil 46 | } else { 47 | // keep looking for the full path to the key 48 | return prevValueByPath(value, strings.Join(keys[1:], ".")) 49 | } 50 | } 51 | } 52 | } 53 | return nil, errors.New("prevValueByPath: didn't find the path – " + path) 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/agrison/mxj/set.go: -------------------------------------------------------------------------------- 1 | package mxj 2 | 3 | import ( 4 | "strings" 5 | ) 6 | 7 | // Sets the value for the path 8 | func (mv Map) SetValueForPath(value interface{}, path string) error { 9 | pathAry := strings.Split(path, ".") 10 | parentPathAry := pathAry[0 : len(pathAry)-1] 11 | parentPath := strings.Join(parentPathAry, ".") 12 | 13 | val, err := mv.ValueForPath(parentPath) 14 | if err != nil { 15 | return err 16 | } 17 | if val == nil { 18 | return nil // we just ignore the request if there's no val 19 | } 20 | 21 | key := pathAry[len(pathAry)-1] 22 | cVal := val.(map[string]interface{}) 23 | cVal[key] = value 24 | 25 | return nil 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/agrison/mxj/songtext.xml: -------------------------------------------------------------------------------- 1 | 2 | help me! 3 | 4 | 5 | 6 | Henry was a renegade 7 | Didn't like to play it safe 8 | One component at a time 9 | There's got to be a better way 10 | Oh, people came from miles around 11 | Searching for a steady job 12 | Welcome to the Motor Town 13 | Booming like an atom bomb 14 | 15 | 16 | Oh, Henry was the end of the story 17 | Then everything went wrong 18 | And we'll return it to its former glory 19 | But it just takes so long 20 | 21 | 22 | 23 | It's going to take a long time 24 | It's going to take it, but we'll make it one day 25 | It's going to take a long time 26 | It's going to take it, but we'll make it one day 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /vendor/github.com/agrison/mxj/struct.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012-2014 Charles Banning. 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 mxj 6 | 7 | import ( 8 | "encoding/json" 9 | "errors" 10 | "github.com/fatih/structs" 11 | "reflect" 12 | ) 13 | 14 | // Create a new Map value from a structure. Error returned if argument is not a structure 15 | // or if there is a json.Marshal or json.Unmarshal error. 16 | // Only public structure fields are decoded in the Map value. Also, json.Marshal structure encoding rules 17 | // are followed for decoding the structure fields. 18 | func NewMapStruct(structVal interface{}) (Map, error) { 19 | if !structs.IsStruct(structVal) { 20 | return nil, errors.New("NewMapStruct() error: argument is not type Struct") 21 | } 22 | return structs.Map(structVal), nil 23 | } 24 | 25 | // Marshal a map[string]interface{} into a structure referenced by 'structPtr'. Error returned 26 | // if argument is not a pointer or if json.Unmarshal returns an error. 27 | // json.Unmarshal structure encoding rules are followed to encode public structure fields. 28 | func (mv Map) Struct(structPtr interface{}) error { 29 | // should check that we're getting a pointer. 30 | if reflect.ValueOf(structPtr).Kind() != reflect.Ptr { 31 | return errors.New("mv.Struct() error: argument is not type Ptr") 32 | } 33 | 34 | m := map[string]interface{}(mv) 35 | j, err := json.Marshal(m) 36 | if err != nil { 37 | return err 38 | } 39 | 40 | return json.Unmarshal(j, structPtr) 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/bndr/gotabulate/AUTHOR: -------------------------------------------------------------------------------- 1 | Vadim Kravcenko 2014 -------------------------------------------------------------------------------- /vendor/github.com/bndr/gotabulate/CHANGELOG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xormplus/xorm/4e1d4fcc1e67fc338647ba8c13f05372eddc27b8/vendor/github.com/bndr/gotabulate/CHANGELOG -------------------------------------------------------------------------------- /vendor/github.com/bndr/gotabulate/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # Contributors git log --format='%aN <%aE>' | sort -uf 2 | Vadim Kravcenko 3 | -------------------------------------------------------------------------------- /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 option 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/fsnotify/fsnotify/AUTHORS: -------------------------------------------------------------------------------- 1 | # Names should be added to this file as 2 | # Name or Organization 3 | # The email address is not required for organizations. 4 | 5 | # You can update this list using the following command: 6 | # 7 | # $ git shortlog -se | awk '{print $2 " " $3 " " $4}' 8 | 9 | # Please keep the list sorted. 10 | 11 | Adrien Bustany 12 | Amit Krishnan 13 | Bjørn Erik Pedersen 14 | Bruno Bigras 15 | Caleb Spare 16 | Case Nelson 17 | Chris Howey 18 | Christoffer Buchholz 19 | Daniel Wagner-Hall 20 | Dave Cheney 21 | Evan Phoenix 22 | Francisco Souza 23 | Hari haran 24 | John C Barstow 25 | Kelvin Fo 26 | Ken-ichirou MATSUZAWA 27 | Matt Layher 28 | Nathan Youngman 29 | Patrick 30 | Paul Hammond 31 | Pawel Knap 32 | Pieter Droogendijk 33 | Pursuit92 34 | Riku Voipio 35 | Rob Figueiredo 36 | Slawek Ligus 37 | Soge Zhang 38 | Tiffany Jernigan 39 | Tilak Sharma 40 | Travis Cline 41 | Tudor Golubenco 42 | Yukang 43 | bronze1man 44 | debrando 45 | henrikedwards 46 | 铁哥 47 | -------------------------------------------------------------------------------- /vendor/github.com/fsnotify/fsnotify/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 The Go Authors. All rights reserved. 2 | Copyright (c) 2012 fsnotify Authors. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /vendor/github.com/fsnotify/fsnotify/fen.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 solaris 6 | 7 | package fsnotify 8 | 9 | import ( 10 | "errors" 11 | ) 12 | 13 | // Watcher watches a set of files, delivering events to a channel. 14 | type Watcher struct { 15 | Events chan Event 16 | Errors chan error 17 | } 18 | 19 | // NewWatcher establishes a new watcher with the underlying OS and begins waiting for events. 20 | func NewWatcher() (*Watcher, error) { 21 | return nil, errors.New("FEN based watcher not yet supported for fsnotify\n") 22 | } 23 | 24 | // Close removes all watches and closes the events channel. 25 | func (w *Watcher) Close() error { 26 | return nil 27 | } 28 | 29 | // Add starts watching the named file or directory (non-recursively). 30 | func (w *Watcher) Add(name string) error { 31 | return nil 32 | } 33 | 34 | // Remove stops watching the the named file or directory (non-recursively). 35 | func (w *Watcher) Remove(name string) error { 36 | return nil 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/fsnotify/fsnotify/fsnotify.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 !plan9 6 | 7 | // Package fsnotify provides a platform-independent interface for file system notifications. 8 | package fsnotify 9 | 10 | import ( 11 | "bytes" 12 | "errors" 13 | "fmt" 14 | ) 15 | 16 | // Event represents a single file system notification. 17 | type Event struct { 18 | Name string // Relative path to the file or directory. 19 | Op Op // File operation that triggered the event. 20 | } 21 | 22 | // Op describes a set of file operations. 23 | type Op uint32 24 | 25 | // These are the generalized file operations that can trigger a notification. 26 | const ( 27 | Create Op = 1 << iota 28 | Write 29 | Remove 30 | Rename 31 | Chmod 32 | ) 33 | 34 | func (op Op) String() string { 35 | // Use a buffer for efficient string concatenation 36 | var buffer bytes.Buffer 37 | 38 | if op&Create == Create { 39 | buffer.WriteString("|CREATE") 40 | } 41 | if op&Remove == Remove { 42 | buffer.WriteString("|REMOVE") 43 | } 44 | if op&Write == Write { 45 | buffer.WriteString("|WRITE") 46 | } 47 | if op&Rename == Rename { 48 | buffer.WriteString("|RENAME") 49 | } 50 | if op&Chmod == Chmod { 51 | buffer.WriteString("|CHMOD") 52 | } 53 | if buffer.Len() == 0 { 54 | return "" 55 | } 56 | return buffer.String()[1:] // Strip leading pipe 57 | } 58 | 59 | // String returns a string representation of the event in the form 60 | // "file: REMOVE|WRITE|..." 61 | func (e Event) String() string { 62 | return fmt.Sprintf("%q: %s", e.Name, e.Op.String()) 63 | } 64 | 65 | // Common errors that can be reported by a watcher 66 | var ErrEventOverflow = errors.New("fsnotify queue overflow") 67 | -------------------------------------------------------------------------------- /vendor/github.com/fsnotify/fsnotify/open_mode_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 freebsd openbsd netbsd dragonfly 6 | 7 | package fsnotify 8 | 9 | import "golang.org/x/sys/unix" 10 | 11 | const openMode = unix.O_NONBLOCK | unix.O_RDONLY 12 | -------------------------------------------------------------------------------- /vendor/github.com/fsnotify/fsnotify/open_mode_darwin.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 6 | 7 | package fsnotify 8 | 9 | import "golang.org/x/sys/unix" 10 | 11 | // note: this constant is not defined on BSD 12 | const openMode = unix.O_EVTONLY 13 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/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-runewidth/README.mkd: -------------------------------------------------------------------------------- 1 | go-runewidth 2 | ============ 3 | 4 | [![Build Status](https://travis-ci.org/mattn/go-runewidth.png?branch=master)](https://travis-ci.org/mattn/go-runewidth) 5 | [![Coverage Status](https://coveralls.io/repos/mattn/go-runewidth/badge.png?branch=HEAD)](https://coveralls.io/r/mattn/go-runewidth?branch=HEAD) 6 | [![GoDoc](https://godoc.org/github.com/mattn/go-runewidth?status.svg)](http://godoc.org/github.com/mattn/go-runewidth) 7 | [![Go Report Card](https://goreportcard.com/badge/github.com/mattn/go-runewidth)](https://goreportcard.com/report/github.com/mattn/go-runewidth) 8 | 9 | Provides functions to get fixed width of the character or string. 10 | 11 | Usage 12 | ----- 13 | 14 | ```go 15 | runewidth.StringWidth("つのだ☆HIRO") == 12 16 | ``` 17 | 18 | 19 | Author 20 | ------ 21 | 22 | Yasuhiro Matsumoto 23 | 24 | License 25 | ------- 26 | 27 | under the MIT License: http://mattn.mit-license.org/2013 28 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/runewidth_js.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package runewidth 4 | 5 | func IsEastAsian() bool { 6 | // TODO: Implement this for the web. Detect east asian in a compatible way, and return true. 7 | return false 8 | } 9 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/runewidth_posix.go: -------------------------------------------------------------------------------- 1 | // +build !windows,!js 2 | 3 | package runewidth 4 | 5 | import ( 6 | "os" 7 | "regexp" 8 | "strings" 9 | ) 10 | 11 | var reLoc = regexp.MustCompile(`^[a-z][a-z][a-z]?(?:_[A-Z][A-Z])?\.(.+)`) 12 | 13 | var mblenTable = map[string]int{ 14 | "utf-8": 6, 15 | "utf8": 6, 16 | "jis": 8, 17 | "eucjp": 3, 18 | "euckr": 2, 19 | "euccn": 2, 20 | "sjis": 2, 21 | "cp932": 2, 22 | "cp51932": 2, 23 | "cp936": 2, 24 | "cp949": 2, 25 | "cp950": 2, 26 | "big5": 2, 27 | "gbk": 2, 28 | "gb2312": 2, 29 | } 30 | 31 | func isEastAsian(locale string) bool { 32 | charset := strings.ToLower(locale) 33 | r := reLoc.FindStringSubmatch(locale) 34 | if len(r) == 2 { 35 | charset = strings.ToLower(r[1]) 36 | } 37 | 38 | if strings.HasSuffix(charset, "@cjk_narrow") { 39 | return false 40 | } 41 | 42 | for pos, b := range []byte(charset) { 43 | if b == '@' { 44 | charset = charset[:pos] 45 | break 46 | } 47 | } 48 | max := 1 49 | if m, ok := mblenTable[charset]; ok { 50 | max = m 51 | } 52 | if max > 1 && (charset[0] != 'u' || 53 | strings.HasPrefix(locale, "ja") || 54 | strings.HasPrefix(locale, "ko") || 55 | strings.HasPrefix(locale, "zh")) { 56 | return true 57 | } 58 | return false 59 | } 60 | 61 | // IsEastAsian return true if the current locale is CJK 62 | func IsEastAsian() bool { 63 | locale := os.Getenv("LC_CTYPE") 64 | if locale == "" { 65 | locale = os.Getenv("LANG") 66 | } 67 | 68 | // ignore C locale 69 | if locale == "POSIX" || locale == "C" { 70 | return false 71 | } 72 | if len(locale) > 1 && locale[0] == 'C' && (locale[1] == '.' || locale[1] == '-') { 73 | return false 74 | } 75 | 76 | return isEastAsian(locale) 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/mattn/go-runewidth/runewidth_windows.go: -------------------------------------------------------------------------------- 1 | package runewidth 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | var ( 8 | kernel32 = syscall.NewLazyDLL("kernel32") 9 | procGetConsoleOutputCP = kernel32.NewProc("GetConsoleOutputCP") 10 | ) 11 | 12 | // IsEastAsian return true if the current locale is CJK 13 | func IsEastAsian() bool { 14 | r1, _, _ := procGetConsoleOutputCP.Call() 15 | if r1 == 0 { 16 | return false 17 | } 18 | 19 | switch int(r1) { 20 | case 932, 51932, 936, 949, 950: 21 | return true 22 | } 23 | 24 | return false 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.9.x 5 | - 1.10.x 6 | - 1.11.x 7 | - tip 8 | 9 | script: 10 | - go vet ./... 11 | - go test -timeout 1h ./... 12 | - go test -timeout 30m -race -run "TestDB_(Concurrent|GoleveldbIssue74)" ./leveldb 13 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2012 Suryandaru Triandana 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the 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 | HOLDER 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/syndtr/goleveldb/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/syndtr/goleveldb 2 | 3 | go 1.14 4 | 5 | require ( 6 | github.com/golang/snappy v0.0.1 7 | github.com/onsi/ginkgo v1.7.0 8 | github.com/onsi/gomega v1.4.3 9 | ) 10 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/leveldb/cache/bench_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | package cache 8 | 9 | import ( 10 | "math/rand" 11 | "testing" 12 | "time" 13 | ) 14 | 15 | func BenchmarkLRUCache(b *testing.B) { 16 | c := NewCache(NewLRU(10000)) 17 | 18 | b.SetParallelism(10) 19 | b.RunParallel(func(pb *testing.PB) { 20 | r := rand.New(rand.NewSource(time.Now().UnixNano())) 21 | 22 | for pb.Next() { 23 | key := uint64(r.Intn(1000000)) 24 | c.Get(0, key, func() (int, Value) { 25 | return 1, key 26 | }).Release() 27 | } 28 | }) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/leveldb/comparer.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | package leveldb 8 | 9 | import ( 10 | "github.com/syndtr/goleveldb/leveldb/comparer" 11 | ) 12 | 13 | type iComparer struct { 14 | ucmp comparer.Comparer 15 | } 16 | 17 | func (icmp *iComparer) uName() string { 18 | return icmp.ucmp.Name() 19 | } 20 | 21 | func (icmp *iComparer) uCompare(a, b []byte) int { 22 | return icmp.ucmp.Compare(a, b) 23 | } 24 | 25 | func (icmp *iComparer) uSeparator(dst, a, b []byte) []byte { 26 | return icmp.ucmp.Separator(dst, a, b) 27 | } 28 | 29 | func (icmp *iComparer) uSuccessor(dst, b []byte) []byte { 30 | return icmp.ucmp.Successor(dst, b) 31 | } 32 | 33 | func (icmp *iComparer) Name() string { 34 | return icmp.uName() 35 | } 36 | 37 | func (icmp *iComparer) Compare(a, b []byte) int { 38 | x := icmp.uCompare(internalKey(a).ukey(), internalKey(b).ukey()) 39 | if x == 0 { 40 | if m, n := internalKey(a).num(), internalKey(b).num(); m > n { 41 | return -1 42 | } else if m < n { 43 | return 1 44 | } 45 | } 46 | return x 47 | } 48 | 49 | func (icmp *iComparer) Separator(dst, a, b []byte) []byte { 50 | ua, ub := internalKey(a).ukey(), internalKey(b).ukey() 51 | dst = icmp.uSeparator(dst, ua, ub) 52 | if dst != nil && len(dst) < len(ua) && icmp.uCompare(ua, dst) < 0 { 53 | // Append earliest possible number. 54 | return append(dst, keyMaxNumBytes...) 55 | } 56 | return nil 57 | } 58 | 59 | func (icmp *iComparer) Successor(dst, b []byte) []byte { 60 | ub := internalKey(b).ukey() 61 | dst = icmp.uSuccessor(dst, ub) 62 | if dst != nil && len(dst) < len(ub) && icmp.uCompare(ub, dst) < 0 { 63 | // Append earliest possible number. 64 | return append(dst, keyMaxNumBytes...) 65 | } 66 | return nil 67 | } 68 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/leveldb/comparer/bytes_comparer.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | package comparer 8 | 9 | import "bytes" 10 | 11 | type bytesComparer struct{} 12 | 13 | func (bytesComparer) Compare(a, b []byte) int { 14 | return bytes.Compare(a, b) 15 | } 16 | 17 | func (bytesComparer) Name() string { 18 | return "leveldb.BytewiseComparator" 19 | } 20 | 21 | func (bytesComparer) Separator(dst, a, b []byte) []byte { 22 | i, n := 0, len(a) 23 | if n > len(b) { 24 | n = len(b) 25 | } 26 | for ; i < n && a[i] == b[i]; i++ { 27 | } 28 | if i >= n { 29 | // Do not shorten if one string is a prefix of the other 30 | } else if c := a[i]; c < 0xff && c+1 < b[i] { 31 | dst = append(dst, a[:i+1]...) 32 | dst[len(dst)-1]++ 33 | return dst 34 | } 35 | return nil 36 | } 37 | 38 | func (bytesComparer) Successor(dst, b []byte) []byte { 39 | for i, c := range b { 40 | if c != 0xff { 41 | dst = append(dst, b[:i+1]...) 42 | dst[len(dst)-1]++ 43 | return dst 44 | } 45 | } 46 | return nil 47 | } 48 | 49 | // DefaultComparer are default implementation of the Comparer interface. 50 | // It uses the natural ordering, consistent with bytes.Compare. 51 | var DefaultComparer = bytesComparer{} 52 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/leveldb/errors.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | package leveldb 8 | 9 | import ( 10 | "github.com/syndtr/goleveldb/leveldb/errors" 11 | ) 12 | 13 | // Common errors. 14 | var ( 15 | ErrNotFound = errors.ErrNotFound 16 | ErrReadOnly = errors.New("leveldb: read-only mode") 17 | ErrSnapshotReleased = errors.New("leveldb: snapshot released") 18 | ErrIterReleased = errors.New("leveldb: iterator released") 19 | ErrClosed = errors.New("leveldb: closed") 20 | ) 21 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/leveldb/filter.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | package leveldb 8 | 9 | import ( 10 | "github.com/syndtr/goleveldb/leveldb/filter" 11 | ) 12 | 13 | type iFilter struct { 14 | filter.Filter 15 | } 16 | 17 | func (f iFilter) Contains(filter, key []byte) bool { 18 | return f.Filter.Contains(filter, internalKey(key).ukey()) 19 | } 20 | 21 | func (f iFilter) NewGenerator() filter.FilterGenerator { 22 | return iFilterGenerator{f.Filter.NewGenerator()} 23 | } 24 | 25 | type iFilterGenerator struct { 26 | filter.FilterGenerator 27 | } 28 | 29 | func (g iFilterGenerator) Add(key []byte) { 30 | g.FilterGenerator.Add(internalKey(key).ukey()) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/leveldb/iterator/array_iter_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | package iterator_test 8 | 9 | import ( 10 | . "github.com/onsi/ginkgo" 11 | 12 | . "github.com/syndtr/goleveldb/leveldb/iterator" 13 | "github.com/syndtr/goleveldb/leveldb/testutil" 14 | ) 15 | 16 | var _ = testutil.Defer(func() { 17 | Describe("Array iterator", func() { 18 | It("Should iterates and seeks correctly", func() { 19 | // Build key/value. 20 | kv := testutil.KeyValue_Generate(nil, 70, 1, 1, 5, 3, 3) 21 | 22 | // Test the iterator. 23 | t := testutil.IteratorTesting{ 24 | KeyValue: kv.Clone(), 25 | Iter: NewArrayIterator(kv), 26 | } 27 | testutil.DoIteratorTesting(&t) 28 | }) 29 | }) 30 | }) 31 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/leveldb/iterator/iter_suite_test.go: -------------------------------------------------------------------------------- 1 | package iterator_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/syndtr/goleveldb/leveldb/testutil" 7 | ) 8 | 9 | func TestIterator(t *testing.T) { 10 | testutil.RunSuite(t, "Iterator Suite") 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/leveldb/leveldb_suite_test.go: -------------------------------------------------------------------------------- 1 | package leveldb 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/syndtr/goleveldb/leveldb/testutil" 7 | ) 8 | 9 | func TestLevelDB(t *testing.T) { 10 | testutil.RunSuite(t, "LevelDB Suite") 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/leveldb/memdb/bench_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | package memdb 8 | 9 | import ( 10 | "encoding/binary" 11 | "math/rand" 12 | "testing" 13 | 14 | "github.com/syndtr/goleveldb/leveldb/comparer" 15 | ) 16 | 17 | func BenchmarkPut(b *testing.B) { 18 | buf := make([][4]byte, b.N) 19 | for i := range buf { 20 | binary.LittleEndian.PutUint32(buf[i][:], uint32(i)) 21 | } 22 | 23 | b.ResetTimer() 24 | p := New(comparer.DefaultComparer, 0) 25 | for i := range buf { 26 | p.Put(buf[i][:], nil) 27 | } 28 | } 29 | 30 | func BenchmarkPutRandom(b *testing.B) { 31 | buf := make([][4]byte, b.N) 32 | for i := range buf { 33 | binary.LittleEndian.PutUint32(buf[i][:], uint32(rand.Int())) 34 | } 35 | 36 | b.ResetTimer() 37 | p := New(comparer.DefaultComparer, 0) 38 | for i := range buf { 39 | p.Put(buf[i][:], nil) 40 | } 41 | } 42 | 43 | func BenchmarkGet(b *testing.B) { 44 | buf := make([][4]byte, b.N) 45 | for i := range buf { 46 | binary.LittleEndian.PutUint32(buf[i][:], uint32(i)) 47 | } 48 | 49 | p := New(comparer.DefaultComparer, 0) 50 | for i := range buf { 51 | p.Put(buf[i][:], nil) 52 | } 53 | 54 | b.ResetTimer() 55 | for i := range buf { 56 | p.Get(buf[i][:]) 57 | } 58 | } 59 | 60 | func BenchmarkGetRandom(b *testing.B) { 61 | buf := make([][4]byte, b.N) 62 | for i := range buf { 63 | binary.LittleEndian.PutUint32(buf[i][:], uint32(i)) 64 | } 65 | 66 | p := New(comparer.DefaultComparer, 0) 67 | for i := range buf { 68 | p.Put(buf[i][:], nil) 69 | } 70 | 71 | b.ResetTimer() 72 | for i := 0; i < b.N; i++ { 73 | p.Get(buf[rand.Int()%b.N][:]) 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/leveldb/memdb/memdb_suite_test.go: -------------------------------------------------------------------------------- 1 | package memdb 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/syndtr/goleveldb/leveldb/testutil" 7 | ) 8 | 9 | func TestMemDB(t *testing.T) { 10 | testutil.RunSuite(t, "MemDB Suite") 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/leveldb/session_record_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | package leveldb 8 | 9 | import ( 10 | "bytes" 11 | "testing" 12 | ) 13 | 14 | func decodeEncode(v *sessionRecord) (res bool, err error) { 15 | b := new(bytes.Buffer) 16 | err = v.encode(b) 17 | if err != nil { 18 | return 19 | } 20 | v2 := &sessionRecord{} 21 | err = v.decode(b) 22 | if err != nil { 23 | return 24 | } 25 | b2 := new(bytes.Buffer) 26 | err = v2.encode(b2) 27 | if err != nil { 28 | return 29 | } 30 | return bytes.Equal(b.Bytes(), b2.Bytes()), nil 31 | } 32 | 33 | func TestSessionRecord_EncodeDecode(t *testing.T) { 34 | big := int64(1) << 50 35 | v := &sessionRecord{} 36 | i := int64(0) 37 | test := func() { 38 | res, err := decodeEncode(v) 39 | if err != nil { 40 | t.Fatalf("error when testing encode/decode sessionRecord: %v", err) 41 | } 42 | if !res { 43 | t.Error("encode/decode test failed at iteration:", i) 44 | } 45 | } 46 | 47 | for ; i < 4; i++ { 48 | test() 49 | v.addTable(3, big+300+i, big+400+i, 50 | makeInternalKey(nil, []byte("foo"), uint64(big+500+1), keyTypeVal), 51 | makeInternalKey(nil, []byte("zoo"), uint64(big+600+1), keyTypeDel)) 52 | v.delTable(4, big+700+i) 53 | v.addCompPtr(int(i), makeInternalKey(nil, []byte("x"), uint64(big+900+1), keyTypeVal)) 54 | } 55 | 56 | v.setComparer("foo") 57 | v.setJournalNum(big + 100) 58 | v.setPrevJournalNum(big + 99) 59 | v.setNextFileNum(big + 200) 60 | v.setSeqNum(uint64(big + 1000)) 61 | test() 62 | } 63 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/leveldb/storage.go: -------------------------------------------------------------------------------- 1 | package leveldb 2 | 3 | import ( 4 | "github.com/syndtr/goleveldb/leveldb/storage" 5 | "sync/atomic" 6 | ) 7 | 8 | type iStorage struct { 9 | storage.Storage 10 | read uint64 11 | write uint64 12 | } 13 | 14 | func (c *iStorage) Open(fd storage.FileDesc) (storage.Reader, error) { 15 | r, err := c.Storage.Open(fd) 16 | return &iStorageReader{r, c}, err 17 | } 18 | 19 | func (c *iStorage) Create(fd storage.FileDesc) (storage.Writer, error) { 20 | w, err := c.Storage.Create(fd) 21 | return &iStorageWriter{w, c}, err 22 | } 23 | 24 | func (c *iStorage) reads() uint64 { 25 | return atomic.LoadUint64(&c.read) 26 | } 27 | 28 | func (c *iStorage) writes() uint64 { 29 | return atomic.LoadUint64(&c.write) 30 | } 31 | 32 | // newIStorage returns the given storage wrapped by iStorage. 33 | func newIStorage(s storage.Storage) *iStorage { 34 | return &iStorage{s, 0, 0} 35 | } 36 | 37 | type iStorageReader struct { 38 | storage.Reader 39 | c *iStorage 40 | } 41 | 42 | func (r *iStorageReader) Read(p []byte) (n int, err error) { 43 | n, err = r.Reader.Read(p) 44 | atomic.AddUint64(&r.c.read, uint64(n)) 45 | return n, err 46 | } 47 | 48 | func (r *iStorageReader) ReadAt(p []byte, off int64) (n int, err error) { 49 | n, err = r.Reader.ReadAt(p, off) 50 | atomic.AddUint64(&r.c.read, uint64(n)) 51 | return n, err 52 | } 53 | 54 | type iStorageWriter struct { 55 | storage.Writer 56 | c *iStorage 57 | } 58 | 59 | func (w *iStorageWriter) Write(p []byte) (n int, err error) { 60 | n, err = w.Writer.Write(p) 61 | atomic.AddUint64(&w.c.write, uint64(n)) 62 | return n, err 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_nacl.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | // +build nacl 8 | 9 | package storage 10 | 11 | import ( 12 | "os" 13 | "syscall" 14 | ) 15 | 16 | func newFileLock(path string, readOnly bool) (fl fileLock, err error) { 17 | return nil, syscall.ENOTSUP 18 | } 19 | 20 | func setFileLock(f *os.File, readOnly, lock bool) error { 21 | return syscall.ENOTSUP 22 | } 23 | 24 | func rename(oldpath, newpath string) error { 25 | return syscall.ENOTSUP 26 | } 27 | 28 | func isErrInvalid(err error) bool { 29 | return false 30 | } 31 | 32 | func syncDir(name string) error { 33 | return syscall.ENOTSUP 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_plan9.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | package storage 8 | 9 | import ( 10 | "os" 11 | ) 12 | 13 | type plan9FileLock struct { 14 | f *os.File 15 | } 16 | 17 | func (fl *plan9FileLock) release() error { 18 | return fl.f.Close() 19 | } 20 | 21 | func newFileLock(path string, readOnly bool) (fl fileLock, err error) { 22 | var ( 23 | flag int 24 | perm os.FileMode 25 | ) 26 | if readOnly { 27 | flag = os.O_RDONLY 28 | } else { 29 | flag = os.O_RDWR 30 | perm = os.ModeExclusive 31 | } 32 | f, err := os.OpenFile(path, flag, perm) 33 | if os.IsNotExist(err) { 34 | f, err = os.OpenFile(path, flag|os.O_CREATE, perm|0644) 35 | } 36 | if err != nil { 37 | return 38 | } 39 | fl = &plan9FileLock{f: f} 40 | return 41 | } 42 | 43 | func rename(oldpath, newpath string) error { 44 | if _, err := os.Stat(newpath); err == nil { 45 | if err := os.Remove(newpath); err != nil { 46 | return err 47 | } 48 | } 49 | 50 | return os.Rename(oldpath, newpath) 51 | } 52 | 53 | func syncDir(name string) error { 54 | f, err := os.Open(name) 55 | if err != nil { 56 | return err 57 | } 58 | defer f.Close() 59 | if err := f.Sync(); err != nil { 60 | return err 61 | } 62 | return nil 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/leveldb/storage/file_storage_solaris.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | // +build solaris 8 | 9 | package storage 10 | 11 | import ( 12 | "os" 13 | "syscall" 14 | ) 15 | 16 | type unixFileLock struct { 17 | f *os.File 18 | } 19 | 20 | func (fl *unixFileLock) release() error { 21 | if err := setFileLock(fl.f, false, false); err != nil { 22 | return err 23 | } 24 | return fl.f.Close() 25 | } 26 | 27 | func newFileLock(path string, readOnly bool) (fl fileLock, err error) { 28 | var flag int 29 | if readOnly { 30 | flag = os.O_RDONLY 31 | } else { 32 | flag = os.O_RDWR 33 | } 34 | f, err := os.OpenFile(path, flag, 0) 35 | if os.IsNotExist(err) { 36 | f, err = os.OpenFile(path, flag|os.O_CREATE, 0644) 37 | } 38 | if err != nil { 39 | return 40 | } 41 | err = setFileLock(f, readOnly, true) 42 | if err != nil { 43 | f.Close() 44 | return 45 | } 46 | fl = &unixFileLock{f: f} 47 | return 48 | } 49 | 50 | func setFileLock(f *os.File, readOnly, lock bool) error { 51 | flock := syscall.Flock_t{ 52 | Type: syscall.F_UNLCK, 53 | Start: 0, 54 | Len: 0, 55 | Whence: 1, 56 | } 57 | if lock { 58 | if readOnly { 59 | flock.Type = syscall.F_RDLCK 60 | } else { 61 | flock.Type = syscall.F_WRLCK 62 | } 63 | } 64 | return syscall.FcntlFlock(f.Fd(), syscall.F_SETLK, &flock) 65 | } 66 | 67 | func rename(oldpath, newpath string) error { 68 | return os.Rename(oldpath, newpath) 69 | } 70 | 71 | func syncDir(name string) error { 72 | f, err := os.Open(name) 73 | if err != nil { 74 | return err 75 | } 76 | defer f.Close() 77 | if err := f.Sync(); err != nil { 78 | return err 79 | } 80 | return nil 81 | } 82 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/leveldb/table/table_suite_test.go: -------------------------------------------------------------------------------- 1 | package table 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/syndtr/goleveldb/leveldb/testutil" 7 | ) 8 | 9 | func TestTable(t *testing.T) { 10 | testutil.RunSuite(t, "Table Suite") 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/leveldb/testutil/ginkgo.go: -------------------------------------------------------------------------------- 1 | package testutil 2 | 3 | import ( 4 | . "github.com/onsi/ginkgo" 5 | . "github.com/onsi/gomega" 6 | ) 7 | 8 | func RunSuite(t GinkgoTestingT, name string) { 9 | RunDefer() 10 | 11 | SynchronizedBeforeSuite(func() []byte { 12 | RunDefer("setup") 13 | return nil 14 | }, func(data []byte) {}) 15 | SynchronizedAfterSuite(func() { 16 | RunDefer("teardown") 17 | }, func() {}) 18 | 19 | RegisterFailHandler(Fail) 20 | RunSpecs(t, name) 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/leveldb/util/crc32.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The LevelDB-Go Authors. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style license that can be 4 | // found in the LICENSE file. 5 | 6 | package util 7 | 8 | import ( 9 | "hash/crc32" 10 | ) 11 | 12 | var table = crc32.MakeTable(crc32.Castagnoli) 13 | 14 | // CRC is a CRC-32 checksum computed using Castagnoli's polynomial. 15 | type CRC uint32 16 | 17 | // NewCRC creates a new crc based on the given bytes. 18 | func NewCRC(b []byte) CRC { 19 | return CRC(0).Update(b) 20 | } 21 | 22 | // Update updates the crc with the given bytes. 23 | func (c CRC) Update(b []byte) CRC { 24 | return CRC(crc32.Update(uint32(c), table, b)) 25 | } 26 | 27 | // Value returns a masked crc. 28 | func (c CRC) Value() uint32 { 29 | return uint32(c>>15|c<<17) + 0xa282ead8 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/leveldb/util/hash.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | package util 8 | 9 | import ( 10 | "encoding/binary" 11 | ) 12 | 13 | // Hash return hash of the given data. 14 | func Hash(data []byte, seed uint32) uint32 { 15 | // Similar to murmur hash 16 | const ( 17 | m = uint32(0xc6a4a793) 18 | r = uint32(24) 19 | ) 20 | var ( 21 | h = seed ^ (uint32(len(data)) * m) 22 | i int 23 | ) 24 | 25 | for n := len(data) - len(data)%4; i < n; i += 4 { 26 | h += binary.LittleEndian.Uint32(data[i:]) 27 | h *= m 28 | h ^= (h >> 16) 29 | } 30 | 31 | switch len(data) - i { 32 | default: 33 | panic("not reached") 34 | case 3: 35 | h += uint32(data[i+2]) << 16 36 | fallthrough 37 | case 2: 38 | h += uint32(data[i+1]) << 8 39 | fallthrough 40 | case 1: 41 | h += uint32(data[i]) 42 | h *= m 43 | h ^= (h >> r) 44 | case 0: 45 | } 46 | 47 | return h 48 | } 49 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/leveldb/util/hash_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | package util 8 | 9 | import ( 10 | "testing" 11 | ) 12 | 13 | var hashTests = []struct { 14 | data []byte 15 | seed uint32 16 | hash uint32 17 | }{ 18 | {nil, 0xbc9f1d34, 0xbc9f1d34}, 19 | {[]byte{0x62}, 0xbc9f1d34, 0xef1345c4}, 20 | {[]byte{0xc3, 0x97}, 0xbc9f1d34, 0x5b663814}, 21 | {[]byte{0xe2, 0x99, 0xa5}, 0xbc9f1d34, 0x323c078f}, 22 | {[]byte{0xe1, 0x80, 0xb9, 0x32}, 0xbc9f1d34, 0xed21633a}, 23 | {[]byte{ 24 | 0x01, 0xc0, 0x00, 0x00, 25 | 0x00, 0x00, 0x00, 0x00, 26 | 0x00, 0x00, 0x00, 0x00, 27 | 0x00, 0x00, 0x00, 0x00, 28 | 0x14, 0x00, 0x00, 0x00, 29 | 0x00, 0x00, 0x04, 0x00, 30 | 0x00, 0x00, 0x00, 0x14, 31 | 0x00, 0x00, 0x00, 0x18, 32 | 0x28, 0x00, 0x00, 0x00, 33 | 0x00, 0x00, 0x00, 0x00, 34 | 0x02, 0x00, 0x00, 0x00, 35 | 0x00, 0x00, 0x00, 0x00, 36 | }, 0x12345678, 0xf333dabb}, 37 | } 38 | 39 | func TestHash(t *testing.T) { 40 | for i, x := range hashTests { 41 | h := Hash(x.data, x.seed) 42 | if h != x.hash { 43 | t.Fatalf("test-%d: invalid hash, %#x vs %#x", i, h, x.hash) 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/syndtr/goleveldb/leveldb/util/range.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2014, Suryandaru Triandana 2 | // All rights reserved. 3 | // 4 | // Use of this source code is governed by a BSD-style license that can be 5 | // found in the LICENSE file. 6 | 7 | package util 8 | 9 | // Range is a key range. 10 | type Range struct { 11 | // Start of the key range, include in the range. 12 | Start []byte 13 | 14 | // Limit of the key range, not include in the range. 15 | Limit []byte 16 | } 17 | 18 | // BytesPrefix returns key range that satisfy the given prefix. 19 | // This only applicable for the standard 'bytes comparer'. 20 | func BytesPrefix(prefix []byte) *Range { 21 | var limit []byte 22 | for i := len(prefix) - 1; i >= 0; i-- { 23 | c := prefix[i] 24 | if c < 0xff { 25 | limit = make([]byte, i+1) 26 | copy(limit, prefix) 27 | limit[i] = c + 1 28 | break 29 | } 30 | } 31 | return &Range{prefix, limit} 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/tealeg/xlsx/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2011-2017, Geoffrey J. Teale 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /vendor/github.com/tealeg/xlsx/col.go: -------------------------------------------------------------------------------- 1 | package xlsx 2 | 3 | // Default column width in excel 4 | const ColWidth = 9.5 5 | 6 | type Col struct { 7 | Min int 8 | Max int 9 | Hidden bool 10 | Width float64 11 | Collapsed bool 12 | OutlineLevel uint8 13 | numFmt string 14 | parsedNumFmt *parsedNumberFormat 15 | style *Style 16 | } 17 | 18 | // SetType will set the format string of a column based on the type that you want to set it to. 19 | // This function does not really make a lot of sense. 20 | func (c *Col) SetType(cellType CellType) { 21 | switch cellType { 22 | case CellTypeString: 23 | c.numFmt = builtInNumFmt[builtInNumFmtIndex_STRING] 24 | case CellTypeNumeric: 25 | c.numFmt = builtInNumFmt[builtInNumFmtIndex_INT] 26 | case CellTypeBool: 27 | c.numFmt = builtInNumFmt[builtInNumFmtIndex_GENERAL] //TEMP 28 | case CellTypeInline: 29 | c.numFmt = builtInNumFmt[builtInNumFmtIndex_STRING] 30 | case CellTypeError: 31 | c.numFmt = builtInNumFmt[builtInNumFmtIndex_GENERAL] //TEMP 32 | case CellTypeDate: 33 | // Cells that are stored as dates are not properly supported in this library. 34 | // They should instead be stored as a Numeric with a date format. 35 | c.numFmt = builtInNumFmt[builtInNumFmtIndex_GENERAL] 36 | case CellTypeStringFormula: 37 | c.numFmt = builtInNumFmt[builtInNumFmtIndex_STRING] 38 | } 39 | } 40 | 41 | // GetStyle returns the Style associated with a Col 42 | func (c *Col) GetStyle() *Style { 43 | return c.style 44 | } 45 | 46 | // SetStyle sets the style of a Col 47 | func (c *Col) SetStyle(style *Style) { 48 | c.style = style 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/tealeg/xlsx/doc.go: -------------------------------------------------------------------------------- 1 | // xslx is a package designed to help with reading data from 2 | // spreadsheets stored in the XLSX format used in recent versions of 3 | // Microsoft's Excel spreadsheet. 4 | // 5 | // Additionally, xlsx has started to grow some XLSX authoring 6 | // capabilities too. 7 | // 8 | // For a concise example of how to use this library why not check out 9 | // the source for xlsx2csv here: https://github.com/tealeg/xlsx2csv 10 | 11 | package xlsx 12 | -------------------------------------------------------------------------------- /vendor/github.com/tealeg/xlsx/row.go: -------------------------------------------------------------------------------- 1 | package xlsx 2 | 3 | type Row struct { 4 | Cells []*Cell 5 | Hidden bool 6 | Sheet *Sheet 7 | Height float64 8 | OutlineLevel uint8 9 | isCustom bool 10 | } 11 | 12 | func (r *Row) SetHeight(ht float64) { 13 | r.Height = ht 14 | r.isCustom = true 15 | } 16 | 17 | func (r *Row) SetHeightCM(ht float64) { 18 | r.Height = ht * 28.3464567 // Convert CM to postscript points 19 | r.isCustom = true 20 | } 21 | 22 | func (r *Row) AddCell() *Cell { 23 | cell := NewCell(r) 24 | r.Cells = append(r.Cells, cell) 25 | r.Sheet.maybeAddCol(len(r.Cells)) 26 | return cell 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/tealeg/xlsx/theme.go: -------------------------------------------------------------------------------- 1 | package xlsx 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | type theme struct { 9 | colors []string 10 | } 11 | 12 | func newTheme(themeXml xlsxTheme) *theme { 13 | clrMap := map[string]string{} 14 | clrSchemes := themeXml.ThemeElements.ClrScheme.Children 15 | for _, scheme := range clrSchemes { 16 | var rgbColor string 17 | if scheme.SysClr != nil { 18 | rgbColor = scheme.SysClr.LastClr 19 | } else { 20 | rgbColor = scheme.SrgbClr.Val 21 | } 22 | clrMap[scheme.XMLName.Local] = rgbColor 23 | } 24 | colors := []string{clrMap["lt1"], clrMap["dk1"], clrMap["lt2"], clrMap["dk2"], clrMap["accent1"], 25 | clrMap["accent2"], clrMap["accent3"], clrMap["accent4"], clrMap["accent5"], 26 | clrMap["accent6"], clrMap["hlink"], clrMap["folHlink"]} 27 | return &theme{colors} 28 | } 29 | 30 | func (t *theme) themeColor(index int64, tint float64) string { 31 | baseColor := t.colors[index] 32 | if tint == 0 { 33 | return "FF" + baseColor 34 | } else { 35 | r, _ := strconv.ParseInt(baseColor[0:2], 16, 64) 36 | g, _ := strconv.ParseInt(baseColor[2:4], 16, 64) 37 | b, _ := strconv.ParseInt(baseColor[4:6], 16, 64) 38 | h, s, l := RGBToHSL(uint8(r), uint8(g), uint8(b)) 39 | if tint < 0 { 40 | l *= (1 + tint) 41 | } else { 42 | l = l*(1-tint) + (1 - (1 - tint)) 43 | } 44 | br, bg, bb := HSLToRGB(h, s, l) 45 | return fmt.Sprintf("FF%02X%02X%02X", br, bg, bb) 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/tealeg/xlsx/xmlSharedStrings.go: -------------------------------------------------------------------------------- 1 | package xlsx 2 | 3 | import ( 4 | "encoding/xml" 5 | ) 6 | 7 | // xlsxSST directly maps the sst element from the namespace 8 | // http://schemas.openxmlformats.org/spreadsheetml/2006/main currently 9 | // I have not checked this for completeness - it does as much as I need. 10 | type xlsxSST struct { 11 | XMLName xml.Name `xml:"http://schemas.openxmlformats.org/spreadsheetml/2006/main sst"` 12 | Count int `xml:"count,attr"` 13 | UniqueCount int `xml:"uniqueCount,attr"` 14 | SI []xlsxSI `xml:"si"` 15 | } 16 | 17 | // xlsxSI directly maps the si element from the namespace 18 | // http://schemas.openxmlformats.org/spreadsheetml/2006/main - 19 | // currently I have not checked this for completeness - it does as 20 | // much as I need. 21 | type xlsxSI struct { 22 | T string `xml:"t"` 23 | R []xlsxR `xml:"r"` 24 | } 25 | 26 | // xlsxR directly maps the r element from the namespace 27 | // http://schemas.openxmlformats.org/spreadsheetml/2006/main - 28 | // currently I have not checked this for completeness - it does as 29 | // much as I need. 30 | type xlsxR struct { 31 | T string `xml:"t"` 32 | } 33 | -------------------------------------------------------------------------------- /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/asm.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 | TEXT ·use(SB),NOSPLIT,$0 10 | RET 11 | -------------------------------------------------------------------------------- /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-64 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-64 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/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/mkpost.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 ignore 6 | 7 | // mkpost processes the output of cgo -godefs to 8 | // modify the generated types. It is used to clean up 9 | // the sys API in an architecture specific manner. 10 | // 11 | // mkpost is run after cgo -godefs by mkall.sh. 12 | package main 13 | 14 | import ( 15 | "fmt" 16 | "go/format" 17 | "io/ioutil" 18 | "log" 19 | "os" 20 | "regexp" 21 | ) 22 | 23 | func main() { 24 | b, err := ioutil.ReadAll(os.Stdin) 25 | if err != nil { 26 | log.Fatal(err) 27 | } 28 | s := string(b) 29 | 30 | goarch := os.Getenv("GOARCH") 31 | goos := os.Getenv("GOOS") 32 | if goarch == "s390x" && goos == "linux" { 33 | // Export the types of PtraceRegs fields. 34 | re := regexp.MustCompile("ptrace(Psw|Fpregs|Per)") 35 | s = re.ReplaceAllString(s, "Ptrace$1") 36 | 37 | // Replace padding fields inserted by cgo with blank identifiers. 38 | re = regexp.MustCompile("Pad_cgo[A-Za-z0-9_]*") 39 | s = re.ReplaceAllString(s, "_") 40 | 41 | // Replace other unwanted fields with blank identifiers. 42 | re = regexp.MustCompile("X_[A-Za-z0-9_]*") 43 | s = re.ReplaceAllString(s, "_") 44 | 45 | // Replace the control_regs union with a blank identifier for now. 46 | re = regexp.MustCompile("(Control_regs)\\s+\\[0\\]uint64") 47 | s = re.ReplaceAllString(s, "_ [0]uint64") 48 | } 49 | 50 | // gofmt 51 | b, err = format.Source([]byte(s)) 52 | if err != nil { 53 | log.Fatal(err) 54 | } 55 | 56 | // Append this command to the header to show where the new file 57 | // came from. 58 | re := regexp.MustCompile("(cgo -godefs [a-zA-Z0-9_]+\\.go.*)") 59 | b = re.ReplaceAll(b, []byte("$1 | go run mkpost.go")) 60 | 61 | fmt.Printf("%s", b) 62 | } 63 | -------------------------------------------------------------------------------- /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 < 999){ 31 | # ignore deprecated syscalls that are no longer implemented 32 | # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716 33 | return; 34 | } 35 | $name =~ y/a-z/A-Z/; 36 | $num = $num + $offset; 37 | print " SYS_$name = $num;\n"; 38 | } 39 | 40 | my $prev; 41 | open(GCC, "gcc -E -dD $ARGV[0] |") || die "can't run gcc"; 42 | while(){ 43 | if(/^#define __NR_Linux\s+([0-9]+)/){ 44 | # mips/mips64: extract offset 45 | $offset = $1; 46 | } 47 | elsif(/^#define __NR_syscalls\s+/) { 48 | # ignore redefinitions of __NR_syscalls 49 | } 50 | elsif(/^#define __NR_(\w+)\s+([0-9]+)/){ 51 | $prev = $2; 52 | fmt($1, $2); 53 | } 54 | elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){ 55 | $prev = $2; 56 | fmt($1, $2); 57 | } 58 | elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){ 59 | fmt($1, $prev+$2) 60 | } 61 | elsif(/^#define __NR_(\w+)\s+\(__NR_Linux \+ ([0-9]+)/){ 62 | fmt($1, $2); 63 | } 64 | } 65 | 66 | 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_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/gopkg.in/flosch/pongo2.v3/AUTHORS: -------------------------------------------------------------------------------- 1 | Main author and maintainer of pongo2: 2 | 3 | * Florian Schlachter 4 | 5 | Contributors (in no specific order): 6 | 7 | * @romanoaugusto88 8 | * @vitalbh 9 | 10 | Feel free to add yourself to the list or to modify your entry if you did a contribution. 11 | -------------------------------------------------------------------------------- /vendor/gopkg.in/flosch/pongo2.v3/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013-2014 Florian Schlachter 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/gopkg.in/flosch/pongo2.v3/doc.go: -------------------------------------------------------------------------------- 1 | // A Django-syntax like template-engine 2 | // 3 | // Blog posts about pongo2 (including introduction and migration): 4 | // https://www.florian-schlachter.de/?tag=pongo2 5 | // 6 | // Complete documentation on the template language: 7 | // https://docs.djangoproject.com/en/dev/topics/templates/ 8 | // 9 | // Try out pongo2 live in the pongo2 playground: 10 | // https://www.florian-schlachter.de/pongo2/ 11 | // 12 | // Make sure to read README.md in the repository as well. 13 | // 14 | // A tiny example with template strings: 15 | // 16 | // (Snippet on playground: https://www.florian-schlachter.de/pongo2/?id=1206546277) 17 | // 18 | // // Compile the template first (i. e. creating the AST) 19 | // tpl, err := pongo2.FromString("Hello {{ name|capfirst }}!") 20 | // if err != nil { 21 | // panic(err) 22 | // } 23 | // // Now you can render the template with the given 24 | // // pongo2.Context how often you want to. 25 | // out, err := tpl.Execute(pongo2.Context{"name": "fred"}) 26 | // if err != nil { 27 | // panic(err) 28 | // } 29 | // fmt.Println(out) // Output: Hello Fred! 30 | // 31 | package pongo2 32 | -------------------------------------------------------------------------------- /vendor/gopkg.in/flosch/pongo2.v3/helpers.go: -------------------------------------------------------------------------------- 1 | package pongo2 2 | 3 | func max(a, b int) int { 4 | if a > b { 5 | return a 6 | } 7 | return b 8 | } 9 | 10 | func min(a, b int) int { 11 | if a < b { 12 | return a 13 | } 14 | return b 15 | } 16 | -------------------------------------------------------------------------------- /vendor/gopkg.in/flosch/pongo2.v3/nodes.go: -------------------------------------------------------------------------------- 1 | package pongo2 2 | 3 | import ( 4 | "bytes" 5 | ) 6 | 7 | // The root document 8 | type nodeDocument struct { 9 | Nodes []INode 10 | } 11 | 12 | func (doc *nodeDocument) Execute(ctx *ExecutionContext, buffer *bytes.Buffer) *Error { 13 | for _, n := range doc.Nodes { 14 | err := n.Execute(ctx, buffer) 15 | if err != nil { 16 | return err 17 | } 18 | } 19 | return nil 20 | } 21 | -------------------------------------------------------------------------------- /vendor/gopkg.in/flosch/pongo2.v3/nodes_html.go: -------------------------------------------------------------------------------- 1 | package pongo2 2 | 3 | import ( 4 | "bytes" 5 | ) 6 | 7 | type nodeHTML struct { 8 | token *Token 9 | } 10 | 11 | func (n *nodeHTML) Execute(ctx *ExecutionContext, buffer *bytes.Buffer) *Error { 12 | buffer.WriteString(n.token.Val) 13 | return nil 14 | } 15 | -------------------------------------------------------------------------------- /vendor/gopkg.in/flosch/pongo2.v3/nodes_wrapper.go: -------------------------------------------------------------------------------- 1 | package pongo2 2 | 3 | import ( 4 | "bytes" 5 | ) 6 | 7 | type NodeWrapper struct { 8 | Endtag string 9 | nodes []INode 10 | } 11 | 12 | func (wrapper *NodeWrapper) Execute(ctx *ExecutionContext, buffer *bytes.Buffer) *Error { 13 | for _, n := range wrapper.nodes { 14 | err := n.Execute(ctx, buffer) 15 | if err != nil { 16 | return err 17 | } 18 | } 19 | return nil 20 | } 21 | -------------------------------------------------------------------------------- /vendor/gopkg.in/flosch/pongo2.v3/parser_document.go: -------------------------------------------------------------------------------- 1 | package pongo2 2 | 3 | // Doc = { ( Filter | Tag | HTML ) } 4 | func (p *Parser) parseDocElement() (INode, *Error) { 5 | t := p.Current() 6 | 7 | switch t.Typ { 8 | case TokenHTML: 9 | p.Consume() // consume HTML element 10 | return &nodeHTML{token: t}, nil 11 | case TokenSymbol: 12 | switch t.Val { 13 | case "{{": 14 | // parse variable 15 | variable, err := p.parseVariableElement() 16 | if err != nil { 17 | return nil, err 18 | } 19 | return variable, nil 20 | case "{%": 21 | // parse tag 22 | tag, err := p.parseTagElement() 23 | if err != nil { 24 | return nil, err 25 | } 26 | return tag, nil 27 | } 28 | } 29 | return nil, p.Error("Unexpected token (only HTML/tags/filters in templates allowed)", t) 30 | } 31 | 32 | func (tpl *Template) parse() *Error { 33 | tpl.parser = newParser(tpl.name, tpl.tokens, tpl) 34 | doc, err := tpl.parser.parseDocument() 35 | if err != nil { 36 | return err 37 | } 38 | tpl.root = doc 39 | return nil 40 | } 41 | 42 | func (p *Parser) parseDocument() (*nodeDocument, *Error) { 43 | doc := &nodeDocument{} 44 | 45 | for p.Remaining() > 0 { 46 | node, err := p.parseDocElement() 47 | if err != nil { 48 | return nil, err 49 | } 50 | doc.Nodes = append(doc.Nodes, node) 51 | } 52 | 53 | return doc, nil 54 | } 55 | -------------------------------------------------------------------------------- /vendor/gopkg.in/flosch/pongo2.v3/pongo2.go: -------------------------------------------------------------------------------- 1 | package pongo2 2 | 3 | // Version string 4 | const Version = "v3" 5 | 6 | // Helper function which panics, if a Template couldn't 7 | // successfully parsed. This is how you would use it: 8 | // var baseTemplate = pongo2.Must(pongo2.FromFile("templates/base.html")) 9 | func Must(tpl *Template, err error) *Template { 10 | if err != nil { 11 | panic(err) 12 | } 13 | return tpl 14 | } 15 | -------------------------------------------------------------------------------- /vendor/gopkg.in/flosch/pongo2.v3/tags_autoescape.go: -------------------------------------------------------------------------------- 1 | package pongo2 2 | 3 | import ( 4 | "bytes" 5 | ) 6 | 7 | type tagAutoescapeNode struct { 8 | wrapper *NodeWrapper 9 | autoescape bool 10 | } 11 | 12 | func (node *tagAutoescapeNode) Execute(ctx *ExecutionContext, buffer *bytes.Buffer) *Error { 13 | old := ctx.Autoescape 14 | ctx.Autoescape = node.autoescape 15 | 16 | err := node.wrapper.Execute(ctx, buffer) 17 | if err != nil { 18 | return err 19 | } 20 | 21 | ctx.Autoescape = old 22 | 23 | return nil 24 | } 25 | 26 | func tagAutoescapeParser(doc *Parser, start *Token, arguments *Parser) (INodeTag, *Error) { 27 | autoescape_node := &tagAutoescapeNode{} 28 | 29 | wrapper, _, err := doc.WrapUntilTag("endautoescape") 30 | if err != nil { 31 | return nil, err 32 | } 33 | autoescape_node.wrapper = wrapper 34 | 35 | mode_token := arguments.MatchType(TokenIdentifier) 36 | if mode_token == nil { 37 | return nil, arguments.Error("A mode is required for autoescape-tag.", nil) 38 | } 39 | if mode_token.Val == "on" { 40 | autoescape_node.autoescape = true 41 | } else if mode_token.Val == "off" { 42 | autoescape_node.autoescape = false 43 | } else { 44 | return nil, arguments.Error("Only 'on' or 'off' is valid as an autoescape-mode.", nil) 45 | } 46 | 47 | if arguments.Remaining() > 0 { 48 | return nil, arguments.Error("Malformed autoescape-tag arguments.", nil) 49 | } 50 | 51 | return autoescape_node, nil 52 | } 53 | 54 | func init() { 55 | RegisterTag("autoescape", tagAutoescapeParser) 56 | } 57 | -------------------------------------------------------------------------------- /vendor/gopkg.in/flosch/pongo2.v3/tags_comment.go: -------------------------------------------------------------------------------- 1 | package pongo2 2 | 3 | import ( 4 | "bytes" 5 | ) 6 | 7 | type tagCommentNode struct{} 8 | 9 | func (node *tagCommentNode) Execute(ctx *ExecutionContext, buffer *bytes.Buffer) *Error { 10 | return nil 11 | } 12 | 13 | func tagCommentParser(doc *Parser, start *Token, arguments *Parser) (INodeTag, *Error) { 14 | comment_node := &tagCommentNode{} 15 | 16 | // TODO: Process the endtag's arguments (see django 'comment'-tag documentation) 17 | _, _, err := doc.WrapUntilTag("endcomment") 18 | if err != nil { 19 | return nil, err 20 | } 21 | 22 | if arguments.Count() != 0 { 23 | return nil, arguments.Error("Tag 'comment' does not take any argument.", nil) 24 | } 25 | 26 | return comment_node, nil 27 | } 28 | 29 | func init() { 30 | RegisterTag("comment", tagCommentParser) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/gopkg.in/flosch/pongo2.v3/tags_extends.go: -------------------------------------------------------------------------------- 1 | package pongo2 2 | 3 | import ( 4 | "bytes" 5 | ) 6 | 7 | type tagExtendsNode struct { 8 | filename string 9 | } 10 | 11 | func (node *tagExtendsNode) Execute(ctx *ExecutionContext, buffer *bytes.Buffer) *Error { 12 | return nil 13 | } 14 | 15 | func tagExtendsParser(doc *Parser, start *Token, arguments *Parser) (INodeTag, *Error) { 16 | extends_node := &tagExtendsNode{} 17 | 18 | if doc.template.level > 1 { 19 | return nil, arguments.Error("The 'extends' tag can only defined on root level.", start) 20 | } 21 | 22 | if doc.template.parent != nil { 23 | // Already one parent 24 | return nil, arguments.Error("This template has already one parent.", start) 25 | } 26 | 27 | if filename_token := arguments.MatchType(TokenString); filename_token != nil { 28 | // prepared, static template 29 | 30 | // Get parent's filename 31 | parent_filename := doc.template.set.resolveFilename(doc.template, filename_token.Val) 32 | 33 | // Parse the parent 34 | parent_template, err := doc.template.set.FromFile(parent_filename) 35 | if err != nil { 36 | return nil, err.(*Error) 37 | } 38 | 39 | // Keep track of things 40 | parent_template.child = doc.template 41 | doc.template.parent = parent_template 42 | extends_node.filename = parent_filename 43 | } else { 44 | return nil, arguments.Error("Tag 'extends' requires a template filename as string.", nil) 45 | } 46 | 47 | if arguments.Remaining() > 0 { 48 | return nil, arguments.Error("Tag 'extends' does only take 1 argument.", nil) 49 | } 50 | 51 | return extends_node, nil 52 | } 53 | 54 | func init() { 55 | RegisterTag("extends", tagExtendsParser) 56 | } 57 | -------------------------------------------------------------------------------- /vendor/gopkg.in/flosch/pongo2.v3/tags_firstof.go: -------------------------------------------------------------------------------- 1 | package pongo2 2 | 3 | import ( 4 | "bytes" 5 | ) 6 | 7 | type tagFirstofNode struct { 8 | position *Token 9 | args []IEvaluator 10 | } 11 | 12 | func (node *tagFirstofNode) Execute(ctx *ExecutionContext, buffer *bytes.Buffer) *Error { 13 | for _, arg := range node.args { 14 | val, err := arg.Evaluate(ctx) 15 | if err != nil { 16 | return err 17 | } 18 | 19 | if val.IsTrue() { 20 | if ctx.Autoescape && !arg.FilterApplied("safe") { 21 | val, err = ApplyFilter("escape", val, nil) 22 | if err != nil { 23 | return err 24 | } 25 | } 26 | 27 | buffer.WriteString(val.String()) 28 | return nil 29 | } 30 | } 31 | 32 | return nil 33 | } 34 | 35 | func tagFirstofParser(doc *Parser, start *Token, arguments *Parser) (INodeTag, *Error) { 36 | firstof_node := &tagFirstofNode{ 37 | position: start, 38 | } 39 | 40 | for arguments.Remaining() > 0 { 41 | node, err := arguments.ParseExpression() 42 | if err != nil { 43 | return nil, err 44 | } 45 | firstof_node.args = append(firstof_node.args, node) 46 | } 47 | 48 | return firstof_node, nil 49 | } 50 | 51 | func init() { 52 | RegisterTag("firstof", tagFirstofParser) 53 | } 54 | -------------------------------------------------------------------------------- /vendor/gopkg.in/flosch/pongo2.v3/tags_now.go: -------------------------------------------------------------------------------- 1 | package pongo2 2 | 3 | import ( 4 | "bytes" 5 | "time" 6 | ) 7 | 8 | type tagNowNode struct { 9 | position *Token 10 | format string 11 | fake bool 12 | } 13 | 14 | func (node *tagNowNode) Execute(ctx *ExecutionContext, buffer *bytes.Buffer) *Error { 15 | var t time.Time 16 | if node.fake { 17 | t = time.Date(2014, time.February, 05, 18, 31, 45, 00, time.UTC) 18 | } else { 19 | t = time.Now() 20 | } 21 | 22 | buffer.WriteString(t.Format(node.format)) 23 | 24 | return nil 25 | } 26 | 27 | func tagNowParser(doc *Parser, start *Token, arguments *Parser) (INodeTag, *Error) { 28 | now_node := &tagNowNode{ 29 | position: start, 30 | } 31 | 32 | format_token := arguments.MatchType(TokenString) 33 | if format_token == nil { 34 | return nil, arguments.Error("Expected a format string.", nil) 35 | } 36 | now_node.format = format_token.Val 37 | 38 | if arguments.MatchOne(TokenIdentifier, "fake") != nil { 39 | now_node.fake = true 40 | } 41 | 42 | if arguments.Remaining() > 0 { 43 | return nil, arguments.Error("Malformed now-tag arguments.", nil) 44 | } 45 | 46 | return now_node, nil 47 | } 48 | 49 | func init() { 50 | RegisterTag("now", tagNowParser) 51 | } 52 | -------------------------------------------------------------------------------- /vendor/gopkg.in/flosch/pongo2.v3/tags_set.go: -------------------------------------------------------------------------------- 1 | package pongo2 2 | 3 | import "bytes" 4 | 5 | type tagSetNode struct { 6 | name string 7 | expression IEvaluator 8 | } 9 | 10 | func (node *tagSetNode) Execute(ctx *ExecutionContext, buffer *bytes.Buffer) *Error { 11 | // Evaluate expression 12 | value, err := node.expression.Evaluate(ctx) 13 | if err != nil { 14 | return err 15 | } 16 | 17 | ctx.Private[node.name] = value 18 | return nil 19 | } 20 | 21 | func tagSetParser(doc *Parser, start *Token, arguments *Parser) (INodeTag, *Error) { 22 | node := &tagSetNode{} 23 | 24 | // Parse variable name 25 | typeToken := arguments.MatchType(TokenIdentifier) 26 | if typeToken == nil { 27 | return nil, arguments.Error("Expected an identifier.", nil) 28 | } 29 | node.name = typeToken.Val 30 | 31 | if arguments.Match(TokenSymbol, "=") == nil { 32 | return nil, arguments.Error("Expected '='.", nil) 33 | } 34 | 35 | // Variable expression 36 | keyExpression, err := arguments.ParseExpression() 37 | if err != nil { 38 | return nil, err 39 | } 40 | node.expression = keyExpression 41 | 42 | // Remaining arguments 43 | if arguments.Remaining() > 0 { 44 | return nil, arguments.Error("Malformed 'set'-tag arguments.", nil) 45 | } 46 | 47 | return node, nil 48 | } 49 | 50 | func init() { 51 | RegisterTag("set", tagSetParser) 52 | } 53 | -------------------------------------------------------------------------------- /vendor/gopkg.in/flosch/pongo2.v3/tags_spaceless.go: -------------------------------------------------------------------------------- 1 | package pongo2 2 | 3 | import ( 4 | "bytes" 5 | "regexp" 6 | ) 7 | 8 | type tagSpacelessNode struct { 9 | wrapper *NodeWrapper 10 | } 11 | 12 | var tagSpacelessRegexp = regexp.MustCompile(`(?U:(<.*>))([\t\n\v\f\r ]+)(?U:(<.*>))`) 13 | 14 | func (node *tagSpacelessNode) Execute(ctx *ExecutionContext, buffer *bytes.Buffer) *Error { 15 | b := bytes.NewBuffer(make([]byte, 0, 1024)) // 1 KiB 16 | 17 | err := node.wrapper.Execute(ctx, b) 18 | if err != nil { 19 | return err 20 | } 21 | 22 | s := b.String() 23 | // Repeat this recursively 24 | changed := true 25 | for changed { 26 | s2 := tagSpacelessRegexp.ReplaceAllString(s, "$1$3") 27 | changed = s != s2 28 | s = s2 29 | } 30 | 31 | buffer.WriteString(s) 32 | 33 | return nil 34 | } 35 | 36 | func tagSpacelessParser(doc *Parser, start *Token, arguments *Parser) (INodeTag, *Error) { 37 | spaceless_node := &tagSpacelessNode{} 38 | 39 | wrapper, _, err := doc.WrapUntilTag("endspaceless") 40 | if err != nil { 41 | return nil, err 42 | } 43 | spaceless_node.wrapper = wrapper 44 | 45 | if arguments.Remaining() > 0 { 46 | return nil, arguments.Error("Malformed spaceless-tag arguments.", nil) 47 | } 48 | 49 | return spaceless_node, nil 50 | } 51 | 52 | func init() { 53 | RegisterTag("spaceless", tagSpacelessParser) 54 | } 55 | -------------------------------------------------------------------------------- /vendor/gopkg.in/flosch/pongo2.v3/tags_templatetag.go: -------------------------------------------------------------------------------- 1 | package pongo2 2 | 3 | import ( 4 | "bytes" 5 | ) 6 | 7 | type tagTemplateTagNode struct { 8 | content string 9 | } 10 | 11 | var templateTagMapping = map[string]string{ 12 | "openblock": "{%", 13 | "closeblock": "%}", 14 | "openvariable": "{{", 15 | "closevariable": "}}", 16 | "openbrace": "{", 17 | "closebrace": "}", 18 | "opencomment": "{#", 19 | "closecomment": "#}", 20 | } 21 | 22 | func (node *tagTemplateTagNode) Execute(ctx *ExecutionContext, buffer *bytes.Buffer) *Error { 23 | buffer.WriteString(node.content) 24 | return nil 25 | } 26 | 27 | func tagTemplateTagParser(doc *Parser, start *Token, arguments *Parser) (INodeTag, *Error) { 28 | tt_node := &tagTemplateTagNode{} 29 | 30 | if arg_token := arguments.MatchType(TokenIdentifier); arg_token != nil { 31 | output, found := templateTagMapping[arg_token.Val] 32 | if !found { 33 | return nil, arguments.Error("Argument not found", arg_token) 34 | } 35 | tt_node.content = output 36 | } else { 37 | return nil, arguments.Error("Identifier expected.", nil) 38 | } 39 | 40 | if arguments.Remaining() > 0 { 41 | return nil, arguments.Error("Malformed templatetag-tag argument.", nil) 42 | } 43 | 44 | return tt_node, nil 45 | } 46 | 47 | func init() { 48 | RegisterTag("templatetag", tagTemplateTagParser) 49 | } 50 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2011-2016 Canonical Ltd. 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 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/LICENSE.libyaml: -------------------------------------------------------------------------------- 1 | The following files were ported to Go from C files of libyaml, and thus 2 | are still covered by their original copyright and license: 3 | 4 | apic.go 5 | emitterc.go 6 | parserc.go 7 | readerc.go 8 | scannerc.go 9 | writerc.go 10 | yamlh.go 11 | yamlprivateh.go 12 | 13 | Copyright (c) 2006 Kirill Simonov 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | this software and associated documentation files (the "Software"), to deal in 17 | the Software without restriction, including without limitation the rights to 18 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | of the Software, and to permit persons to whom the Software is furnished to do 20 | so, subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in all 23 | copies or substantial portions of the Software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 | SOFTWARE. 32 | -------------------------------------------------------------------------------- /xormplus.go: -------------------------------------------------------------------------------- 1 | package xorm 2 | 3 | // "fmt" 4 | 5 | const ( 6 | MSSQL_DRIVER string = "mssql" 7 | MSSQL_ODBC_DRIVER string = "odbc" 8 | MYSQL_DRIVER string = "mysql" 9 | MYMYSQL_DRIVER string = "mymysql" 10 | POSTGRESQL_DRIVER string = "postgres" 11 | OCI8_DRIVER string = "oci8" 12 | GORACLE_DRIVER string = "godror" 13 | SQLITE3_DRIVER string = "sqlite3" 14 | ) 15 | 16 | func NewOracle(driverName string, dataSourceName string) (*Engine, error) { 17 | return NewEngine(driverName, dataSourceName) 18 | } 19 | 20 | func NewMSSQL(driverName string, dataSourceName string) (*Engine, error) { 21 | return NewEngine(driverName, dataSourceName) 22 | } 23 | 24 | func NewMySQL(driverName string, dataSourceName string) (*Engine, error) { 25 | return NewEngine(driverName, dataSourceName) 26 | } 27 | 28 | func NewPostgreSQL(dataSourceName string) (*Engine, error) { 29 | return NewEngine(POSTGRESQL_DRIVER, dataSourceName) 30 | } 31 | 32 | func NewSqlite3(dataSourceName string) (*Engine, error) { 33 | return NewEngine(SQLITE3_DRIVER, dataSourceName) 34 | } 35 | 36 | func NewDB(driverName string, dataSourceName string) (*Engine, error) { 37 | return NewEngine(driverName, dataSourceName) 38 | } 39 | --------------------------------------------------------------------------------