├── .gitignore ├── 1-introduction ├── README.md └── benchmarksort.bash ├── 10-runtime-evaluations-in-go ├── build │ ├── go.mod │ ├── go.sum │ ├── prometheusMetrics │ ├── prometheusMetrics.go │ └── vendor │ │ ├── github.com │ │ ├── beorn7 │ │ │ └── perks │ │ │ │ ├── LICENSE │ │ │ │ └── quantile │ │ │ │ ├── exampledata.txt │ │ │ │ └── stream.go │ │ ├── golang │ │ │ └── protobuf │ │ │ │ ├── AUTHORS │ │ │ │ ├── CONTRIBUTORS │ │ │ │ ├── LICENSE │ │ │ │ └── proto │ │ │ │ ├── clone.go │ │ │ │ ├── decode.go │ │ │ │ ├── deprecated.go │ │ │ │ ├── discard.go │ │ │ │ ├── encode.go │ │ │ │ ├── equal.go │ │ │ │ ├── extensions.go │ │ │ │ ├── lib.go │ │ │ │ ├── message_set.go │ │ │ │ ├── pointer_reflect.go │ │ │ │ ├── pointer_unsafe.go │ │ │ │ ├── properties.go │ │ │ │ ├── table_marshal.go │ │ │ │ ├── table_merge.go │ │ │ │ ├── table_unmarshal.go │ │ │ │ ├── text.go │ │ │ │ └── text_parser.go │ │ ├── matttproud │ │ │ └── golang_protobuf_extensions │ │ │ │ ├── LICENSE │ │ │ │ ├── NOTICE │ │ │ │ └── pbutil │ │ │ │ ├── .gitignore │ │ │ │ ├── Makefile │ │ │ │ ├── decode.go │ │ │ │ ├── doc.go │ │ │ │ └── encode.go │ │ └── prometheus │ │ │ ├── client_golang │ │ │ ├── LICENSE │ │ │ ├── NOTICE │ │ │ └── prometheus │ │ │ │ ├── .gitignore │ │ │ │ ├── README.md │ │ │ │ ├── build_info.go │ │ │ │ ├── build_info_pre_1.12.go │ │ │ │ ├── collector.go │ │ │ │ ├── counter.go │ │ │ │ ├── desc.go │ │ │ │ ├── doc.go │ │ │ │ ├── expvar_collector.go │ │ │ │ ├── fnv.go │ │ │ │ ├── gauge.go │ │ │ │ ├── go_collector.go │ │ │ │ ├── histogram.go │ │ │ │ ├── internal │ │ │ │ └── metric.go │ │ │ │ ├── labels.go │ │ │ │ ├── metric.go │ │ │ │ ├── observer.go │ │ │ │ ├── process_collector.go │ │ │ │ ├── process_collector_other.go │ │ │ │ ├── process_collector_windows.go │ │ │ │ ├── promhttp │ │ │ │ ├── delegator.go │ │ │ │ ├── http.go │ │ │ │ ├── instrument_client.go │ │ │ │ └── instrument_server.go │ │ │ │ ├── registry.go │ │ │ │ ├── summary.go │ │ │ │ ├── timer.go │ │ │ │ ├── untyped.go │ │ │ │ ├── value.go │ │ │ │ ├── vec.go │ │ │ │ └── wrap.go │ │ │ ├── client_model │ │ │ ├── LICENSE │ │ │ ├── NOTICE │ │ │ └── go │ │ │ │ └── metrics.pb.go │ │ │ ├── common │ │ │ ├── LICENSE │ │ │ ├── NOTICE │ │ │ ├── expfmt │ │ │ │ ├── decode.go │ │ │ │ ├── encode.go │ │ │ │ ├── expfmt.go │ │ │ │ ├── fuzz.go │ │ │ │ ├── text_create.go │ │ │ │ └── text_parse.go │ │ │ ├── internal │ │ │ │ └── bitbucket.org │ │ │ │ │ └── ww │ │ │ │ │ └── goautoneg │ │ │ │ │ ├── README.txt │ │ │ │ │ └── autoneg.go │ │ │ └── model │ │ │ │ ├── alert.go │ │ │ │ ├── fingerprinting.go │ │ │ │ ├── fnv.go │ │ │ │ ├── labels.go │ │ │ │ ├── labelset.go │ │ │ │ ├── metric.go │ │ │ │ ├── model.go │ │ │ │ ├── signature.go │ │ │ │ ├── silence.go │ │ │ │ ├── time.go │ │ │ │ └── value.go │ │ │ └── procfs │ │ │ ├── .gitignore │ │ │ ├── .golangci.yml │ │ │ ├── CONTRIBUTING.md │ │ │ ├── LICENSE │ │ │ ├── MAINTAINERS.md │ │ │ ├── Makefile │ │ │ ├── Makefile.common │ │ │ ├── NOTICE │ │ │ ├── README.md │ │ │ ├── buddyinfo.go │ │ │ ├── doc.go │ │ │ ├── fixtures.ttar │ │ │ ├── fs.go │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── internal │ │ │ └── fs │ │ │ │ └── fs.go │ │ │ ├── ipvs.go │ │ │ ├── mdstat.go │ │ │ ├── mountinfo.go │ │ │ ├── mountstats.go │ │ │ ├── net_dev.go │ │ │ ├── net_unix.go │ │ │ ├── proc.go │ │ │ ├── proc_environ.go │ │ │ ├── proc_io.go │ │ │ ├── proc_limits.go │ │ │ ├── proc_ns.go │ │ │ ├── proc_psi.go │ │ │ ├── proc_stat.go │ │ │ ├── proc_status.go │ │ │ ├── stat.go │ │ │ ├── ttar │ │ │ └── xfrm.go │ │ ├── golang.org │ │ └── x │ │ │ └── sys │ │ │ ├── AUTHORS │ │ │ ├── CONTRIBUTORS │ │ │ ├── LICENSE │ │ │ ├── PATENTS │ │ │ └── windows │ │ │ ├── aliases.go │ │ │ ├── asm_windows_386.s │ │ │ ├── asm_windows_amd64.s │ │ │ ├── asm_windows_arm.s │ │ │ ├── dll_windows.go │ │ │ ├── env_windows.go │ │ │ ├── eventlog.go │ │ │ ├── exec_windows.go │ │ │ ├── memory_windows.go │ │ │ ├── mkerrors.bash │ │ │ ├── mkknownfolderids.bash │ │ │ ├── mksyscall.go │ │ │ ├── race.go │ │ │ ├── race0.go │ │ │ ├── security_windows.go │ │ │ ├── service.go │ │ │ ├── str.go │ │ │ ├── syscall.go │ │ │ ├── syscall_windows.go │ │ │ ├── types_windows.go │ │ │ ├── types_windows_386.go │ │ │ ├── types_windows_amd64.go │ │ │ ├── types_windows_arm.go │ │ │ ├── zerrors_windows.go │ │ │ ├── zknownfolderids_windows.go │ │ │ └── zsyscall_windows.go │ │ └── modules.txt ├── gogc.sh ├── gomaxprocs.sh ├── keepalive │ ├── keepalive.go │ └── testfile.txt ├── memstats │ └── memstats.go ├── numcpu │ └── numcpu.go ├── runtime │ ├── gctraceExample │ ├── gctraceExample.go │ ├── go.mod │ └── go.sum ├── traceback.go └── traceback │ └── traceback.go ├── 11-deploying-go-code ├── compilerLinker │ ├── Optimized │ ├── compilerLinkerFlags.go │ └── nonOptimized ├── goList │ ├── go.mod │ └── goListExample.go ├── multiStageDockerBuild │ ├── Dockerfile │ ├── go.mod │ ├── go.sum │ ├── vendor │ │ ├── github.com │ │ │ └── BurntSushi │ │ │ │ └── toml │ │ │ │ ├── .gitignore │ │ │ │ ├── .travis.yml │ │ │ │ ├── COMPATIBLE │ │ │ │ ├── COPYING │ │ │ │ ├── Makefile │ │ │ │ ├── README.md │ │ │ │ ├── decode.go │ │ │ │ ├── decode_meta.go │ │ │ │ ├── doc.go │ │ │ │ ├── encode.go │ │ │ │ ├── encoding_types.go │ │ │ │ ├── encoding_types_1.1.go │ │ │ │ ├── lex.go │ │ │ │ ├── parse.go │ │ │ │ ├── session.vim │ │ │ │ ├── type_check.go │ │ │ │ └── type_fields.go │ │ ├── go.uber.org │ │ │ ├── atomic │ │ │ │ ├── .codecov.yml │ │ │ │ ├── .gitignore │ │ │ │ ├── .travis.yml │ │ │ │ ├── CHANGELOG.md │ │ │ │ ├── LICENSE.txt │ │ │ │ ├── Makefile │ │ │ │ ├── README.md │ │ │ │ ├── atomic.go │ │ │ │ ├── error.go │ │ │ │ ├── go.mod │ │ │ │ ├── go.sum │ │ │ │ ├── string.go │ │ │ │ └── tools.go │ │ │ ├── multierr │ │ │ │ ├── .codecov.yml │ │ │ │ ├── .gitignore │ │ │ │ ├── .travis.yml │ │ │ │ ├── CHANGELOG.md │ │ │ │ ├── LICENSE.txt │ │ │ │ ├── Makefile │ │ │ │ ├── README.md │ │ │ │ ├── error.go │ │ │ │ ├── glide.yaml │ │ │ │ ├── go.mod │ │ │ │ ├── go.sum │ │ │ │ ├── go113.go │ │ │ │ └── tools.go │ │ │ ├── tools │ │ │ │ ├── LICENSE │ │ │ │ └── update-license │ │ │ │ │ ├── .gitignore │ │ │ │ │ ├── README.md │ │ │ │ │ ├── licenses.go │ │ │ │ │ └── main.go │ │ │ └── zap │ │ │ │ ├── .codecov.yml │ │ │ │ ├── .gitignore │ │ │ │ ├── .readme.tmpl │ │ │ │ ├── .travis.yml │ │ │ │ ├── CHANGELOG.md │ │ │ │ ├── CODE_OF_CONDUCT.md │ │ │ │ ├── CONTRIBUTING.md │ │ │ │ ├── FAQ.md │ │ │ │ ├── LICENSE.txt │ │ │ │ ├── Makefile │ │ │ │ ├── README.md │ │ │ │ ├── array.go │ │ │ │ ├── buffer │ │ │ │ ├── buffer.go │ │ │ │ └── pool.go │ │ │ │ ├── checklicense.sh │ │ │ │ ├── config.go │ │ │ │ ├── doc.go │ │ │ │ ├── encoder.go │ │ │ │ ├── error.go │ │ │ │ ├── field.go │ │ │ │ ├── flag.go │ │ │ │ ├── glide.yaml │ │ │ │ ├── global.go │ │ │ │ ├── global_go112.go │ │ │ │ ├── global_prego112.go │ │ │ │ ├── go.mod │ │ │ │ ├── go.sum │ │ │ │ ├── http_handler.go │ │ │ │ ├── internal │ │ │ │ ├── bufferpool │ │ │ │ │ └── bufferpool.go │ │ │ │ ├── color │ │ │ │ │ └── color.go │ │ │ │ └── exit │ │ │ │ │ └── exit.go │ │ │ │ ├── level.go │ │ │ │ ├── logger.go │ │ │ │ ├── options.go │ │ │ │ ├── sink.go │ │ │ │ ├── stacktrace.go │ │ │ │ ├── sugar.go │ │ │ │ ├── time.go │ │ │ │ ├── tools.go │ │ │ │ ├── writer.go │ │ │ │ └── zapcore │ │ │ │ ├── console_encoder.go │ │ │ │ ├── core.go │ │ │ │ ├── doc.go │ │ │ │ ├── encoder.go │ │ │ │ ├── entry.go │ │ │ │ ├── error.go │ │ │ │ ├── field.go │ │ │ │ ├── hook.go │ │ │ │ ├── increase_level.go │ │ │ │ ├── json_encoder.go │ │ │ │ ├── level.go │ │ │ │ ├── level_strings.go │ │ │ │ ├── marshaler.go │ │ │ │ ├── memory_encoder.go │ │ │ │ ├── sampler.go │ │ │ │ ├── tee.go │ │ │ │ └── write_syncer.go │ │ ├── golang.org │ │ │ └── x │ │ │ │ ├── lint │ │ │ │ ├── .travis.yml │ │ │ │ ├── CONTRIBUTING.md │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── go.mod │ │ │ │ ├── go.sum │ │ │ │ ├── golint │ │ │ │ │ ├── golint.go │ │ │ │ │ ├── import.go │ │ │ │ │ └── importcomment.go │ │ │ │ └── lint.go │ │ │ │ └── tools │ │ │ │ ├── AUTHORS │ │ │ │ ├── CONTRIBUTORS │ │ │ │ ├── LICENSE │ │ │ │ ├── PATENTS │ │ │ │ ├── go │ │ │ │ ├── analysis │ │ │ │ │ ├── analysis.go │ │ │ │ │ ├── diagnostic.go │ │ │ │ │ ├── doc.go │ │ │ │ │ ├── passes │ │ │ │ │ │ └── inspect │ │ │ │ │ │ │ └── inspect.go │ │ │ │ │ └── validate.go │ │ │ │ ├── ast │ │ │ │ │ ├── astutil │ │ │ │ │ │ ├── enclosing.go │ │ │ │ │ │ ├── imports.go │ │ │ │ │ │ ├── rewrite.go │ │ │ │ │ │ └── util.go │ │ │ │ │ └── inspector │ │ │ │ │ │ ├── inspector.go │ │ │ │ │ │ └── typeof.go │ │ │ │ ├── buildutil │ │ │ │ │ ├── allpackages.go │ │ │ │ │ ├── fakecontext.go │ │ │ │ │ ├── overlay.go │ │ │ │ │ ├── tags.go │ │ │ │ │ └── util.go │ │ │ │ ├── gcexportdata │ │ │ │ │ ├── gcexportdata.go │ │ │ │ │ └── importer.go │ │ │ │ ├── internal │ │ │ │ │ ├── gcimporter │ │ │ │ │ │ ├── bexport.go │ │ │ │ │ │ ├── bimport.go │ │ │ │ │ │ ├── exportdata.go │ │ │ │ │ │ ├── gcimporter.go │ │ │ │ │ │ ├── iexport.go │ │ │ │ │ │ ├── iimport.go │ │ │ │ │ │ ├── newInterface10.go │ │ │ │ │ │ └── newInterface11.go │ │ │ │ │ └── packagesdriver │ │ │ │ │ │ └── sizes.go │ │ │ │ ├── packages │ │ │ │ │ ├── doc.go │ │ │ │ │ ├── external.go │ │ │ │ │ ├── golist.go │ │ │ │ │ ├── golist_overlay.go │ │ │ │ │ ├── packages.go │ │ │ │ │ └── visit.go │ │ │ │ └── types │ │ │ │ │ ├── objectpath │ │ │ │ │ └── objectpath.go │ │ │ │ │ └── typeutil │ │ │ │ │ ├── callee.go │ │ │ │ │ ├── imports.go │ │ │ │ │ ├── map.go │ │ │ │ │ ├── methodsetcache.go │ │ │ │ │ └── ui.go │ │ │ │ └── internal │ │ │ │ ├── fastwalk │ │ │ │ ├── fastwalk.go │ │ │ │ ├── fastwalk_dirent_fileno.go │ │ │ │ ├── fastwalk_dirent_ino.go │ │ │ │ ├── fastwalk_dirent_namlen_bsd.go │ │ │ │ ├── fastwalk_dirent_namlen_linux.go │ │ │ │ ├── fastwalk_portable.go │ │ │ │ └── fastwalk_unix.go │ │ │ │ ├── gopathwalk │ │ │ │ └── walk.go │ │ │ │ ├── semver │ │ │ │ └── semver.go │ │ │ │ └── span │ │ │ │ ├── parse.go │ │ │ │ ├── span.go │ │ │ │ ├── token.go │ │ │ │ ├── token111.go │ │ │ │ ├── token112.go │ │ │ │ ├── uri.go │ │ │ │ └── utf16.go │ │ ├── honnef.co │ │ │ └── go │ │ │ │ └── tools │ │ │ │ ├── LICENSE │ │ │ │ ├── LICENSE-THIRD-PARTY │ │ │ │ ├── arg │ │ │ │ └── arg.go │ │ │ │ ├── cmd │ │ │ │ └── staticcheck │ │ │ │ │ ├── README.md │ │ │ │ │ └── staticcheck.go │ │ │ │ ├── config │ │ │ │ ├── config.go │ │ │ │ └── example.conf │ │ │ │ ├── deprecated │ │ │ │ └── stdlib.go │ │ │ │ ├── facts │ │ │ │ ├── deprecated.go │ │ │ │ ├── generated.go │ │ │ │ ├── purity.go │ │ │ │ └── token.go │ │ │ │ ├── functions │ │ │ │ ├── loops.go │ │ │ │ ├── pure.go │ │ │ │ └── terminates.go │ │ │ │ ├── go │ │ │ │ └── types │ │ │ │ │ └── typeutil │ │ │ │ │ ├── callee.go │ │ │ │ │ ├── identical.go │ │ │ │ │ ├── imports.go │ │ │ │ │ ├── map.go │ │ │ │ │ ├── methodsetcache.go │ │ │ │ │ └── ui.go │ │ │ │ ├── internal │ │ │ │ ├── cache │ │ │ │ │ ├── cache.go │ │ │ │ │ ├── default.go │ │ │ │ │ └── hash.go │ │ │ │ ├── passes │ │ │ │ │ └── buildssa │ │ │ │ │ │ └── buildssa.go │ │ │ │ ├── renameio │ │ │ │ │ └── renameio.go │ │ │ │ └── sharedcheck │ │ │ │ │ └── lint.go │ │ │ │ ├── lint │ │ │ │ ├── LICENSE │ │ │ │ ├── lint.go │ │ │ │ ├── lintdsl │ │ │ │ │ └── lintdsl.go │ │ │ │ ├── lintutil │ │ │ │ │ ├── format │ │ │ │ │ │ └── format.go │ │ │ │ │ ├── stats.go │ │ │ │ │ ├── stats_bsd.go │ │ │ │ │ ├── stats_posix.go │ │ │ │ │ └── util.go │ │ │ │ ├── runner.go │ │ │ │ └── stats.go │ │ │ │ ├── loader │ │ │ │ └── loader.go │ │ │ │ ├── printf │ │ │ │ ├── fuzz.go │ │ │ │ └── printf.go │ │ │ │ ├── simple │ │ │ │ ├── CONTRIBUTING.md │ │ │ │ ├── analysis.go │ │ │ │ ├── doc.go │ │ │ │ └── lint.go │ │ │ │ ├── ssa │ │ │ │ ├── LICENSE │ │ │ │ ├── blockopt.go │ │ │ │ ├── builder.go │ │ │ │ ├── const.go │ │ │ │ ├── create.go │ │ │ │ ├── doc.go │ │ │ │ ├── dom.go │ │ │ │ ├── emit.go │ │ │ │ ├── func.go │ │ │ │ ├── identical.go │ │ │ │ ├── identical_17.go │ │ │ │ ├── lift.go │ │ │ │ ├── lvalue.go │ │ │ │ ├── methods.go │ │ │ │ ├── mode.go │ │ │ │ ├── print.go │ │ │ │ ├── sanity.go │ │ │ │ ├── source.go │ │ │ │ ├── ssa.go │ │ │ │ ├── staticcheck.conf │ │ │ │ ├── testmain.go │ │ │ │ ├── util.go │ │ │ │ ├── wrappers.go │ │ │ │ └── write.go │ │ │ │ ├── ssautil │ │ │ │ └── ssautil.go │ │ │ │ ├── staticcheck │ │ │ │ ├── CONTRIBUTING.md │ │ │ │ ├── analysis.go │ │ │ │ ├── buildtag.go │ │ │ │ ├── doc.go │ │ │ │ ├── knowledge.go │ │ │ │ ├── lint.go │ │ │ │ ├── rules.go │ │ │ │ ├── structtag.go │ │ │ │ └── vrp │ │ │ │ │ ├── channel.go │ │ │ │ │ ├── int.go │ │ │ │ │ ├── slice.go │ │ │ │ │ ├── string.go │ │ │ │ │ └── vrp.go │ │ │ │ ├── stylecheck │ │ │ │ ├── analysis.go │ │ │ │ ├── doc.go │ │ │ │ ├── lint.go │ │ │ │ └── names.go │ │ │ │ ├── unused │ │ │ │ ├── edge.go │ │ │ │ ├── edgekind_string.go │ │ │ │ ├── implements.go │ │ │ │ └── unused.go │ │ │ │ └── version │ │ │ │ ├── buildinfo.go │ │ │ │ ├── buildinfo111.go │ │ │ │ └── version.go │ │ └── modules.txt │ └── zapLoggerExample.go └── promExporter │ ├── go.mod │ ├── go.sum │ ├── prometheusExporterExample │ ├── prometheusExporterExample.go │ └── vendor │ ├── github.com │ ├── beorn7 │ │ └── perks │ │ │ ├── LICENSE │ │ │ └── quantile │ │ │ ├── exampledata.txt │ │ │ └── stream.go │ ├── golang │ │ └── protobuf │ │ │ ├── AUTHORS │ │ │ ├── CONTRIBUTORS │ │ │ ├── LICENSE │ │ │ └── proto │ │ │ ├── clone.go │ │ │ ├── decode.go │ │ │ ├── deprecated.go │ │ │ ├── discard.go │ │ │ ├── encode.go │ │ │ ├── equal.go │ │ │ ├── extensions.go │ │ │ ├── lib.go │ │ │ ├── message_set.go │ │ │ ├── pointer_reflect.go │ │ │ ├── pointer_unsafe.go │ │ │ ├── properties.go │ │ │ ├── table_marshal.go │ │ │ ├── table_merge.go │ │ │ ├── table_unmarshal.go │ │ │ ├── text.go │ │ │ └── text_parser.go │ ├── matttproud │ │ └── golang_protobuf_extensions │ │ │ ├── LICENSE │ │ │ ├── NOTICE │ │ │ └── pbutil │ │ │ ├── .gitignore │ │ │ ├── Makefile │ │ │ ├── decode.go │ │ │ ├── doc.go │ │ │ └── encode.go │ └── prometheus │ │ ├── client_golang │ │ ├── LICENSE │ │ ├── NOTICE │ │ └── prometheus │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── build_info.go │ │ │ ├── build_info_pre_1.12.go │ │ │ ├── collector.go │ │ │ ├── counter.go │ │ │ ├── desc.go │ │ │ ├── doc.go │ │ │ ├── expvar_collector.go │ │ │ ├── fnv.go │ │ │ ├── gauge.go │ │ │ ├── go_collector.go │ │ │ ├── histogram.go │ │ │ ├── internal │ │ │ └── metric.go │ │ │ ├── labels.go │ │ │ ├── metric.go │ │ │ ├── observer.go │ │ │ ├── process_collector.go │ │ │ ├── process_collector_other.go │ │ │ ├── process_collector_windows.go │ │ │ ├── promhttp │ │ │ ├── delegator.go │ │ │ ├── http.go │ │ │ ├── instrument_client.go │ │ │ └── instrument_server.go │ │ │ ├── registry.go │ │ │ ├── summary.go │ │ │ ├── timer.go │ │ │ ├── untyped.go │ │ │ ├── value.go │ │ │ ├── vec.go │ │ │ └── wrap.go │ │ ├── client_model │ │ ├── LICENSE │ │ ├── NOTICE │ │ └── go │ │ │ └── metrics.pb.go │ │ ├── common │ │ ├── LICENSE │ │ ├── NOTICE │ │ ├── expfmt │ │ │ ├── decode.go │ │ │ ├── encode.go │ │ │ ├── expfmt.go │ │ │ ├── fuzz.go │ │ │ ├── text_create.go │ │ │ └── text_parse.go │ │ ├── internal │ │ │ └── bitbucket.org │ │ │ │ └── ww │ │ │ │ └── goautoneg │ │ │ │ ├── README.txt │ │ │ │ └── autoneg.go │ │ └── model │ │ │ ├── alert.go │ │ │ ├── fingerprinting.go │ │ │ ├── fnv.go │ │ │ ├── labels.go │ │ │ ├── labelset.go │ │ │ ├── metric.go │ │ │ ├── model.go │ │ │ ├── signature.go │ │ │ ├── silence.go │ │ │ ├── time.go │ │ │ └── value.go │ │ └── procfs │ │ ├── .gitignore │ │ ├── .golangci.yml │ │ ├── CONTRIBUTING.md │ │ ├── LICENSE │ │ ├── MAINTAINERS.md │ │ ├── Makefile │ │ ├── Makefile.common │ │ ├── NOTICE │ │ ├── README.md │ │ ├── buddyinfo.go │ │ ├── doc.go │ │ ├── fixtures.ttar │ │ ├── fs.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── internal │ │ └── fs │ │ │ └── fs.go │ │ ├── ipvs.go │ │ ├── mdstat.go │ │ ├── mountinfo.go │ │ ├── mountstats.go │ │ ├── net_dev.go │ │ ├── net_unix.go │ │ ├── proc.go │ │ ├── proc_environ.go │ │ ├── proc_io.go │ │ ├── proc_limits.go │ │ ├── proc_ns.go │ │ ├── proc_psi.go │ │ ├── proc_stat.go │ │ ├── proc_status.go │ │ ├── stat.go │ │ ├── ttar │ │ └── xfrm.go │ ├── golang.org │ └── x │ │ └── sys │ │ ├── AUTHORS │ │ ├── CONTRIBUTORS │ │ ├── LICENSE │ │ ├── PATENTS │ │ └── windows │ │ ├── aliases.go │ │ ├── asm_windows_386.s │ │ ├── asm_windows_amd64.s │ │ ├── asm_windows_arm.s │ │ ├── dll_windows.go │ │ ├── env_windows.go │ │ ├── eventlog.go │ │ ├── exec_windows.go │ │ ├── memory_windows.go │ │ ├── mkerrors.bash │ │ ├── mkknownfolderids.bash │ │ ├── mksyscall.go │ │ ├── race.go │ │ ├── race0.go │ │ ├── security_windows.go │ │ ├── service.go │ │ ├── str.go │ │ ├── syscall.go │ │ ├── syscall_windows.go │ │ ├── types_windows.go │ │ ├── types_windows_386.go │ │ ├── types_windows_amd64.go │ │ ├── types_windows_arm.go │ │ ├── zerrors_windows.go │ │ ├── zknownfolderids_windows.go │ │ └── zsyscall_windows.go │ └── modules.txt ├── 12-profiling-with-pprof ├── httpProfiling.go ├── memoryLeakTest │ └── memoryLeak.go ├── out.dump └── timedHttpProfiling.go ├── 13-tracing-with-trace-tool ├── OpenCensusExample │ ├── go.mod │ ├── go.sum │ ├── ocZipkin.go │ └── tracingToZipkin.go ├── pprofTrace │ └── netTracePprof.go └── traceExample │ └── trace.go ├── 14-clustering-and-job-queueing-in-go ├── clustering │ ├── kmeans │ │ ├── 3_0.png │ │ ├── 3_1.png │ │ ├── 3_2.png │ │ ├── 3_3.png │ │ ├── 3_4.png │ │ ├── 3_5.png │ │ ├── go.mod │ │ ├── go.sum │ │ └── kmeans.go │ └── knn │ │ ├── iris.csv │ │ ├── knn.go │ │ ├── outside.csv │ │ └── randomdata.csv └── jobqueues │ ├── goroutine │ ├── go.mod │ ├── go.sum │ └── gomail.go │ ├── jobQueue │ └── jobQueue.go │ ├── kafka │ ├── go.mod │ ├── go.sum │ ├── readFromKafka.go │ ├── testKafka.sh │ └── writeToKafka.go │ └── rabbitMQ │ ├── checkAmqpQueue.go │ └── sendAmqpMessage.go ├── 15-code-quality-across-versions ├── GoogleCloudTrace │ ├── go.mod │ ├── go.sum │ └── trace.go ├── SLISLO │ ├── Dockerfile.promservice │ ├── SLISLO.go │ ├── four_golden_signals_grafana_dashboard.json │ ├── go.mod │ ├── go.sum │ └── prometheus.yml ├── logging │ ├── go.mod │ ├── go.sum │ └── logging.go └── promExporter │ ├── Dockerfile.promExporter │ ├── Dockerfile.promservice │ ├── go.mod │ ├── go.sum │ ├── promExporter │ ├── promExporter.go │ └── prometheus.yml ├── 2-data-structures-and-algorithms ├── Benchstat-comparison │ ├── multi │ │ ├── comparisonLarger.go │ │ └── larger_comparison_test.go │ └── single │ │ ├── comparison.go │ │ └── comparison_test.go ├── BigO-notation-o-1 │ ├── o1.go │ └── o1_test.go ├── BigO-notation-o-2n │ ├── o2n.go │ └── o2n_test.go ├── BigO-notation-o-logn │ ├── logn.go │ └── logn_test.go ├── BigO-notation-o-n │ ├── on.go │ └── on_test.go ├── BigO-notation-o-n2 │ ├── on2.go │ └── on2_test.go ├── BigO-notation-o-nlogn │ ├── onlogn.go │ └── onlogn_test.go ├── binarysearch │ └── binarysearch.go ├── hello │ └── hello_test.go ├── img │ ├── ArraySortingAlgorithms.png │ ├── BenchStatComparison.png │ ├── Big-O-functions.png │ ├── CommonDataStructureOperations.png │ ├── Screenshot from 2019-05-18 09-59-07.png │ ├── Screenshot from 2019-08-24 11-50-31.png │ ├── StdLibHeapSort.png │ ├── StdLibInsertionSort.png │ ├── StdLibSearch.png │ ├── StdLibStableSort.png │ ├── StdLibraryQuicksort.png │ ├── StdLibrarySearch.png │ ├── SumOfHarmonicSeries.png │ ├── binaryTree.svg │ └── mermaidLiveEditorValues.txt ├── iterators │ └── function_with_callback.go └── plot │ ├── functions.png │ ├── go.mod │ ├── go.sum │ └── plot.go ├── 3-iterators-and-generators ├── anonymous-functions │ ├── hello_anonymous.go │ ├── hello_anonymous_variable_as_function.go │ └── hello_go.go ├── channels │ ├── buffered_channel.go │ ├── buffered_channel_error_closed_channel.go │ ├── buffered_channel_error_no_room_in_buffer.go │ ├── directional_channels.go │ ├── ranges.go │ ├── unbuffered_channel.go │ ├── unbuffered_channel_int.go │ └── unbuffered_pipeline.go ├── closures │ ├── defer_work.go │ ├── http_middleware.go │ └── increment_closure.go ├── generators │ ├── forloop.go │ ├── generators.go │ ├── loop_sleep.go │ └── semaphore_sleep.go ├── goroutines │ └── simple_goroutine.go ├── iterators │ ├── buffered_chan.go │ ├── callback.go │ ├── iterators_test.go │ ├── loops.go │ ├── next.go │ └── unbuffered_chan.go ├── selects │ ├── selects.go │ └── timeouts.go └── workgroups │ └── workgroups.go ├── 4-standard-template-library ├── algorithms │ ├── minmax.go │ ├── reverse.go │ ├── search.go │ ├── sort.go │ └── vector.go ├── containers │ ├── deque.go │ ├── doubleLinkedList.go │ ├── go.mod │ ├── go.sum │ ├── map.go │ ├── multimap.go │ ├── multiset.go │ ├── priorityQueue.go │ ├── queue.go │ ├── set.go │ ├── singleLinkedList.go │ ├── slice.go │ └── stack.go ├── functions │ ├── functor.go │ ├── go.mod │ └── go.sum └── iterators │ ├── for.go │ └── range.go ├── 5-vectors-and-matrices ├── cscMatrix.go ├── csrMatrix.go ├── go.mod ├── go.sum ├── gonumVector.go ├── matrixAdd.go ├── matrixMult.go ├── matrixMultTwo.go ├── matrixScale.go ├── matrixSub.go ├── matrixSum.go ├── matrixTranspose.go ├── scaleMatrix.go ├── sliceVector.go ├── sparseMatrix.go ├── testCSRMatrix.go ├── transposeMatrix.go ├── vectorManipulation.go └── vectorMult.go ├── 6-composing-readable-go-code ├── antipatternDirectory │ └── notifications │ │ ├── email │ │ ├── email.go │ │ └── email_test.go │ │ ├── pagerduty │ │ ├── pagerduty.go │ │ └── pagerduty_test.go │ │ ├── pushnotify │ │ ├── pushnotify.go │ │ └── pushnotify_test.go │ │ ├── slack │ │ ├── slack.go │ │ └── slack_test.go │ │ └── trello │ │ ├── trello.go │ │ └── trello_test.go ├── embeddedStructs.go ├── emptyInterface.go ├── exampleProgram │ ├── .dockerignore │ ├── .gitignore │ ├── Dockerfile │ ├── Jenkinsfile │ ├── README.md │ ├── cmd │ │ ├── examplecli │ │ │ └── main.go │ │ └── exampleweb │ │ │ └── main.go │ ├── go.mod │ ├── go.sum │ └── pkg │ │ ├── api │ │ ├── api.go │ │ └── api_test.go │ │ ├── integration │ │ ├── integration.go │ │ └── integration_test.go │ │ └── notification │ │ ├── notification.go │ │ └── notification_test.go ├── goModulesExample │ ├── go.mod │ ├── go.sum │ ├── main.go │ └── vendor │ │ ├── github.com │ │ ├── gin-contrib │ │ │ └── sse │ │ │ │ ├── .travis.yml │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── sse-decoder.go │ │ │ │ ├── sse-encoder.go │ │ │ │ └── writer.go │ │ ├── gin-gonic │ │ │ └── gin │ │ │ │ ├── .gitignore │ │ │ │ ├── .travis.yml │ │ │ │ ├── AUTHORS.md │ │ │ │ ├── BENCHMARKS.md │ │ │ │ ├── CHANGELOG.md │ │ │ │ ├── CODE_OF_CONDUCT.md │ │ │ │ ├── CONTRIBUTING.md │ │ │ │ ├── LICENSE │ │ │ │ ├── Makefile │ │ │ │ ├── README.md │ │ │ │ ├── auth.go │ │ │ │ ├── binding │ │ │ │ ├── binding.go │ │ │ │ ├── binding_nomsgpack.go │ │ │ │ ├── default_validator.go │ │ │ │ ├── form.go │ │ │ │ ├── form_mapping.go │ │ │ │ ├── header.go │ │ │ │ ├── json.go │ │ │ │ ├── msgpack.go │ │ │ │ ├── multipart_form_mapping.go │ │ │ │ ├── protobuf.go │ │ │ │ ├── query.go │ │ │ │ ├── uri.go │ │ │ │ ├── xml.go │ │ │ │ └── yaml.go │ │ │ │ ├── codecov.yml │ │ │ │ ├── context.go │ │ │ │ ├── context_appengine.go │ │ │ │ ├── debug.go │ │ │ │ ├── deprecated.go │ │ │ │ ├── doc.go │ │ │ │ ├── errors.go │ │ │ │ ├── fs.go │ │ │ │ ├── gin.go │ │ │ │ ├── internal │ │ │ │ ├── bytesconv │ │ │ │ │ └── bytesconv.go │ │ │ │ └── json │ │ │ │ │ ├── json.go │ │ │ │ │ └── jsoniter.go │ │ │ │ ├── logger.go │ │ │ │ ├── mode.go │ │ │ │ ├── path.go │ │ │ │ ├── recovery.go │ │ │ │ ├── render │ │ │ │ ├── data.go │ │ │ │ ├── html.go │ │ │ │ ├── json.go │ │ │ │ ├── msgpack.go │ │ │ │ ├── protobuf.go │ │ │ │ ├── reader.go │ │ │ │ ├── redirect.go │ │ │ │ ├── render.go │ │ │ │ ├── text.go │ │ │ │ ├── xml.go │ │ │ │ └── yaml.go │ │ │ │ ├── response_writer.go │ │ │ │ ├── routergroup.go │ │ │ │ ├── test_helpers.go │ │ │ │ ├── tree.go │ │ │ │ ├── utils.go │ │ │ │ └── version.go │ │ ├── go-playground │ │ │ ├── locales │ │ │ │ ├── .gitignore │ │ │ │ ├── .travis.yml │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── currency │ │ │ │ │ └── currency.go │ │ │ │ ├── logo.png │ │ │ │ └── rules.go │ │ │ ├── universal-translator │ │ │ │ ├── .gitignore │ │ │ │ ├── .travis.yml │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── errors.go │ │ │ │ ├── import_export.go │ │ │ │ ├── logo.png │ │ │ │ ├── translator.go │ │ │ │ └── universal_translator.go │ │ │ └── validator │ │ │ │ └── v10 │ │ │ │ ├── .gitignore │ │ │ │ ├── .travis.yml │ │ │ │ ├── LICENSE │ │ │ │ ├── Makefile │ │ │ │ ├── README.md │ │ │ │ ├── baked_in.go │ │ │ │ ├── cache.go │ │ │ │ ├── country_codes.go │ │ │ │ ├── doc.go │ │ │ │ ├── errors.go │ │ │ │ ├── field_level.go │ │ │ │ ├── logo.png │ │ │ │ ├── regexes.go │ │ │ │ ├── struct_level.go │ │ │ │ ├── translations.go │ │ │ │ ├── util.go │ │ │ │ ├── validator.go │ │ │ │ └── validator_instance.go │ │ ├── golang │ │ │ └── protobuf │ │ │ │ ├── AUTHORS │ │ │ │ ├── CONTRIBUTORS │ │ │ │ ├── LICENSE │ │ │ │ └── proto │ │ │ │ ├── clone.go │ │ │ │ ├── decode.go │ │ │ │ ├── deprecated.go │ │ │ │ ├── discard.go │ │ │ │ ├── encode.go │ │ │ │ ├── equal.go │ │ │ │ ├── extensions.go │ │ │ │ ├── lib.go │ │ │ │ ├── message_set.go │ │ │ │ ├── pointer_reflect.go │ │ │ │ ├── pointer_unsafe.go │ │ │ │ ├── properties.go │ │ │ │ ├── table_marshal.go │ │ │ │ ├── table_merge.go │ │ │ │ ├── table_unmarshal.go │ │ │ │ ├── text.go │ │ │ │ └── text_parser.go │ │ ├── json-iterator │ │ │ └── go │ │ │ │ ├── .codecov.yml │ │ │ │ ├── .gitignore │ │ │ │ ├── .travis.yml │ │ │ │ ├── Gopkg.lock │ │ │ │ ├── Gopkg.toml │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── adapter.go │ │ │ │ ├── any.go │ │ │ │ ├── any_array.go │ │ │ │ ├── any_bool.go │ │ │ │ ├── any_float.go │ │ │ │ ├── any_int32.go │ │ │ │ ├── any_int64.go │ │ │ │ ├── any_invalid.go │ │ │ │ ├── any_nil.go │ │ │ │ ├── any_number.go │ │ │ │ ├── any_object.go │ │ │ │ ├── any_str.go │ │ │ │ ├── any_uint32.go │ │ │ │ ├── any_uint64.go │ │ │ │ ├── build.sh │ │ │ │ ├── config.go │ │ │ │ ├── fuzzy_mode_convert_table.md │ │ │ │ ├── iter.go │ │ │ │ ├── iter_array.go │ │ │ │ ├── iter_float.go │ │ │ │ ├── iter_int.go │ │ │ │ ├── iter_object.go │ │ │ │ ├── iter_skip.go │ │ │ │ ├── iter_skip_sloppy.go │ │ │ │ ├── iter_skip_strict.go │ │ │ │ ├── iter_str.go │ │ │ │ ├── jsoniter.go │ │ │ │ ├── pool.go │ │ │ │ ├── reflect.go │ │ │ │ ├── reflect_array.go │ │ │ │ ├── reflect_dynamic.go │ │ │ │ ├── reflect_extension.go │ │ │ │ ├── reflect_json_number.go │ │ │ │ ├── reflect_json_raw_message.go │ │ │ │ ├── reflect_map.go │ │ │ │ ├── reflect_marshaler.go │ │ │ │ ├── reflect_native.go │ │ │ │ ├── reflect_optional.go │ │ │ │ ├── reflect_slice.go │ │ │ │ ├── reflect_struct_decoder.go │ │ │ │ ├── reflect_struct_encoder.go │ │ │ │ ├── stream.go │ │ │ │ ├── stream_float.go │ │ │ │ ├── stream_int.go │ │ │ │ ├── stream_str.go │ │ │ │ └── test.sh │ │ ├── leodido │ │ │ └── go-urn │ │ │ │ ├── .gitignore │ │ │ │ ├── .travis.yml │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── machine.go │ │ │ │ ├── machine.go.rl │ │ │ │ ├── makefile │ │ │ │ └── urn.go │ │ ├── mattn │ │ │ └── go-isatty │ │ │ │ ├── .travis.yml │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── doc.go │ │ │ │ ├── go.test.sh │ │ │ │ ├── isatty_bsd.go │ │ │ │ ├── isatty_others.go │ │ │ │ ├── isatty_plan9.go │ │ │ │ ├── isatty_solaris.go │ │ │ │ ├── isatty_tcgets.go │ │ │ │ ├── isatty_windows.go │ │ │ │ └── renovate.json │ │ ├── modern-go │ │ │ ├── concurrent │ │ │ │ ├── .gitignore │ │ │ │ ├── .travis.yml │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── executor.go │ │ │ │ ├── go_above_19.go │ │ │ │ ├── go_below_19.go │ │ │ │ ├── log.go │ │ │ │ ├── test.sh │ │ │ │ └── unbounded_executor.go │ │ │ └── reflect2 │ │ │ │ ├── .gitignore │ │ │ │ ├── .travis.yml │ │ │ │ ├── Gopkg.lock │ │ │ │ ├── Gopkg.toml │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── go_above_17.go │ │ │ │ ├── go_above_19.go │ │ │ │ ├── go_below_17.go │ │ │ │ ├── go_below_19.go │ │ │ │ ├── reflect2.go │ │ │ │ ├── reflect2_amd64.s │ │ │ │ ├── reflect2_kind.go │ │ │ │ ├── relfect2_386.s │ │ │ │ ├── relfect2_amd64p32.s │ │ │ │ ├── relfect2_arm.s │ │ │ │ ├── relfect2_arm64.s │ │ │ │ ├── relfect2_mips64x.s │ │ │ │ ├── relfect2_mipsx.s │ │ │ │ ├── relfect2_ppc64x.s │ │ │ │ ├── relfect2_s390x.s │ │ │ │ ├── safe_field.go │ │ │ │ ├── safe_map.go │ │ │ │ ├── safe_slice.go │ │ │ │ ├── safe_struct.go │ │ │ │ ├── safe_type.go │ │ │ │ ├── test.sh │ │ │ │ ├── type_map.go │ │ │ │ ├── unsafe_array.go │ │ │ │ ├── unsafe_eface.go │ │ │ │ ├── unsafe_field.go │ │ │ │ ├── unsafe_iface.go │ │ │ │ ├── unsafe_link.go │ │ │ │ ├── unsafe_map.go │ │ │ │ ├── unsafe_ptr.go │ │ │ │ ├── unsafe_slice.go │ │ │ │ ├── unsafe_struct.go │ │ │ │ └── unsafe_type.go │ │ └── ugorji │ │ │ └── go │ │ │ └── codec │ │ │ ├── 0_importpath.go │ │ │ ├── LICENSE │ │ │ ├── binc.go │ │ │ ├── build.sh │ │ │ ├── cbor.go │ │ │ ├── codecgen.go │ │ │ ├── decode.go │ │ │ ├── doc.go │ │ │ ├── encode.go │ │ │ ├── fast-path.generated.go │ │ │ ├── fast-path.go.tmpl │ │ │ ├── fast-path.not.go │ │ │ ├── float.go │ │ │ ├── gen-dec-array.go.tmpl │ │ │ ├── gen-dec-map.go.tmpl │ │ │ ├── gen-enc-chan.go.tmpl │ │ │ ├── gen-helper.generated.go │ │ │ ├── gen-helper.go.tmpl │ │ │ ├── gen.generated.go │ │ │ ├── gen.go │ │ │ ├── goversion_arrayof_gte_go15.go │ │ │ ├── goversion_arrayof_lt_go15.go │ │ │ ├── goversion_fmt_time_gte_go15.go │ │ │ ├── goversion_fmt_time_lt_go15.go │ │ │ ├── goversion_makemap_gte_go19.go │ │ │ ├── goversion_makemap_lt_go19.go │ │ │ ├── goversion_maprange_gte_go112.go │ │ │ ├── goversion_maprange_lt_go112.go │ │ │ ├── goversion_unexportedembeddedptr_gte_go110.go │ │ │ ├── goversion_unexportedembeddedptr_lt_go110.go │ │ │ ├── goversion_unsupported_lt_go14.go │ │ │ ├── goversion_vendor_eq_go15.go │ │ │ ├── goversion_vendor_eq_go16.go │ │ │ ├── goversion_vendor_gte_go17.go │ │ │ ├── goversion_vendor_lt_go15.go │ │ │ ├── helper.go │ │ │ ├── helper.s │ │ │ ├── helper_internal.go │ │ │ ├── helper_not_unsafe.go │ │ │ ├── helper_unsafe.go │ │ │ ├── json.go │ │ │ ├── mammoth-test.go.tmpl │ │ │ ├── mammoth2-test.go.tmpl │ │ │ ├── msgpack.go │ │ │ ├── prebuild.go │ │ │ ├── reader.go │ │ │ ├── register_ext.go │ │ │ ├── rpc.go │ │ │ ├── simple.go │ │ │ ├── sort-slice.generated.go │ │ │ ├── sort-slice.go.tmpl │ │ │ ├── test-cbor-goldens.json │ │ │ ├── test.py │ │ │ └── writer.go │ │ ├── golang.org │ │ └── x │ │ │ ├── crypto │ │ │ ├── AUTHORS │ │ │ ├── CONTRIBUTORS │ │ │ ├── LICENSE │ │ │ ├── PATENTS │ │ │ └── sha3 │ │ │ │ ├── doc.go │ │ │ │ ├── hashes.go │ │ │ │ ├── hashes_generic.go │ │ │ │ ├── keccakf.go │ │ │ │ ├── keccakf_amd64.go │ │ │ │ ├── keccakf_amd64.s │ │ │ │ ├── register.go │ │ │ │ ├── sha3.go │ │ │ │ ├── sha3_s390x.go │ │ │ │ ├── sha3_s390x.s │ │ │ │ ├── shake.go │ │ │ │ ├── shake_generic.go │ │ │ │ ├── xor.go │ │ │ │ ├── xor_generic.go │ │ │ │ └── xor_unaligned.go │ │ │ └── sys │ │ │ ├── AUTHORS │ │ │ ├── CONTRIBUTORS │ │ │ ├── LICENSE │ │ │ ├── PATENTS │ │ │ ├── cpu │ │ │ ├── asm_aix_ppc64.s │ │ │ ├── byteorder.go │ │ │ ├── cpu.go │ │ │ ├── cpu_aix_ppc64.go │ │ │ ├── cpu_arm.go │ │ │ ├── cpu_arm64.go │ │ │ ├── cpu_arm64.s │ │ │ ├── cpu_gc_arm64.go │ │ │ ├── cpu_gc_s390x.go │ │ │ ├── cpu_gc_x86.go │ │ │ ├── cpu_gccgo_arm64.go │ │ │ ├── cpu_gccgo_s390x.go │ │ │ ├── cpu_gccgo_x86.c │ │ │ ├── cpu_gccgo_x86.go │ │ │ ├── cpu_linux.go │ │ │ ├── cpu_linux_arm.go │ │ │ ├── cpu_linux_arm64.go │ │ │ ├── cpu_linux_noinit.go │ │ │ ├── cpu_linux_ppc64x.go │ │ │ ├── cpu_linux_s390x.go │ │ │ ├── cpu_mips64x.go │ │ │ ├── cpu_mipsx.go │ │ │ ├── cpu_other_arm64.go │ │ │ ├── cpu_riscv64.go │ │ │ ├── cpu_s390x.s │ │ │ ├── cpu_wasm.go │ │ │ ├── cpu_x86.go │ │ │ ├── cpu_x86.s │ │ │ ├── hwcap_linux.go │ │ │ └── syscall_aix_ppc64_gc.go │ │ │ └── unix │ │ │ ├── .gitignore │ │ │ ├── README.md │ │ │ ├── affinity_linux.go │ │ │ ├── aliases.go │ │ │ ├── asm_aix_ppc64.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_freebsd_arm64.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_riscv64.s │ │ │ ├── asm_linux_s390x.s │ │ │ ├── asm_netbsd_386.s │ │ │ ├── asm_netbsd_amd64.s │ │ │ ├── asm_netbsd_arm.s │ │ │ ├── asm_netbsd_arm64.s │ │ │ ├── asm_openbsd_386.s │ │ │ ├── asm_openbsd_amd64.s │ │ │ ├── asm_openbsd_arm.s │ │ │ ├── asm_openbsd_arm64.s │ │ │ ├── asm_solaris_amd64.s │ │ │ ├── bluetooth_linux.go │ │ │ ├── cap_freebsd.go │ │ │ ├── constants.go │ │ │ ├── dev_aix_ppc.go │ │ │ ├── dev_aix_ppc64.go │ │ │ ├── dev_darwin.go │ │ │ ├── dev_dragonfly.go │ │ │ ├── dev_freebsd.go │ │ │ ├── dev_linux.go │ │ │ ├── dev_netbsd.go │ │ │ ├── dev_openbsd.go │ │ │ ├── dirent.go │ │ │ ├── endian_big.go │ │ │ ├── endian_little.go │ │ │ ├── env_unix.go │ │ │ ├── errors_freebsd_386.go │ │ │ ├── errors_freebsd_amd64.go │ │ │ ├── errors_freebsd_arm.go │ │ │ ├── fcntl.go │ │ │ ├── fcntl_darwin.go │ │ │ ├── fcntl_linux_32bit.go │ │ │ ├── fdset.go │ │ │ ├── gccgo.go │ │ │ ├── gccgo_c.c │ │ │ ├── gccgo_linux_amd64.go │ │ │ ├── ioctl.go │ │ │ ├── mkall.sh │ │ │ ├── mkerrors.sh │ │ │ ├── pagesize_unix.go │ │ │ ├── pledge_openbsd.go │ │ │ ├── race.go │ │ │ ├── race0.go │ │ │ ├── readdirent_getdents.go │ │ │ ├── readdirent_getdirentries.go │ │ │ ├── sockcmsg_dragonfly.go │ │ │ ├── sockcmsg_linux.go │ │ │ ├── sockcmsg_unix.go │ │ │ ├── sockcmsg_unix_other.go │ │ │ ├── str.go │ │ │ ├── syscall.go │ │ │ ├── syscall_aix.go │ │ │ ├── syscall_aix_ppc.go │ │ │ ├── syscall_aix_ppc64.go │ │ │ ├── syscall_bsd.go │ │ │ ├── syscall_darwin.1_12.go │ │ │ ├── syscall_darwin.1_13.go │ │ │ ├── syscall_darwin.go │ │ │ ├── syscall_darwin_386.1_11.go │ │ │ ├── syscall_darwin_386.go │ │ │ ├── syscall_darwin_amd64.1_11.go │ │ │ ├── syscall_darwin_amd64.go │ │ │ ├── syscall_darwin_arm.1_11.go │ │ │ ├── syscall_darwin_arm.go │ │ │ ├── syscall_darwin_arm64.1_11.go │ │ │ ├── syscall_darwin_arm64.go │ │ │ ├── syscall_darwin_libSystem.go │ │ │ ├── syscall_dragonfly.go │ │ │ ├── syscall_dragonfly_amd64.go │ │ │ ├── syscall_freebsd.go │ │ │ ├── syscall_freebsd_386.go │ │ │ ├── syscall_freebsd_amd64.go │ │ │ ├── syscall_freebsd_arm.go │ │ │ ├── syscall_freebsd_arm64.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_gc.go │ │ │ ├── syscall_linux_gc_386.go │ │ │ ├── syscall_linux_gccgo_386.go │ │ │ ├── syscall_linux_gccgo_arm.go │ │ │ ├── syscall_linux_mips64x.go │ │ │ ├── syscall_linux_mipsx.go │ │ │ ├── syscall_linux_ppc64x.go │ │ │ ├── syscall_linux_riscv64.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_netbsd_arm64.go │ │ │ ├── syscall_openbsd.go │ │ │ ├── syscall_openbsd_386.go │ │ │ ├── syscall_openbsd_amd64.go │ │ │ ├── syscall_openbsd_arm.go │ │ │ ├── syscall_openbsd_arm64.go │ │ │ ├── syscall_solaris.go │ │ │ ├── syscall_solaris_amd64.go │ │ │ ├── syscall_unix.go │ │ │ ├── syscall_unix_gc.go │ │ │ ├── syscall_unix_gc_ppc64x.go │ │ │ ├── timestruct.go │ │ │ ├── unveil_openbsd.go │ │ │ ├── xattr_bsd.go │ │ │ ├── zerrors_aix_ppc.go │ │ │ ├── zerrors_aix_ppc64.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_freebsd_arm64.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_riscv64.go │ │ │ ├── zerrors_linux_s390x.go │ │ │ ├── zerrors_linux_sparc64.go │ │ │ ├── zerrors_netbsd_386.go │ │ │ ├── zerrors_netbsd_amd64.go │ │ │ ├── zerrors_netbsd_arm.go │ │ │ ├── zerrors_netbsd_arm64.go │ │ │ ├── zerrors_openbsd_386.go │ │ │ ├── zerrors_openbsd_amd64.go │ │ │ ├── zerrors_openbsd_arm.go │ │ │ ├── zerrors_openbsd_arm64.go │ │ │ ├── zerrors_solaris_amd64.go │ │ │ ├── zptrace_armnn_linux.go │ │ │ ├── zptrace_linux_arm64.go │ │ │ ├── zptrace_mipsnn_linux.go │ │ │ ├── zptrace_mipsnnle_linux.go │ │ │ ├── zptrace_x86_linux.go │ │ │ ├── zsyscall_aix_ppc.go │ │ │ ├── zsyscall_aix_ppc64.go │ │ │ ├── zsyscall_aix_ppc64_gc.go │ │ │ ├── zsyscall_aix_ppc64_gccgo.go │ │ │ ├── zsyscall_darwin_386.1_11.go │ │ │ ├── zsyscall_darwin_386.1_13.go │ │ │ ├── zsyscall_darwin_386.1_13.s │ │ │ ├── zsyscall_darwin_386.go │ │ │ ├── zsyscall_darwin_386.s │ │ │ ├── zsyscall_darwin_amd64.1_11.go │ │ │ ├── zsyscall_darwin_amd64.1_13.go │ │ │ ├── zsyscall_darwin_amd64.1_13.s │ │ │ ├── zsyscall_darwin_amd64.go │ │ │ ├── zsyscall_darwin_amd64.s │ │ │ ├── zsyscall_darwin_arm.1_11.go │ │ │ ├── zsyscall_darwin_arm.1_13.go │ │ │ ├── zsyscall_darwin_arm.1_13.s │ │ │ ├── zsyscall_darwin_arm.go │ │ │ ├── zsyscall_darwin_arm.s │ │ │ ├── zsyscall_darwin_arm64.1_11.go │ │ │ ├── zsyscall_darwin_arm64.1_13.go │ │ │ ├── zsyscall_darwin_arm64.1_13.s │ │ │ ├── zsyscall_darwin_arm64.go │ │ │ ├── zsyscall_darwin_arm64.s │ │ │ ├── zsyscall_dragonfly_amd64.go │ │ │ ├── zsyscall_freebsd_386.go │ │ │ ├── zsyscall_freebsd_amd64.go │ │ │ ├── zsyscall_freebsd_arm.go │ │ │ ├── zsyscall_freebsd_arm64.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_riscv64.go │ │ │ ├── zsyscall_linux_s390x.go │ │ │ ├── zsyscall_linux_sparc64.go │ │ │ ├── zsyscall_netbsd_386.go │ │ │ ├── zsyscall_netbsd_amd64.go │ │ │ ├── zsyscall_netbsd_arm.go │ │ │ ├── zsyscall_netbsd_arm64.go │ │ │ ├── zsyscall_openbsd_386.go │ │ │ ├── zsyscall_openbsd_amd64.go │ │ │ ├── zsyscall_openbsd_arm.go │ │ │ ├── zsyscall_openbsd_arm64.go │ │ │ ├── zsyscall_solaris_amd64.go │ │ │ ├── zsysctl_openbsd_386.go │ │ │ ├── zsysctl_openbsd_amd64.go │ │ │ ├── zsysctl_openbsd_arm.go │ │ │ ├── zsysctl_openbsd_arm64.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_freebsd_arm64.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_riscv64.go │ │ │ ├── zsysnum_linux_s390x.go │ │ │ ├── zsysnum_linux_sparc64.go │ │ │ ├── zsysnum_netbsd_386.go │ │ │ ├── zsysnum_netbsd_amd64.go │ │ │ ├── zsysnum_netbsd_arm.go │ │ │ ├── zsysnum_netbsd_arm64.go │ │ │ ├── zsysnum_openbsd_386.go │ │ │ ├── zsysnum_openbsd_amd64.go │ │ │ ├── zsysnum_openbsd_arm.go │ │ │ ├── zsysnum_openbsd_arm64.go │ │ │ ├── ztypes_aix_ppc.go │ │ │ ├── ztypes_aix_ppc64.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_freebsd_arm64.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_riscv64.go │ │ │ ├── ztypes_linux_s390x.go │ │ │ ├── ztypes_linux_sparc64.go │ │ │ ├── ztypes_netbsd_386.go │ │ │ ├── ztypes_netbsd_amd64.go │ │ │ ├── ztypes_netbsd_arm.go │ │ │ ├── ztypes_netbsd_arm64.go │ │ │ ├── ztypes_openbsd_386.go │ │ │ ├── ztypes_openbsd_amd64.go │ │ │ ├── ztypes_openbsd_arm.go │ │ │ ├── ztypes_openbsd_arm64.go │ │ │ └── ztypes_solaris_amd64.go │ │ ├── gopkg.in │ │ └── yaml.v2 │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── LICENSE.libyaml │ │ │ ├── NOTICE │ │ │ ├── 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 │ │ └── modules.txt ├── gofmtSimplify.go ├── internalDirectory │ ├── cmd │ │ └── main.go │ ├── internal │ │ └── structures │ │ │ ├── types.go │ │ │ └── types_test.go │ └── pkg │ │ └── api │ │ ├── api.go │ │ └── api_test.go ├── patternDirectory │ └── notifications │ │ ├── email.go │ │ ├── email_test.go │ │ ├── pagerduty.go │ │ ├── pagerduty_test.go │ │ ├── pushnotify.go │ │ ├── pushnotify_test.go │ │ ├── slack.go │ │ ├── slack_test.go │ │ ├── trello.go │ │ └── trello_test.go ├── reflectionKinds.go ├── reflectionTypes.go ├── reflectionValues.go ├── tmp.go ├── userMethod.go └── userMethodPointer.go ├── 7-template-programming-in-go ├── clitooling │ ├── cmd │ │ ├── date.go │ │ └── go.mod │ ├── go.mod │ ├── go.sum │ └── main.go ├── grpcExample │ ├── client │ │ └── main.go │ ├── go.mod │ ├── go.sum │ ├── server │ │ └── main.go │ └── userinfo │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── userinfo.go │ │ ├── userinfo.pb.go │ │ └── userinfo.proto ├── serialNumber.go └── templates │ ├── html │ ├── htmlTemplate.go │ └── tmp.html │ ├── sprig │ ├── default.go │ ├── go.mod │ ├── go.sum │ ├── jsonPrettyPrint.go │ ├── stringSlices.go │ └── strings.go │ └── text │ └── textTemplate.go ├── 8-memory-management ├── 8-memory-management ├── elf.go ├── elfReader.go ├── escapeAnalysis │ ├── out │ ├── simpleEscapeAnalysis │ └── simpleEscapeAnalysis.go ├── server ├── server.go ├── simpleProgramMemoryStats │ ├── simpleProgramMemoryStats │ └── simpleProgramMemoryStats.go ├── simpleServer │ ├── simpleServer │ └── simpleServer.go ├── simpleServerGCStats │ ├── simpleServerGCStats │ └── simpleServerGCStats.go └── simpleServerMemoryStats │ ├── simpleServerMemoryStats │ └── simpleServerMemoryStats.go ├── 9-gpu-parallelization-in-go ├── cgo │ ├── benchmarkCgo.go │ ├── benchmarkCgo_test.go │ └── cgo.go ├── cuda │ ├── Makefile │ ├── cuda_add.cu │ ├── cuda_add.go │ └── cuda_add.h ├── docker_cuda │ ├── Dockerfile │ ├── Makefile │ ├── cuda_multiply.cpp │ ├── cuda_multiply.cu │ ├── cuda_multiply.go │ └── cuda_multiply.h └── gcp_scripts │ └── nvidia-cuda-gcp-setup.sh ├── README.md └── frequency_scaling_governor_diable.bash /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | *.swp 8 | # Test binary, build with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | 1-introduction/go 14 | -------------------------------------------------------------------------------- /1-introduction/benchmarksort.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | git clone https://github.com/golang/go/ 3 | GODEV=$(pwd)/go 4 | cd go/src 5 | GOROOT_BOOTSTRAP=$(go env GOROOT) ./make.bash 6 | $GODEV/bin/go test -bench=. -v sort -run TestSearch 7 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/bobstrecansky/HighPerformanceWithGo/10-runtime-evaluations-in-go/build 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect 7 | github.com/modern-go/reflect2 v1.0.1 // indirect 8 | github.com/prometheus/client_golang v1.1.0 9 | ) 10 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/prometheusMetrics: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/10-runtime-evaluations-in-go/build/prometheusMetrics -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/prometheusMetrics.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/prometheus/client_golang/prometheus/promhttp" 7 | ) 8 | 9 | func main() { 10 | http.Handle("/promMetrics", promhttp.Handler()) 11 | http.ListenAndServe(":1234", nil) 12 | } 13 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/github.com/golang/protobuf/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/github.com/golang/protobuf/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/github.com/matttproud/golang_protobuf_extensions/NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2012 Matt T. Proud (matt.proud@gmail.com) 2 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/github.com/matttproud/golang_protobuf_extensions/pbutil/.gitignore: -------------------------------------------------------------------------------- 1 | cover.dat 2 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/github.com/matttproud/golang_protobuf_extensions/pbutil/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | 3 | cover: 4 | go test -cover -v -coverprofile=cover.dat ./... 5 | go tool cover -func cover.dat 6 | 7 | .PHONY: cover 8 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/github.com/prometheus/client_golang/prometheus/.gitignore: -------------------------------------------------------------------------------- 1 | command-line-arguments.test 2 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/github.com/prometheus/client_golang/prometheus/README.md: -------------------------------------------------------------------------------- 1 | See [![go-doc](https://godoc.org/github.com/prometheus/client_golang/prometheus?status.svg)](https://godoc.org/github.com/prometheus/client_golang/prometheus). 2 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/github.com/prometheus/client_model/NOTICE: -------------------------------------------------------------------------------- 1 | Data model artifacts for Prometheus. 2 | Copyright 2012-2015 The Prometheus Authors 3 | 4 | This product includes software developed at 5 | SoundCloud Ltd. (http://soundcloud.com/). 6 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/github.com/prometheus/common/NOTICE: -------------------------------------------------------------------------------- 1 | Common libraries shared by Prometheus Go components. 2 | Copyright 2015 The Prometheus Authors 3 | 4 | This product includes software developed at 5 | SoundCloud Ltd. (http://soundcloud.com/). 6 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/github.com/prometheus/procfs/.gitignore: -------------------------------------------------------------------------------- 1 | /fixtures/ 2 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/github.com/prometheus/procfs/.golangci.yml: -------------------------------------------------------------------------------- 1 | # Run only staticcheck for now. Additional linters will be enabled one-by-one. 2 | linters: 3 | enable: 4 | - staticcheck 5 | - govet 6 | disable-all: true 7 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/github.com/prometheus/procfs/MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | * Johannes 'fish' Ziemke @discordianfish 2 | * Paul Gier @pgier 3 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/github.com/prometheus/procfs/NOTICE: -------------------------------------------------------------------------------- 1 | procfs provides functions to retrieve system, kernel and process 2 | metrics from the pseudo-filesystem proc. 3 | 4 | Copyright 2014-2015 The Prometheus Authors 5 | 6 | This product includes software developed at 7 | SoundCloud Ltd. (http://soundcloud.com/). 8 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/github.com/prometheus/procfs/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/prometheus/procfs 2 | 3 | require ( 4 | github.com/google/go-cmp v0.3.0 5 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 6 | ) 7 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/github.com/prometheus/procfs/go.sum: -------------------------------------------------------------------------------- 1 | github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= 2 | github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 3 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= 4 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 5 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/golang.org/x/sys/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/golang.org/x/sys/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/golang.org/x/sys/windows/aliases.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | // +build go1.9 7 | 8 | package windows 9 | 10 | import "syscall" 11 | 12 | type Errno = syscall.Errno 13 | type SysProcAttr = syscall.SysProcAttr 14 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/golang.org/x/sys/windows/asm_windows_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 | // 6 | // System calls for 386, Windows are implemented in runtime/syscall_windows.goc 7 | // 8 | 9 | TEXT ·getprocaddress(SB), 7, $0-16 10 | JMP syscall·getprocaddress(SB) 11 | 12 | TEXT ·loadlibrary(SB), 7, $0-12 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/golang.org/x/sys/windows/asm_windows_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 | // 6 | // System calls for amd64, Windows are implemented in runtime/syscall_windows.goc 7 | // 8 | 9 | TEXT ·getprocaddress(SB), 7, $0-32 10 | JMP syscall·getprocaddress(SB) 11 | 12 | TEXT ·loadlibrary(SB), 7, $0-24 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/golang.org/x/sys/windows/asm_windows_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | #include "textflag.h" 6 | 7 | TEXT ·getprocaddress(SB),NOSPLIT,$0 8 | B syscall·getprocaddress(SB) 9 | 10 | TEXT ·loadlibrary(SB),NOSPLIT,$0 11 | B syscall·loadlibrary(SB) 12 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/golang.org/x/sys/windows/mksyscall.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 generate 6 | 7 | package windows 8 | 9 | //go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go eventlog.go service.go syscall_windows.go security_windows.go 10 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/golang.org/x/sys/windows/race0.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 windows,!race 6 | 7 | package windows 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/golang.org/x/sys/windows/str.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 windows 6 | 7 | package windows 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + itoa(-val) 12 | } 13 | var buf [32]byte // big enough for int64 14 | i := len(buf) - 1 15 | for val >= 10 { 16 | buf[i] = byte(val%10 + '0') 17 | i-- 18 | val /= 10 19 | } 20 | buf[i] = byte(val + '0') 21 | return string(buf[i:]) 22 | } 23 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/golang.org/x/sys/windows/types_windows_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | Description [WSADESCRIPTION_LEN + 1]byte 11 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 12 | MaxSockets uint16 13 | MaxUdpDg uint16 14 | VendorInfo *byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Port uint16 21 | Proto *byte 22 | } 23 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/golang.org/x/sys/windows/types_windows_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | MaxSockets uint16 11 | MaxUdpDg uint16 12 | VendorInfo *byte 13 | Description [WSADESCRIPTION_LEN + 1]byte 14 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Proto *byte 21 | Port uint16 22 | } 23 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/build/vendor/golang.org/x/sys/windows/types_windows_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | Description [WSADESCRIPTION_LEN + 1]byte 11 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 12 | MaxSockets uint16 13 | MaxUdpDg uint16 14 | VendorInfo *byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Port uint16 21 | Proto *byte 22 | } 23 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/gogc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export GOGC=off 3 | printf "\nBuild with GOGC=off:" 4 | time go build -a std 5 | printf "\nBuild with GOGC=50:" 6 | export GOGC=50 7 | time go build -a std 8 | for i in 0 500 1000 1500 2000 9 | do 10 | printf "\nBuild with GOGC = $i:" 11 | export GOGC=$i 12 | time go build -a std 13 | done 14 | 15 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/gomaxprocs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for i in 1 2 3 4 4 | do 5 | export GOMAXPROCS=$i 6 | printf "\nBuild with GOMAXPROCS=$i:" 7 | time go build -a std 8 | done 9 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/keepalive/keepalive.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "runtime" 6 | "syscall" 7 | ) 8 | 9 | func main() { 10 | type File struct{ d int } 11 | d, err := syscall.Open("./testfile.txt", syscall.O_RDONLY, 0) 12 | if err != nil { 13 | fmt.Println(err) 14 | } 15 | p := &File{d} 16 | runtime.SetFinalizer(p, func(p *File) { syscall.Close(p.d) }) 17 | var buf [10]byte 18 | n, err := syscall.Read(p.d, buf[:]) 19 | if err != nil { 20 | fmt.Println(err) 21 | } 22 | runtime.KeepAlive(p) 23 | fmt.Println(n) 24 | fmt.Println(p) 25 | } 26 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/keepalive/testfile.txt: -------------------------------------------------------------------------------- 1 | Go is Awesome 2 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/numcpu/numcpu.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "runtime" 6 | ) 7 | 8 | func main() { 9 | fmt.Println("Number of CPUs Available: ", runtime.NumCPU()) 10 | } 11 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/runtime/gctraceExample: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/10-runtime-evaluations-in-go/runtime/gctraceExample -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/runtime/gctraceExample.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | ) 7 | 8 | func hello(w http.ResponseWriter, r *http.Request) { 9 | fmt.Fprintf(w, "Hello Gophers") 10 | } 11 | 12 | func main() { 13 | http.HandleFunc("/", hello) 14 | err := http.ListenAndServe(":8080", nil) 15 | if err != nil { 16 | fmt.Println(err) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/runtime/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/bobstrecansky/HighPerformanceWithGo/10-runtime-evaluations-in-go/runtime 2 | 3 | go 1.12 4 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/runtime/go.sum: -------------------------------------------------------------------------------- 1 | github.com/bobstrecansky/HighPerformanceWithGo v0.0.0-20190806225535-5d776858db53 h1:1eAI/VtBrlbxphF8vqmtvWeRrrhttn435OrXciCnwk4= 2 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/traceback.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | func main() { 8 | c := make(chan bool, 1) 9 | go panicRoutine(c) 10 | for i := 0; i < 2; i++ { 11 | <-c 12 | } 13 | } 14 | 15 | func panicRoutine(c chan bool) { 16 | time.Sleep(100 * time.Millisecond) 17 | panic("Goroutine Panic") 18 | c <- true 19 | } 20 | -------------------------------------------------------------------------------- /10-runtime-evaluations-in-go/traceback/traceback.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "time" 5 | ) 6 | 7 | func main() { 8 | c := make(chan bool, 1) 9 | go panicRoutine(c) 10 | for i := 0; i < 2; i++ { 11 | <-c 12 | } 13 | } 14 | 15 | func panicRoutine(c chan bool) { 16 | time.Sleep(100 * time.Millisecond) 17 | panic("Goroutine Panic") 18 | c <- true 19 | } 20 | -------------------------------------------------------------------------------- /11-deploying-go-code/compilerLinker/Optimized: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/11-deploying-go-code/compilerLinker/Optimized -------------------------------------------------------------------------------- /11-deploying-go-code/compilerLinker/compilerLinkerFlags.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | var linkerFlag string 6 | 7 | func main() { 8 | fmt.Println(linkerFlag) 9 | } 10 | -------------------------------------------------------------------------------- /11-deploying-go-code/compilerLinker/nonOptimized: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/11-deploying-go-code/compilerLinker/nonOptimized -------------------------------------------------------------------------------- /11-deploying-go-code/goList/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/bobstrecansky/HighPerformanceWithGo/11-deploying-go-code/goList 2 | -------------------------------------------------------------------------------- /11-deploying-go-code/goList/goListExample.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "math" 6 | ) 7 | 8 | func main() { 9 | fmt.Println("Hello Gophers") 10 | fmt.Println(math.Sqrt(64)) 11 | } 12 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/Dockerfile: -------------------------------------------------------------------------------- 1 | # Builder - stage 1 of 2 2 | FROM golang:alpine as builder 3 | COPY . /src 4 | WORKDIR /src 5 | RUN CGO_ENABLED=0 GOOS=linux go build -mod=vendor -o zapLoggerExample 6 | 7 | # Executor - stage 2 of 2 8 | FROM alpine:latest 9 | WORKDIR /src/ 10 | COPY --from=builder /src/zapLoggerExample . 11 | CMD ["./zapLoggerExample"] 12 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/bobstrecansky/HighPerformanceWithGo/11-deploying-go-code/multiStageDockerBuild 2 | 3 | go 1.13 4 | 5 | require go.uber.org/zap v1.14.0 6 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/github.com/BurntSushi/toml/.gitignore: -------------------------------------------------------------------------------- 1 | TAGS 2 | tags 3 | .*.swp 4 | tomlcheck/tomlcheck 5 | toml.test 6 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/github.com/BurntSushi/toml/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.1 4 | - 1.2 5 | - 1.3 6 | - 1.4 7 | - 1.5 8 | - 1.6 9 | - tip 10 | install: 11 | - go install ./... 12 | - go get github.com/BurntSushi/toml-test 13 | script: 14 | - export PATH="$PATH:$HOME/gopath/bin" 15 | - make test 16 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/github.com/BurntSushi/toml/COMPATIBLE: -------------------------------------------------------------------------------- 1 | Compatible with TOML version 2 | [v0.4.0](https://github.com/toml-lang/toml/blob/v0.4.0/versions/en/toml-v0.4.0.md) 3 | 4 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/github.com/BurntSushi/toml/Makefile: -------------------------------------------------------------------------------- 1 | install: 2 | go install ./... 3 | 4 | test: install 5 | go test -v 6 | toml-test toml-test-decoder 7 | toml-test -encoder toml-test-encoder 8 | 9 | fmt: 10 | gofmt -w *.go */*.go 11 | colcheck *.go */*.go 12 | 13 | tags: 14 | find ./ -name '*.go' -print0 | xargs -0 gotags > TAGS 15 | 16 | push: 17 | git push origin master 18 | git push github master 19 | 20 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/github.com/BurntSushi/toml/encoding_types.go: -------------------------------------------------------------------------------- 1 | // +build go1.2 2 | 3 | package toml 4 | 5 | // In order to support Go 1.1, we define our own TextMarshaler and 6 | // TextUnmarshaler types. For Go 1.2+, we just alias them with the 7 | // standard library interfaces. 8 | 9 | import ( 10 | "encoding" 11 | ) 12 | 13 | // TextMarshaler is a synonym for encoding.TextMarshaler. It is defined here 14 | // so that Go 1.1 can be supported. 15 | type TextMarshaler encoding.TextMarshaler 16 | 17 | // TextUnmarshaler is a synonym for encoding.TextUnmarshaler. It is defined 18 | // here so that Go 1.1 can be supported. 19 | type TextUnmarshaler encoding.TextUnmarshaler 20 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/github.com/BurntSushi/toml/encoding_types_1.1.go: -------------------------------------------------------------------------------- 1 | // +build !go1.2 2 | 3 | package toml 4 | 5 | // These interfaces were introduced in Go 1.2, so we add them manually when 6 | // compiling for Go 1.1. 7 | 8 | // TextMarshaler is a synonym for encoding.TextMarshaler. It is defined here 9 | // so that Go 1.1 can be supported. 10 | type TextMarshaler interface { 11 | MarshalText() (text []byte, err error) 12 | } 13 | 14 | // TextUnmarshaler is a synonym for encoding.TextUnmarshaler. It is defined 15 | // here so that Go 1.1 can be supported. 16 | type TextUnmarshaler interface { 17 | UnmarshalText(text []byte) error 18 | } 19 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/github.com/BurntSushi/toml/session.vim: -------------------------------------------------------------------------------- 1 | au BufWritePost *.go silent!make tags > /dev/null 2>&1 2 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/go.uber.org/atomic/.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | .DS_Store 3 | /vendor 4 | cover.html 5 | cover.out 6 | lint.log 7 | 8 | # Binaries 9 | *.test 10 | 11 | # Profiling output 12 | *.prof 13 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/go.uber.org/atomic/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | go_import_path: go.uber.org/atomic 4 | 5 | env: 6 | global: 7 | - GO111MODULE=on 8 | 9 | matrix: 10 | include: 11 | - go: 1.12.x 12 | - go: 1.13.x 13 | env: LINT=1 14 | 15 | cache: 16 | directories: 17 | - vendor 18 | 19 | before_install: 20 | - go version 21 | 22 | script: 23 | - test -z "$LINT" || make lint 24 | - make cover 25 | 26 | after_success: 27 | - bash <(curl -s https://codecov.io/bash) 28 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/go.uber.org/atomic/go.mod: -------------------------------------------------------------------------------- 1 | module go.uber.org/atomic 2 | 3 | require ( 4 | github.com/davecgh/go-spew v1.1.1 // indirect 5 | github.com/stretchr/testify v1.3.0 6 | golang.org/x/lint v0.0.0-20190930215403-16217165b5de 7 | golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c // indirect 8 | ) 9 | 10 | go 1.13 11 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/go.uber.org/multierr/.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | cover.html 3 | cover.out 4 | /bin 5 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/go.uber.org/multierr/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | go_import_path: go.uber.org/multierr 4 | 5 | env: 6 | global: 7 | - GO15VENDOREXPERIMENT=1 8 | - GO111MODULE=on 9 | 10 | go: 11 | - 1.11.x 12 | - 1.12.x 13 | - 1.13.x 14 | 15 | cache: 16 | directories: 17 | - vendor 18 | 19 | before_install: 20 | - go version 21 | 22 | script: 23 | - | 24 | set -e 25 | make lint 26 | make cover 27 | 28 | after_success: 29 | - bash <(curl -s https://codecov.io/bash) 30 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/go.uber.org/multierr/glide.yaml: -------------------------------------------------------------------------------- 1 | package: go.uber.org/multierr 2 | import: 3 | - package: go.uber.org/atomic 4 | version: ^1 5 | testImport: 6 | - package: github.com/stretchr/testify 7 | subpackages: 8 | - assert 9 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/go.uber.org/multierr/go.mod: -------------------------------------------------------------------------------- 1 | module go.uber.org/multierr 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/stretchr/testify v1.3.0 7 | go.uber.org/atomic v1.5.0 8 | go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee 9 | golang.org/x/lint v0.0.0-20190930215403-16217165b5de 10 | golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5 // indirect 11 | honnef.co/go/tools v0.0.1-2019.2.3 12 | ) 13 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/go.uber.org/tools/update-license/.gitignore: -------------------------------------------------------------------------------- 1 | update-license 2 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/go.uber.org/zap/.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 | vendor 10 | 11 | # Architecture specific extensions/prefixes 12 | *.[568vq] 13 | [568vq].out 14 | 15 | *.cgo1.go 16 | *.cgo2.c 17 | _cgo_defun.c 18 | _cgo_gotypes.go 19 | _cgo_export.* 20 | 21 | _testmain.go 22 | 23 | *.exe 24 | *.test 25 | *.prof 26 | *.pprof 27 | *.out 28 | *.log 29 | 30 | /bin 31 | cover.out 32 | cover.html 33 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/go.uber.org/zap/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | 4 | go_import_path: go.uber.org/zap 5 | env: 6 | global: 7 | - TEST_TIMEOUT_SCALE=10 8 | - GO111MODULE=on 9 | 10 | matrix: 11 | include: 12 | - go: 1.12.x 13 | - go: 1.13.x 14 | env: LINT=1 15 | 16 | script: 17 | - test -z "$LINT" || make lint 18 | - make test 19 | - make bench 20 | 21 | after_success: 22 | - make cover 23 | - bash <(curl -s https://codecov.io/bash) 24 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/go.uber.org/zap/checklicense.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | ERROR_COUNT=0 4 | while read -r file 5 | do 6 | case "$(head -1 "${file}")" in 7 | *"Copyright (c) "*" Uber Technologies, Inc.") 8 | # everything's cool 9 | ;; 10 | *) 11 | echo "$file is missing license header." 12 | (( ERROR_COUNT++ )) 13 | ;; 14 | esac 15 | done < <(git ls-files "*\.go") 16 | 17 | exit $ERROR_COUNT 18 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/go.uber.org/zap/go.mod: -------------------------------------------------------------------------------- 1 | module go.uber.org/zap 2 | 3 | go 1.13 4 | 5 | require ( 6 | github.com/pkg/errors v0.8.1 7 | github.com/stretchr/testify v1.4.0 8 | go.uber.org/atomic v1.5.0 9 | go.uber.org/multierr v1.3.0 10 | golang.org/x/lint v0.0.0-20190930215403-16217165b5de 11 | ) 12 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/golang.org/x/lint/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | go: 4 | - 1.10.x 5 | - 1.11.x 6 | - master 7 | 8 | go_import_path: golang.org/x/lint 9 | 10 | install: 11 | - go get -t -v ./... 12 | 13 | script: 14 | - go test -v -race ./... 15 | 16 | matrix: 17 | allow_failures: 18 | - go: master 19 | fast_finish: true 20 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/golang.org/x/lint/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Golint 2 | 3 | ## Before filing an issue: 4 | 5 | ### Are you having trouble building golint? 6 | 7 | Check you have the latest version of its dependencies. Run 8 | ``` 9 | go get -u golang.org/x/lint/golint 10 | ``` 11 | If you still have problems, consider searching for existing issues before filing a new issue. 12 | 13 | ## Before sending a pull request: 14 | 15 | Have you understood the purpose of golint? Make sure to carefully read `README`. 16 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/golang.org/x/lint/go.mod: -------------------------------------------------------------------------------- 1 | module golang.org/x/lint 2 | 3 | require golang.org/x/tools v0.0.0-20190311212946-11955173bddd 4 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/golang.org/x/lint/go.sum: -------------------------------------------------------------------------------- 1 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 2 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 3 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 4 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 5 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd h1:/e+gpKk9r3dJobndpTytxS2gOy6m5uvpg+ISQoEcusQ= 6 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 7 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/golang.org/x/lint/golint/importcomment.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018 The Go Authors. All rights reserved. 2 | // 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file or at 5 | // https://developers.google.com/open-source/licenses/bsd. 6 | 7 | // +build go1.12 8 | 9 | // Require use of the correct import path only for Go 1.12+ users, so 10 | // any breakages coincide with people updating their CI configs or 11 | // whatnot. 12 | 13 | package main // import "golang.org/x/lint/golint" 14 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/golang.org/x/tools/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/golang.org/x/tools/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/golang.org/x/tools/go/ast/astutil/util.go: -------------------------------------------------------------------------------- 1 | package astutil 2 | 3 | import "go/ast" 4 | 5 | // Unparen returns e with any enclosing parentheses stripped. 6 | func Unparen(e ast.Expr) ast.Expr { 7 | for { 8 | p, ok := e.(*ast.ParenExpr) 9 | if !ok { 10 | return e 11 | } 12 | e = p.X 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/golang.org/x/tools/go/internal/gcimporter/newInterface11.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.11 6 | 7 | package gcimporter 8 | 9 | import "go/types" 10 | 11 | func newInterface(methods []*types.Func, embeddeds []types.Type) *types.Interface { 12 | return types.NewInterfaceType(methods, embeddeds) 13 | } 14 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/golang.org/x/tools/internal/fastwalk/fastwalk_dirent_fileno.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 freebsd openbsd netbsd 6 | 7 | package fastwalk 8 | 9 | import "syscall" 10 | 11 | func direntInode(dirent *syscall.Dirent) uint64 { 12 | return uint64(dirent.Fileno) 13 | } 14 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/golang.org/x/tools/internal/fastwalk/fastwalk_dirent_ino.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 linux darwin 6 | // +build !appengine 7 | 8 | package fastwalk 9 | 10 | import "syscall" 11 | 12 | func direntInode(dirent *syscall.Dirent) uint64 { 13 | return uint64(dirent.Ino) 14 | } 15 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/golang.org/x/tools/internal/fastwalk/fastwalk_dirent_namlen_bsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin freebsd openbsd netbsd 6 | 7 | package fastwalk 8 | 9 | import "syscall" 10 | 11 | func direntNamlen(dirent *syscall.Dirent) uint64 { 12 | return uint64(dirent.Namlen) 13 | } 14 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/golang.org/x/tools/internal/span/token112.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.12 6 | 7 | package span 8 | 9 | import ( 10 | "go/token" 11 | ) 12 | 13 | // TODO(rstambler): Delete this file when we no longer support Go 1.11. 14 | func lineStart(f *token.File, line int) token.Pos { 15 | return f.LineStart(line) 16 | } 17 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/honnef.co/go/tools/cmd/staticcheck/README.md: -------------------------------------------------------------------------------- 1 | # staticcheck 2 | 3 | _staticcheck_ offers extensive analysis of Go code, covering a myriad 4 | of categories. It will detect bugs, suggest code simplifications, 5 | point out dead code, and more. 6 | 7 | ## Installation 8 | 9 | See [the main README](https://github.com/dominikh/go-tools#installation) for installation instructions. 10 | 11 | ## Documentation 12 | 13 | Detailed documentation can be found on 14 | [staticcheck.io](https://staticcheck.io/docs/). 15 | 16 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/honnef.co/go/tools/config/example.conf: -------------------------------------------------------------------------------- 1 | checks = ["all", "-ST1003", "-ST1014"] 2 | initialisms = ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", 3 | "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", 4 | "IP", "JSON", "QPS", "RAM", "RPC", "SLA", 5 | "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", 6 | "UDP", "UI", "GID", "UID", "UUID", "URI", 7 | "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", 8 | "XSS", "SIP", "RTP"] 9 | dot_import_whitelist = [] 10 | http_status_code_whitelist = ["200", "400", "404", "500"] 11 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/honnef.co/go/tools/facts/token.go: -------------------------------------------------------------------------------- 1 | package facts 2 | 3 | import ( 4 | "go/ast" 5 | "go/token" 6 | "reflect" 7 | 8 | "golang.org/x/tools/go/analysis" 9 | ) 10 | 11 | var TokenFile = &analysis.Analyzer{ 12 | Name: "tokenfileanalyzer", 13 | Doc: "creates a mapping of *token.File to *ast.File", 14 | Run: func(pass *analysis.Pass) (interface{}, error) { 15 | m := map[*token.File]*ast.File{} 16 | for _, af := range pass.Files { 17 | tf := pass.Fset.File(af.Pos()) 18 | m[tf] = af 19 | } 20 | return m, nil 21 | }, 22 | RunDespiteErrors: true, 23 | ResultType: reflect.TypeOf(map[*token.File]*ast.File{}), 24 | } 25 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/honnef.co/go/tools/lint/lintutil/stats.go: -------------------------------------------------------------------------------- 1 | // +build !aix,!android,!darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris 2 | 3 | package lintutil 4 | 5 | import "os" 6 | 7 | var infoSignals = []os.Signal{} 8 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/honnef.co/go/tools/lint/lintutil/stats_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin dragonfly freebsd netbsd openbsd 2 | 3 | package lintutil 4 | 5 | import ( 6 | "os" 7 | "syscall" 8 | ) 9 | 10 | var infoSignals = []os.Signal{syscall.SIGINFO} 11 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/honnef.co/go/tools/lint/lintutil/stats_posix.go: -------------------------------------------------------------------------------- 1 | // +build aix android linux solaris 2 | 3 | package lintutil 4 | 5 | import ( 6 | "os" 7 | "syscall" 8 | ) 9 | 10 | var infoSignals = []os.Signal{syscall.SIGUSR1} 11 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/honnef.co/go/tools/lint/stats.go: -------------------------------------------------------------------------------- 1 | package lint 2 | 3 | const ( 4 | StateInitializing = 0 5 | StateGraph = 1 6 | StateProcessing = 2 7 | StateCumulative = 3 8 | ) 9 | 10 | type Stats struct { 11 | State uint32 12 | 13 | InitialPackages uint32 14 | TotalPackages uint32 15 | ProcessedPackages uint32 16 | ProcessedInitialPackages uint32 17 | Problems uint32 18 | ActiveWorkers uint32 19 | TotalWorkers uint32 20 | } 21 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/honnef.co/go/tools/printf/fuzz.go: -------------------------------------------------------------------------------- 1 | // +build gofuzz 2 | 3 | package printf 4 | 5 | func Fuzz(data []byte) int { 6 | _, err := Parse(string(data)) 7 | if err == nil { 8 | return 1 9 | } 10 | return 0 11 | } 12 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/honnef.co/go/tools/simple/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to gosimple 2 | 3 | ## Before filing an issue: 4 | 5 | ### Are you having trouble building gosimple? 6 | 7 | Check you have the latest version of its dependencies. Run 8 | ``` 9 | go get -u honnef.co/go/tools/simple 10 | ``` 11 | If you still have problems, consider searching for existing issues before filing a new issue. 12 | 13 | ## Before sending a pull request: 14 | 15 | Have you understood the purpose of gosimple? Make sure to carefully read `README`. 16 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/honnef.co/go/tools/ssa/identical.go: -------------------------------------------------------------------------------- 1 | // +build go1.8 2 | 3 | package ssa 4 | 5 | import "go/types" 6 | 7 | var structTypesIdentical = types.IdenticalIgnoreTags 8 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/honnef.co/go/tools/ssa/identical_17.go: -------------------------------------------------------------------------------- 1 | // +build !go1.8 2 | 3 | package ssa 4 | 5 | import "go/types" 6 | 7 | var structTypesIdentical = types.Identical 8 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/honnef.co/go/tools/ssa/staticcheck.conf: -------------------------------------------------------------------------------- 1 | # ssa/... is mostly imported from upstream and we don't want to 2 | # deviate from it too much, hence disabling SA1019 3 | checks = ["inherit", "-SA1019"] 4 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/honnef.co/go/tools/ssa/write.go: -------------------------------------------------------------------------------- 1 | package ssa 2 | 3 | func NewJump(parent *BasicBlock) *Jump { 4 | return &Jump{anInstruction{parent}} 5 | } 6 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/honnef.co/go/tools/staticcheck/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to staticcheck 2 | 3 | ## Before filing an issue: 4 | 5 | ### Are you having trouble building staticcheck? 6 | 7 | Check you have the latest version of its dependencies. Run 8 | ``` 9 | go get -u honnef.co/go/tools/staticcheck 10 | ``` 11 | If you still have problems, consider searching for existing issues before filing a new issue. 12 | 13 | ## Before sending a pull request: 14 | 15 | Have you understood the purpose of staticcheck? Make sure to carefully read `README`. 16 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/honnef.co/go/tools/staticcheck/buildtag.go: -------------------------------------------------------------------------------- 1 | package staticcheck 2 | 3 | import ( 4 | "go/ast" 5 | "strings" 6 | 7 | . "honnef.co/go/tools/lint/lintdsl" 8 | ) 9 | 10 | func buildTags(f *ast.File) [][]string { 11 | var out [][]string 12 | for _, line := range strings.Split(Preamble(f), "\n") { 13 | if !strings.HasPrefix(line, "+build ") { 14 | continue 15 | } 16 | line = strings.TrimSpace(strings.TrimPrefix(line, "+build ")) 17 | fields := strings.Fields(line) 18 | out = append(out, fields) 19 | } 20 | return out 21 | } 22 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/vendor/honnef.co/go/tools/version/buildinfo111.go: -------------------------------------------------------------------------------- 1 | // +build !go1.12 2 | 3 | package version 4 | 5 | func printBuildInfo() {} 6 | func buildInfoVersion() (string, bool) { return "", false } 7 | -------------------------------------------------------------------------------- /11-deploying-go-code/multiStageDockerBuild/zapLoggerExample.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "go.uber.org/zap" 4 | 5 | func main() { 6 | zapLogger := zap.NewExample() 7 | defer zapLogger.Sync() 8 | zapLogger.Debug("Hi Gophers - from our Zap Logger") 9 | } 10 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/bobstrecansky/HighPerformanceWithGo/11-deploying-go-code/promExporter 2 | 3 | require github.com/prometheus/client_golang v1.1.0 4 | 5 | go 1.13 6 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/prometheusExporterExample: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/11-deploying-go-code/promExporter/prometheusExporterExample -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/prometheusExporterExample.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | 7 | "github.com/prometheus/client_golang/prometheus/promhttp" 8 | ) 9 | 10 | func main() { 11 | http.Handle("/", promhttp.Handler()) 12 | port := ":2112" 13 | fmt.Println("Prometheus Handler listening on port ", port) 14 | http.ListenAndServe(port, nil) 15 | } 16 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/github.com/golang/protobuf/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/github.com/golang/protobuf/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/github.com/matttproud/golang_protobuf_extensions/NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2012 Matt T. Proud (matt.proud@gmail.com) 2 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/github.com/matttproud/golang_protobuf_extensions/pbutil/.gitignore: -------------------------------------------------------------------------------- 1 | cover.dat 2 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/github.com/matttproud/golang_protobuf_extensions/pbutil/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | 3 | cover: 4 | go test -cover -v -coverprofile=cover.dat ./... 5 | go tool cover -func cover.dat 6 | 7 | .PHONY: cover 8 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/github.com/prometheus/client_golang/prometheus/.gitignore: -------------------------------------------------------------------------------- 1 | command-line-arguments.test 2 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/github.com/prometheus/client_golang/prometheus/README.md: -------------------------------------------------------------------------------- 1 | See [![go-doc](https://godoc.org/github.com/prometheus/client_golang/prometheus?status.svg)](https://godoc.org/github.com/prometheus/client_golang/prometheus). 2 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/github.com/prometheus/client_model/NOTICE: -------------------------------------------------------------------------------- 1 | Data model artifacts for Prometheus. 2 | Copyright 2012-2015 The Prometheus Authors 3 | 4 | This product includes software developed at 5 | SoundCloud Ltd. (http://soundcloud.com/). 6 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/github.com/prometheus/common/NOTICE: -------------------------------------------------------------------------------- 1 | Common libraries shared by Prometheus Go components. 2 | Copyright 2015 The Prometheus Authors 3 | 4 | This product includes software developed at 5 | SoundCloud Ltd. (http://soundcloud.com/). 6 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/github.com/prometheus/procfs/.gitignore: -------------------------------------------------------------------------------- 1 | /fixtures/ 2 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/github.com/prometheus/procfs/.golangci.yml: -------------------------------------------------------------------------------- 1 | # Run only staticcheck for now. Additional linters will be enabled one-by-one. 2 | linters: 3 | enable: 4 | - staticcheck 5 | - govet 6 | disable-all: true 7 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/github.com/prometheus/procfs/MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | * Johannes 'fish' Ziemke @discordianfish 2 | * Paul Gier @pgier 3 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/github.com/prometheus/procfs/NOTICE: -------------------------------------------------------------------------------- 1 | procfs provides functions to retrieve system, kernel and process 2 | metrics from the pseudo-filesystem proc. 3 | 4 | Copyright 2014-2015 The Prometheus Authors 5 | 6 | This product includes software developed at 7 | SoundCloud Ltd. (http://soundcloud.com/). 8 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/github.com/prometheus/procfs/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/prometheus/procfs 2 | 3 | require ( 4 | github.com/google/go-cmp v0.3.0 5 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 6 | ) 7 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/github.com/prometheus/procfs/go.sum: -------------------------------------------------------------------------------- 1 | github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= 2 | github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 3 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= 4 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 5 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/golang.org/x/sys/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/golang.org/x/sys/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/golang.org/x/sys/windows/aliases.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | // +build go1.9 7 | 8 | package windows 9 | 10 | import "syscall" 11 | 12 | type Errno = syscall.Errno 13 | type SysProcAttr = syscall.SysProcAttr 14 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/golang.org/x/sys/windows/asm_windows_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 | // 6 | // System calls for 386, Windows are implemented in runtime/syscall_windows.goc 7 | // 8 | 9 | TEXT ·getprocaddress(SB), 7, $0-16 10 | JMP syscall·getprocaddress(SB) 11 | 12 | TEXT ·loadlibrary(SB), 7, $0-12 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/golang.org/x/sys/windows/asm_windows_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 | // 6 | // System calls for amd64, Windows are implemented in runtime/syscall_windows.goc 7 | // 8 | 9 | TEXT ·getprocaddress(SB), 7, $0-32 10 | JMP syscall·getprocaddress(SB) 11 | 12 | TEXT ·loadlibrary(SB), 7, $0-24 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/golang.org/x/sys/windows/asm_windows_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | #include "textflag.h" 6 | 7 | TEXT ·getprocaddress(SB),NOSPLIT,$0 8 | B syscall·getprocaddress(SB) 9 | 10 | TEXT ·loadlibrary(SB),NOSPLIT,$0 11 | B syscall·loadlibrary(SB) 12 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/golang.org/x/sys/windows/mksyscall.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 generate 6 | 7 | package windows 8 | 9 | //go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go eventlog.go service.go syscall_windows.go security_windows.go 10 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/golang.org/x/sys/windows/race0.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 windows,!race 6 | 7 | package windows 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/golang.org/x/sys/windows/str.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 windows 6 | 7 | package windows 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + itoa(-val) 12 | } 13 | var buf [32]byte // big enough for int64 14 | i := len(buf) - 1 15 | for val >= 10 { 16 | buf[i] = byte(val%10 + '0') 17 | i-- 18 | val /= 10 19 | } 20 | buf[i] = byte(val + '0') 21 | return string(buf[i:]) 22 | } 23 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/golang.org/x/sys/windows/types_windows_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | Description [WSADESCRIPTION_LEN + 1]byte 11 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 12 | MaxSockets uint16 13 | MaxUdpDg uint16 14 | VendorInfo *byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Port uint16 21 | Proto *byte 22 | } 23 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/golang.org/x/sys/windows/types_windows_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | MaxSockets uint16 11 | MaxUdpDg uint16 12 | VendorInfo *byte 13 | Description [WSADESCRIPTION_LEN + 1]byte 14 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Proto *byte 21 | Port uint16 22 | } 23 | -------------------------------------------------------------------------------- /11-deploying-go-code/promExporter/vendor/golang.org/x/sys/windows/types_windows_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package windows 6 | 7 | type WSAData struct { 8 | Version uint16 9 | HighVersion uint16 10 | Description [WSADESCRIPTION_LEN + 1]byte 11 | SystemStatus [WSASYS_STATUS_LEN + 1]byte 12 | MaxSockets uint16 13 | MaxUdpDg uint16 14 | VendorInfo *byte 15 | } 16 | 17 | type Servent struct { 18 | Name *byte 19 | Aliases **byte 20 | Port uint16 21 | Proto *byte 22 | } 23 | -------------------------------------------------------------------------------- /12-profiling-with-pprof/httpProfiling.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | _ "net/http/pprof" 7 | "time" 8 | ) 9 | 10 | func main() { 11 | Handler := func(w http.ResponseWriter, req *http.Request) { 12 | sleep(5) 13 | sleep(10) 14 | fmt.Fprintf(w, "Sleep Profiling Test") 15 | } 16 | http.HandleFunc("/", Handler) 17 | http.ListenAndServe(":1234", nil) 18 | } 19 | 20 | func sleep(sleepTime int) { 21 | time.Sleep(time.Duration(sleepTime) * time.Millisecond) 22 | fmt.Println("Slept for ", sleepTime, " Milliseconds") 23 | } 24 | -------------------------------------------------------------------------------- /12-profiling-with-pprof/memoryLeakTest/memoryLeak.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | 7 | _ "net/http/pprof" 8 | "runtime" 9 | "time" 10 | ) 11 | 12 | func main() { 13 | http.HandleFunc("/leak", leakyAbstraction) 14 | http.ListenAndServe("localhost:6060", nil) 15 | } 16 | 17 | func leakyAbstraction(w http.ResponseWriter, r *http.Request) { 18 | ch := make(chan string, 15) 19 | for { 20 | fmt.Fprintln(w, "Number of Goroutines: ", runtime.NumGoroutine()) 21 | go func() { ch <- wait() }() 22 | } 23 | } 24 | 25 | func wait() string { 26 | time.Sleep(5 * time.Microsecond) 27 | return "Hello Gophers!" 28 | } 29 | -------------------------------------------------------------------------------- /12-profiling-with-pprof/out.dump: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/12-profiling-with-pprof/out.dump -------------------------------------------------------------------------------- /13-tracing-with-trace-tool/OpenCensusExample/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/bobstrecansky/HighPerformanceWithGo/13-tracing-with-trace-tool/OpenCensusExample 2 | 3 | go 1.13 4 | 5 | require ( 6 | contrib.go.opencensus.io/exporter/zipkin v0.1.1 // indirect 7 | github.com/go-redis/redis v6.15.6+incompatible // indirect 8 | github.com/openzipkin/zipkin-go v0.2.2 // indirect 9 | go.opencensus.io v0.22.1 // indirect 10 | ) 11 | -------------------------------------------------------------------------------- /13-tracing-with-trace-tool/pprofTrace/netTracePprof.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "io" 5 | "net/http" 6 | _ "net/http/pprof" 7 | "time" 8 | ) 9 | 10 | func main() { 11 | Handler := func(w http.ResponseWriter, req *http.Request) { 12 | time.Sleep(5 * time.Second) 13 | io.WriteString(w, "Network Trace Profile Test") 14 | } 15 | 16 | http.HandleFunc("/", Handler) 17 | http.ListenAndServe(":1234", nil) 18 | } 19 | -------------------------------------------------------------------------------- /13-tracing-with-trace-tool/traceExample/trace.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "os" 6 | "runtime/trace" 7 | ) 8 | 9 | func main() { 10 | f, err := os.Create("trace.out") 11 | if err != nil { 12 | panic(err) 13 | } 14 | defer f.Close() 15 | 16 | err = trace.Start(f) 17 | if err != nil { 18 | panic(err) 19 | } 20 | defer trace.Stop() 21 | ch := make(chan string) 22 | go func() { 23 | ch <- "Hi Gophers" 24 | }() 25 | <-ch 26 | log.Printf("Trace Completed") 27 | } 28 | -------------------------------------------------------------------------------- /14-clustering-and-job-queueing-in-go/clustering/kmeans/3_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/14-clustering-and-job-queueing-in-go/clustering/kmeans/3_0.png -------------------------------------------------------------------------------- /14-clustering-and-job-queueing-in-go/clustering/kmeans/3_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/14-clustering-and-job-queueing-in-go/clustering/kmeans/3_1.png -------------------------------------------------------------------------------- /14-clustering-and-job-queueing-in-go/clustering/kmeans/3_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/14-clustering-and-job-queueing-in-go/clustering/kmeans/3_2.png -------------------------------------------------------------------------------- /14-clustering-and-job-queueing-in-go/clustering/kmeans/3_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/14-clustering-and-job-queueing-in-go/clustering/kmeans/3_3.png -------------------------------------------------------------------------------- /14-clustering-and-job-queueing-in-go/clustering/kmeans/3_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/14-clustering-and-job-queueing-in-go/clustering/kmeans/3_4.png -------------------------------------------------------------------------------- /14-clustering-and-job-queueing-in-go/clustering/kmeans/3_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/14-clustering-and-job-queueing-in-go/clustering/kmeans/3_5.png -------------------------------------------------------------------------------- /14-clustering-and-job-queueing-in-go/clustering/kmeans/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/bobstrecansky/HighPerformanceWithGo/14-clustering-and-job-queueing-in-go/clustering/kmeans 2 | 3 | go 1.13 4 | 5 | require ( 6 | github.com/muesli/clusters v0.0.0-20190807044042-ba9c57dd9228 // indirect 7 | github.com/muesli/kmeans v0.0.0-20190917235210-80dfc71e6c5a // indirect 8 | ) 9 | -------------------------------------------------------------------------------- /14-clustering-and-job-queueing-in-go/jobqueues/goroutine/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/bobstrecansky/HighPerformanceWithGo/14-clustering-and-job-queueing-in-go/jobqueues/goroutine 2 | 3 | go 1.13 4 | 5 | require gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df 6 | -------------------------------------------------------------------------------- /14-clustering-and-job-queueing-in-go/jobqueues/goroutine/go.sum: -------------------------------------------------------------------------------- 1 | gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE= 2 | gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw= 3 | -------------------------------------------------------------------------------- /14-clustering-and-job-queueing-in-go/jobqueues/kafka/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/bobstrecansky/HighPerformanceWithGo/14-clustering-and-job-queueing-in-go/jobqueues/kafka 2 | 3 | go 1.13 4 | 5 | require github.com/segmentio/kafka-go v0.3.4 // indirect 6 | -------------------------------------------------------------------------------- /14-clustering-and-job-queueing-in-go/jobqueues/kafka/testKafka.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -rf kafka_2.12-2.3.0 3 | wget -c http://apache.cs.utah.edu/kafka/2.3.0/kafka_2.12-2.3.0.tgz 4 | tar xvf kafka_2.12-2.3.0.tgz 5 | ./kafka_2.12-2.3.0/bin/zookeeper-server-start.sh kafka_2.12-2.3.0/config/zookeeper.properties & 6 | ./kafka_2.12-2.3.0/bin/kafka-server-start.sh kafka_2.12-2.3.0/config/server.properties 7 | wait 8 | -------------------------------------------------------------------------------- /15-code-quality-across-versions/GoogleCloudTrace/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/bobstrecansky/HighPerformanceWithGo/15-code-quality-across-versions/GoogleCloudTrce 2 | 3 | go 1.13 4 | 5 | require ( 6 | contrib.go.opencensus.io/exporter/stackdriver v0.12.8 // indirect 7 | go.opencensus.io v0.22.2 // indirect 8 | ) 9 | -------------------------------------------------------------------------------- /15-code-quality-across-versions/SLISLO/Dockerfile.promservice: -------------------------------------------------------------------------------- 1 | FROM prom/prometheus 2 | ADD prometheus.yml /etc/prometheus/ 3 | -------------------------------------------------------------------------------- /15-code-quality-across-versions/SLISLO/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/bobstrecansky/HighPerformanceWithGo/15-code-quality-across-versions/SLISLO 2 | 3 | go 1.13 4 | 5 | require github.com/prometheus/client_golang v1.2.1 6 | -------------------------------------------------------------------------------- /15-code-quality-across-versions/SLISLO/prometheus.yml: -------------------------------------------------------------------------------- 1 | global: 2 | scrape_interval: 10s 3 | evaluation_interval: 10s 4 | external_labels: 5 | monitor: 'metrics-example' 6 | scrape_configs: 7 | - job_name: 'prometheus' 8 | static_configs: 9 | - targets: ['0.0.0.0:1234'] 10 | -------------------------------------------------------------------------------- /15-code-quality-across-versions/logging/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/bobstrecansky/HighPerformanceWithGo/15-code-quality-across-versions/logging 2 | 3 | go 1.13 4 | 5 | require go.uber.org/zap v1.13.0 // indirect 6 | -------------------------------------------------------------------------------- /15-code-quality-across-versions/promExporter/Dockerfile.promExporter: -------------------------------------------------------------------------------- 1 | FROM golang:latest 2 | COPY promExporter . 3 | EXPOSE 1234 4 | CMD ["./promExporter"] 5 | -------------------------------------------------------------------------------- /15-code-quality-across-versions/promExporter/Dockerfile.promservice: -------------------------------------------------------------------------------- 1 | FROM prom/prometheus 2 | ADD prometheus.yml /etc/prometheus/ 3 | -------------------------------------------------------------------------------- /15-code-quality-across-versions/promExporter/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/bobstrecansky/HighPerformanceWithGo/15-code-quality-across-versions/promExporter 2 | 3 | go 1.13 4 | 5 | require github.com/prometheus/client_golang v1.2.1 6 | -------------------------------------------------------------------------------- /15-code-quality-across-versions/promExporter/promExporter: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/15-code-quality-across-versions/promExporter/promExporter -------------------------------------------------------------------------------- /15-code-quality-across-versions/promExporter/promExporter.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | 6 | "github.com/prometheus/client_golang/prometheus/promhttp" 7 | ) 8 | 9 | func main() { 10 | mux := http.NewServeMux() 11 | mux.Handle("/metrics", promhttp.Handler()) 12 | http.ListenAndServe("0.0.0.0:1234", mux) 13 | } 14 | -------------------------------------------------------------------------------- /15-code-quality-across-versions/promExporter/prometheus.yml: -------------------------------------------------------------------------------- 1 | global: 2 | scrape_interval: 10s 3 | evaluation_interval: 10s 4 | external_labels: 5 | monitor: 'metrics-example' 6 | scrape_configs: 7 | - job_name: 'prometheus' 8 | static_configs: 9 | - targets: ['promExporter:1234'] 10 | -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/Benchstat-comparison/multi/larger_comparison_test.go: -------------------------------------------------------------------------------- 1 | package comparison_larger 2 | 3 | import "testing" 4 | 5 | func BenchmarkJSON(b *testing.B) { 6 | for i := 0; i < b.N; i++ { 7 | CarJSON() 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/Benchstat-comparison/single/comparison.go: -------------------------------------------------------------------------------- 1 | package comparison 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "log" 7 | ) 8 | 9 | type CarData struct { 10 | Cylinders int 11 | Brand string 12 | Mpg float64 13 | } 14 | 15 | func CarJSON() { 16 | honda := CarData{Cylinders: 4, Brand: "Toyota", Mpg: 42.6} 17 | var carDataJson []byte 18 | carDataJson, err := json.Marshal(honda) 19 | if err != nil { 20 | log.Println(err) 21 | } 22 | fmt.Sprintf(string(carDataJson)) 23 | } 24 | -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/Benchstat-comparison/single/comparison_test.go: -------------------------------------------------------------------------------- 1 | package comparison 2 | 3 | import "testing" 4 | 5 | func BenchmarkJSON(b *testing.B) { 6 | for i := 0; i < b.N; i++ { 7 | CarJSON() 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/BigO-notation-o-1/o1.go: -------------------------------------------------------------------------------- 1 | package oone 2 | 3 | func ThreeWords() string { 4 | threewords := [3]string{"foo", "bar", "baz"} 5 | return threewords[1] 6 | } 7 | 8 | func TenWords() string { 9 | tenwords := [10]string{"foo", "bar", "baz", "qux", "grault", "waldo", "plugh", "xyzzy", "thud", "spam"} 10 | return tenwords[6] 11 | } 12 | -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/BigO-notation-o-1/o1_test.go: -------------------------------------------------------------------------------- 1 | package oone 2 | 3 | import "testing" 4 | 5 | func BenchmarkThree(b *testing.B) { 6 | for n := 0; n < b.N; n++ { 7 | ThreeWords() 8 | } 9 | } 10 | 11 | func BenchmarkTen(b *testing.B) { 12 | for n := 0; n < b.N; n++ { 13 | TenWords() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/BigO-notation-o-2n/o2n.go: -------------------------------------------------------------------------------- 1 | package o2n 2 | 3 | func Fibonacci(i int) int { 4 | if i <= 1 { 5 | return 1 6 | } 7 | return Fibonacci(i-1) + Fibonacci(i-2) 8 | } 9 | -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/BigO-notation-o-2n/o2n_test.go: -------------------------------------------------------------------------------- 1 | package o2n 2 | 3 | import "testing" 4 | 5 | func benchmarkFibonacci(x int, b *testing.B) { 6 | b.ResetTimer() 7 | for n := 0; n < b.N; n++ { 8 | Fibonacci(x) 9 | } 10 | } 11 | 12 | func BenchmarkFibonacci1(b *testing.B) { benchmarkFibonacci(1, b) } 13 | func BenchmarkFibonacci2(b *testing.B) { benchmarkFibonacci(2, b) } 14 | func BenchmarkFibonacci5(b *testing.B) { benchmarkFibonacci(5, b) } 15 | func BenchmarkFibonacci10(b *testing.B) { benchmarkFibonacci(10, b) } 16 | func BenchmarkFibonacci15(b *testing.B) { benchmarkFibonacci(15, b) } 17 | func BenchmarkFibonacci20(b *testing.B) { benchmarkFibonacci(20, b) } 18 | -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/BigO-notation-o-n/on.go: -------------------------------------------------------------------------------- 1 | package on 2 | 3 | // Create a slice of n sorted ints 4 | // generateIntSlice(3) == [0 1 2] 5 | func generateIntSlice(n int) []int { 6 | x := make([]int, 0, n) 7 | for i := 0; i < n; i++ { 8 | x = append(x, n) 9 | } 10 | return x 11 | } 12 | 13 | // Sum the elements in a slice 14 | func simpleLoopSum(count int) int { 15 | slice := generateIntSlice(count) 16 | sum := 0 17 | for i := 0; i < count; i++ { 18 | sum += slice[i] 19 | } 20 | return sum 21 | } 22 | -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/BigO-notation-o-n/on_test.go: -------------------------------------------------------------------------------- 1 | package on 2 | 3 | import "testing" 4 | 5 | func benchmarkSimpleLoop(i int, b *testing.B) { 6 | for n := 0; n < b.N; n++ { 7 | simpleLoopSum(i) 8 | } 9 | } 10 | 11 | func BenchmarkSimpleLoop10(b *testing.B) { benchmarkSimpleLoop(10, b) } 12 | func BenchmarkSimpleLoop100(b *testing.B) { benchmarkSimpleLoop(100, b) } 13 | func BenchmarkSimpleLoop1000(b *testing.B) { benchmarkSimpleLoop(1000, b) } 14 | -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/BigO-notation-o-n2/on2.go: -------------------------------------------------------------------------------- 1 | package on2 2 | 3 | import ( 4 | "math/rand" 5 | "time" 6 | ) 7 | 8 | func generateRandomSlice(size int) []int { 9 | 10 | slice := make([]int, size, size) 11 | rand.Seed(time.Now().UnixNano()) 12 | for i := 0; i < size; i++ { 13 | slice[i] = rand.Intn(999) - rand.Intn(999) 14 | } 15 | return slice 16 | } 17 | 18 | func BubbleSort(i int) []int { 19 | k := generateRandomSlice(i) 20 | for i := 1; i < len(k); i++ { 21 | for j := 0; j < len(k)-i; j++ { 22 | if k[j] > k[j+1] { 23 | k[j], k[j+1] = k[j+1], k[j] 24 | } 25 | } 26 | } 27 | return k 28 | } 29 | -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/BigO-notation-o-n2/on2_test.go: -------------------------------------------------------------------------------- 1 | package on2 2 | 3 | import "testing" 4 | 5 | func benchmarkBubbleSort(x int, b *testing.B) { 6 | b.ResetTimer() 7 | for n := 0; n < b.N; n++ { 8 | BubbleSort(x) 9 | } 10 | } 11 | 12 | func BenchmarkBubbleSort10(b *testing.B) { benchmarkBubbleSort(10, b) } 13 | func BenchmarkBubbleSort100(b *testing.B) { benchmarkBubbleSort(100, b) } 14 | func BenchmarkBubbleSort1000(b *testing.B) { benchmarkBubbleSort(1000, b) } 15 | func BenchmarkBubbleSort10000(b *testing.B) { benchmarkBubbleSort(10000, b) } 16 | func BenchmarkBubbleSort100000(b *testing.B) { benchmarkBubbleSort(100000, b) } 17 | -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/BigO-notation-o-nlogn/onlogn.go: -------------------------------------------------------------------------------- 1 | package onlogn 2 | 3 | func OnlognLoop(n int) { 4 | for i := 0; i < n; i++ { // this loop O(n) because it is executed n times 5 | for j := n; j > 0; j /= 2 { // this loop is O(log n) 6 | // The result here is O(n) * O(log n) = O(n log n) 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/binarysearch/binarysearch.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "sort" 6 | ) 7 | 8 | func main() { 9 | intArray := []int{0, 2, 3, 5, 11, 16, 34} 10 | searchNumber := 34 11 | sorted := sort.SearchInts(intArray, searchNumber) 12 | if sorted < len(intArray) { 13 | fmt.Printf("Found element %d at array position %d\n", searchNumber, sorted) 14 | } else { 15 | fmt.Printf("Element %d not found in array %v\n", searchNumber, intArray) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/hello/hello_test.go: -------------------------------------------------------------------------------- 1 | package hello_test 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | ) 7 | 8 | func BenchmarkHello(b *testing.B) { 9 | for i := 0; i < b.N; i++ { 10 | fmt.Sprintf("Hello High Performance Go") // Print with no formatting 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/img/ArraySortingAlgorithms.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/2-data-structures-and-algorithms/img/ArraySortingAlgorithms.png -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/img/BenchStatComparison.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/2-data-structures-and-algorithms/img/BenchStatComparison.png -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/img/Big-O-functions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/2-data-structures-and-algorithms/img/Big-O-functions.png -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/img/CommonDataStructureOperations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/2-data-structures-and-algorithms/img/CommonDataStructureOperations.png -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/img/Screenshot from 2019-05-18 09-59-07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/2-data-structures-and-algorithms/img/Screenshot from 2019-05-18 09-59-07.png -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/img/Screenshot from 2019-08-24 11-50-31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/2-data-structures-and-algorithms/img/Screenshot from 2019-08-24 11-50-31.png -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/img/StdLibHeapSort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/2-data-structures-and-algorithms/img/StdLibHeapSort.png -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/img/StdLibInsertionSort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/2-data-structures-and-algorithms/img/StdLibInsertionSort.png -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/img/StdLibSearch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/2-data-structures-and-algorithms/img/StdLibSearch.png -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/img/StdLibStableSort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/2-data-structures-and-algorithms/img/StdLibStableSort.png -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/img/StdLibraryQuicksort.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/2-data-structures-and-algorithms/img/StdLibraryQuicksort.png -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/img/StdLibrarySearch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/2-data-structures-and-algorithms/img/StdLibrarySearch.png -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/img/SumOfHarmonicSeries.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/2-data-structures-and-algorithms/img/SumOfHarmonicSeries.png -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/img/binaryTree.svg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/2-data-structures-and-algorithms/img/binaryTree.svg -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/img/mermaidLiveEditorValues.txt: -------------------------------------------------------------------------------- 1 | graph TD 2 | subgraph root 3 | 1 4 | end 5 | 1-->2 6 | 1-->3 7 | 2-->4 8 | 2-->5 9 | 3-->6 10 | 3-->7 11 | subgraph depth 3 12 | 5 13 | 6 14 | end 15 | 4-->8 16 | 4-->9 17 | subgraph height 4 18 | 8 19 | 9 20 | end 21 | -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/iterators/function_with_callback.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "math/rand" 6 | ) 7 | 8 | const NumItems int = 3 9 | 10 | var int_data []int = make([]int, NumItems) 11 | 12 | func InitInts() { 13 | for i := 0; i < NumItems; i++ { 14 | int_data[i] = rand.Intn(2) 15 | } 16 | } 17 | 18 | func IntCallbackIterator(cb func(int)) { 19 | for _, val := range int_data { 20 | fmt.Print(int_data, val) 21 | cb(val) 22 | } 23 | } 24 | 25 | func main() { 26 | InitInts() 27 | var sum int = 0 28 | cb := func(val int) { 29 | sum += val 30 | } 31 | IntCallbackIterator(cb) 32 | fmt.Print(sum) 33 | } 34 | -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/plot/functions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/2-data-structures-and-algorithms/plot/functions.png -------------------------------------------------------------------------------- /2-data-structures-and-algorithms/plot/go.mod: -------------------------------------------------------------------------------- 1 | module . 2 | 3 | go 1.12 4 | 5 | require gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b // indirect 6 | -------------------------------------------------------------------------------- /3-iterators-and-generators/anonymous-functions/hello_anonymous.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func helloGo() { 6 | fmt.Println("Hello Go from a Function") 7 | 8 | } 9 | 10 | func main() { 11 | 12 | helloGo() 13 | func() { fmt.Println("Hello Go from an Anonymous Function") }() 14 | var hello func() = func() { fmt.Println("Hello Go from an Anonymous Function Variable") } 15 | hello() 16 | } 17 | -------------------------------------------------------------------------------- /3-iterators-and-generators/anonymous-functions/hello_anonymous_variable_as_function.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func salutation() func() string { 6 | return func() string { return "Hello Go" } 7 | } 8 | 9 | func main() { 10 | hello := salutation() 11 | fmt.Println(hello()) 12 | } 13 | -------------------------------------------------------------------------------- /3-iterators-and-generators/anonymous-functions/hello_go.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | // Note the trailing () for this anonymous function invocation 7 | func() { 8 | fmt.Println("Hello Go") 9 | }() 10 | } 11 | -------------------------------------------------------------------------------- /3-iterators-and-generators/channels/buffered_channel_error_closed_channel.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | ch := make(chan string, 1) 5 | close(ch) 6 | ch <- "foo" 7 | } 8 | -------------------------------------------------------------------------------- /3-iterators-and-generators/channels/buffered_channel_error_no_room_in_buffer.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | func main() { 4 | 5 | ch := make(chan string, 1) 6 | ch <- "foo" 7 | ch <- "bar" 8 | } 9 | -------------------------------------------------------------------------------- /3-iterators-and-generators/channels/directional_channels.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | foo := make(chan<- string, 10) 7 | bar := make(chan<- string, 10) 8 | baz := make(<-chan string, 10) 9 | 10 | fmt.Println(foo) 11 | fmt.Println(bar) 12 | fmt.Println(baz) 13 | } 14 | -------------------------------------------------------------------------------- /3-iterators-and-generators/channels/ranges.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | 7 | bufferedChannel := make(chan int, 3) 8 | bufferedChannel <- 1 9 | bufferedChannel <- 3 10 | bufferedChannel <- 5 11 | close(bufferedChannel) 12 | for i := range bufferedChannel { 13 | fmt.Println(i) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /3-iterators-and-generators/channels/unbuffered_channel.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func printToChannel(s string, ch chan string) { 8 | for index := range s { 9 | ch <- string(s[index]) 10 | } 11 | close(ch) 12 | } 13 | 14 | func printBool(b bool, ch chan bool) { 15 | ch <- b 16 | close(ch) 17 | } 18 | 19 | func main() { 20 | ch1 := make(chan string) 21 | ch2 := make(chan bool) 22 | go printToChannel("HELLO", ch1) 23 | go printToChannel("GOLANG", ch1) 24 | go printBool(true, ch2) 25 | 26 | // Print all the results from printToChannel calls 27 | for out := range ch1 { 28 | fmt.Println(out) 29 | } 30 | 31 | // Print result from printBool 32 | fmt.Println(<-ch2) 33 | 34 | } 35 | -------------------------------------------------------------------------------- /3-iterators-and-generators/channels/unbuffered_pipeline.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func main() { 8 | 9 | runeCh := make(chan int) 10 | runeConvCh := make(chan rune) 11 | 12 | go func() { 13 | for i := 33; i < 123; i++ { 14 | runeCh <- i 15 | } 16 | }() 17 | 18 | go func() { 19 | for i := 33; i < 123; i++ { 20 | j := <-runeCh 21 | runeConvCh <- rune(j) 22 | } 23 | }() 24 | for i := 33; i < 123; i++ { 25 | k := <-runeConvCh 26 | fmt.Println(string(k)) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /3-iterators-and-generators/closures/defer_work.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "sort" 6 | ) 7 | 8 | func main() { 9 | input := []string{"foo", "bar", "baz"} 10 | var result []string 11 | // closure callback 12 | func() { 13 | result = append(input, "abc") // Append to the array 14 | result = append(result, "def") // Append to the array again 15 | sort.Sort(sort.StringSlice(result)) // Sort the larger array 16 | }() 17 | fmt.Print(result) 18 | } 19 | -------------------------------------------------------------------------------- /3-iterators-and-generators/generators/forloop.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func count(n int) { 6 | for i := 0; i < n; i++ { 7 | fmt.Println("Counted", i) 8 | } 9 | } 10 | 11 | func main() { 12 | count(99999) 13 | } 14 | -------------------------------------------------------------------------------- /3-iterators-and-generators/generators/generators.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func count(n int) chan int { 6 | ch := make(chan int) 7 | 8 | go func() { 9 | for i := 0; i < n; i++ { 10 | ch <- i 11 | } 12 | close(ch) 13 | }() 14 | 15 | return ch 16 | } 17 | 18 | func main() { 19 | for i := range count(99999) { 20 | fmt.Println("Counted", i) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /3-iterators-and-generators/generators/loop_sleep.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | var out = make([]string, 5) 10 | for i := 0; i < 5; i++ { 11 | time.Sleep(100 * time.Millisecond) 12 | out[i] = "This loop is slow\n" 13 | } 14 | fmt.Println(out) 15 | } 16 | -------------------------------------------------------------------------------- /3-iterators-and-generators/goroutines/simple_goroutine.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func printSleep(s string) { 9 | for index, stringVal := range s { 10 | fmt.Printf("%#U at index %d\n", stringVal, index) 11 | time.Sleep(1 * time.Millisecond) 12 | } 13 | } 14 | 15 | func main() { 16 | const t time.Duration = 9 17 | go printSleep("HELLO GOPHERS") 18 | time.Sleep(t * time.Millisecond) 19 | fmt.Println("sleep complete") 20 | } 21 | -------------------------------------------------------------------------------- /3-iterators-and-generators/iterators/buffered_chan.go: -------------------------------------------------------------------------------- 1 | package iterators 2 | 3 | var sumBufferedChan int 4 | 5 | func BufferedChanLoop(n int) int { 6 | 7 | ch := make(chan int, n) 8 | 9 | go func() { 10 | defer close(ch) 11 | for i := 0; i < n; i++ { 12 | ch <- i 13 | } 14 | }() 15 | 16 | for j := range ch { 17 | sumBufferedChan += j 18 | } 19 | return sumBufferedChan 20 | } 21 | -------------------------------------------------------------------------------- /3-iterators-and-generators/iterators/callback.go: -------------------------------------------------------------------------------- 1 | package iterators 2 | 3 | var sumCallback int 4 | 5 | func CallbackLoop(top int) { 6 | err := callbackLoopIterator(top, func(n int) error { 7 | sumCallback += n 8 | return nil 9 | }) 10 | if err != nil { 11 | panic(err) 12 | } 13 | } 14 | 15 | func callbackLoopIterator(top int, callback func(n int) error) error { 16 | for i := 0; i < top; i++ { 17 | err := callback(i) 18 | if err != nil { 19 | return err 20 | } 21 | } 22 | return nil 23 | } 24 | -------------------------------------------------------------------------------- /3-iterators-and-generators/iterators/loops.go: -------------------------------------------------------------------------------- 1 | package iterators 2 | 3 | var sumLoops int 4 | 5 | func simpleLoop(n int) int { 6 | for i := 0; i < n; i++ { 7 | sumLoops += i 8 | } 9 | return sumLoops 10 | } 11 | -------------------------------------------------------------------------------- /3-iterators-and-generators/iterators/unbuffered_chan.go: -------------------------------------------------------------------------------- 1 | package iterators 2 | 3 | var sumUnbufferedChan int 4 | 5 | func UnbufferedChanLoop(n int) int { 6 | ch := make(chan int) 7 | 8 | go func() { 9 | defer close(ch) 10 | for i := 0; i < n; i++ { 11 | ch <- i 12 | } 13 | }() 14 | 15 | for j := range ch { 16 | sumUnbufferedChan += j 17 | } 18 | return sumUnbufferedChan 19 | } 20 | -------------------------------------------------------------------------------- /4-standard-template-library/algorithms/minmax.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func findMinInt(a []int) int { 6 | var minInt int = a[0] 7 | for _, i := range a { 8 | if minInt > i { 9 | minInt = i 10 | } 11 | } 12 | return minInt 13 | 14 | } 15 | 16 | func findMaxInt(b []int) int { 17 | var max int = b[0] 18 | for _, i := range b { 19 | if max < i { 20 | max = i 21 | } 22 | } 23 | return max 24 | } 25 | 26 | func main() { 27 | intData := []int{3, 1, 2, 5, 6, 4} 28 | minResult := findMinInt(intData) 29 | maxResult := findMaxInt(intData) 30 | fmt.Println("Minimum value in array: ", minResult) 31 | fmt.Println("Maximum value in array: ", maxResult) 32 | } 33 | -------------------------------------------------------------------------------- /4-standard-template-library/algorithms/reverse.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func reverse(s []string) []string { 8 | for x, y := 0, len(s)-1; x < y; x, y = x+1, y-1 { 9 | s[x], s[y] = s[y], s[x] 10 | } 11 | return s 12 | } 13 | func main() { 14 | s := []string{"foo", "bar", "baz", "go", "stop"} 15 | reversedS := reverse(s) 16 | fmt.Println(reversedS) 17 | } 18 | -------------------------------------------------------------------------------- /4-standard-template-library/algorithms/search.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "sort" 6 | ) 7 | 8 | func main() { 9 | data := []int{1, 2, 3, 4, 5, 6} 10 | findInt := 2 11 | out := sort.Search(len(data), func(i int) bool { return data[i] >= findInt }) 12 | fmt.Printf("Integer %d was found in %d at position %d\n", findInt, data, out) 13 | } 14 | -------------------------------------------------------------------------------- /4-standard-template-library/algorithms/sort.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "sort" 6 | ) 7 | 8 | func main() { 9 | 10 | intData := []int{3, 1, 2, 5, 6, 4} 11 | stringData := []string{"foo", "bar", "baz"} 12 | floatData := []float64{1.5, 3.6, 2.5, 10.6} 13 | 14 | sort.Ints(intData) 15 | sort.Strings(stringData) 16 | sort.Float64s(floatData) 17 | 18 | fmt.Println("Sorted Integers: ", intData, "\nSorted Strings: ", stringData, "\nSorted Floats: ", floatData) 19 | } 20 | -------------------------------------------------------------------------------- /4-standard-template-library/algorithms/vector.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import vector "container/vector" 4 | import "fmt" 5 | 6 | func main() { 7 | vec := vector.New(0) 8 | buf := make([]byte, 10) 9 | vec.Push(buf) 10 | 11 | for i := 0; i < vec.Len(); i++ { 12 | el := vec.At(i).([]byte) 13 | fmt.Print(el, "\n") 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /4-standard-template-library/containers/deque.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "gopkg.in/karalabe/cookiejar.v1/collections/deque" 7 | ) 8 | 9 | func main() { 10 | d := deque.New() 11 | elements := []string{"foo", "bar", "baz"} 12 | for i := range elements { 13 | d.PushLeft(elements[i]) 14 | } 15 | fmt.Println(d.PopLeft()) // queue => ["foo", "bar"] 16 | fmt.Println(d.PopRight()) // queue => ["bar"] 17 | fmt.Println(d.PopLeft()) // queue => empty 18 | } 19 | -------------------------------------------------------------------------------- /4-standard-template-library/containers/go.mod: -------------------------------------------------------------------------------- 1 | module . 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 // indirect 7 | github.com/jupp0r/go-priority-queue v0.0.0-20160601094913-ab1073853bde // indirect 8 | github.com/jwangsadinata/go-multimap v0.0.0-20180421172204-599609688a40 // indirect 9 | github.com/soniakeys/multiset v1.0.0 // indirect 10 | gopkg.in/karalabe/cookiejar.v1 v1.0.0-20141109175019-e1490cae028c // indirect 11 | ) 12 | -------------------------------------------------------------------------------- /4-standard-template-library/containers/map.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | m := make(map[int]string) 7 | m[1] = "car" 8 | m[2] = "train" 9 | m[3] = "plane" 10 | fmt.Println("Full Map:\t ", m) 11 | fmt.Println("m[3] value:\t ", m[3]) 12 | fmt.Println("Length of map:\t ", len(m)) 13 | } 14 | -------------------------------------------------------------------------------- /4-standard-template-library/containers/multimap.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/jwangsadinata/go-multimap/slicemultimap" 7 | ) 8 | 9 | type cars []struct { 10 | year int 11 | style string 12 | } 13 | 14 | func main() { 15 | 16 | newCars := cars{{2019, "convertible"}, {1966, "fastback"}, {2019, "SUV"}, {1920, "truck"}} 17 | multimap := slicemultimap.New() 18 | 19 | for _, car := range newCars { 20 | multimap.Put(car.year, car.style) 21 | } 22 | 23 | for _, style := range multimap.KeySet() { 24 | color, _ := multimap.Get(style) 25 | fmt.Printf("%v: %v\n", style, color) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /4-standard-template-library/containers/multiset.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/soniakeys/multiset" 7 | ) 8 | 9 | func main() { 10 | x := multiset.Multiset{"foo": 1, "bar": 2, "baz": 3} 11 | fmt.Println("x: ", x) 12 | // Create a scaled version of x 13 | y := multiset.Scale(x, 2) 14 | fmt.Println("y: ", y) 15 | // Test to see if x is a subset of y 16 | // We created y by scaling x, so it should 17 | // be a subset 18 | fmt.Print("x is a subset of y: ") 19 | fmt.Println(multiset.Subset(x, y)) 20 | 21 | fmt.Print("Cardinality of x: ") 22 | fmt.Println(x.Cardinality()) 23 | } 24 | -------------------------------------------------------------------------------- /4-standard-template-library/containers/priorityQueue.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | pq "github.com/jupp0r/go-priority-queue" 7 | ) 8 | 9 | func main() { 10 | priorityQueue := pq.New() 11 | priorityQueue.Insert("java", 1) 12 | priorityQueue.Insert("golang", 1) 13 | priorityQueue.Insert("php", 2) 14 | priorityQueue.UpdatePriority("java", 3) 15 | for priorityQueue.Len() > 0 { 16 | val, err := priorityQueue.Pop() 17 | if err != nil { 18 | panic(err) 19 | } 20 | fmt.Println(val) 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /4-standard-template-library/containers/queue.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | 7 | var simpleQueue []string 8 | simpleQueue = append(simpleQueue, "Performance ") 9 | simpleQueue = append(simpleQueue, "Go") 10 | 11 | for len(simpleQueue) > 0 { 12 | fmt.Println(simpleQueue[0]) // First element 13 | simpleQueue = simpleQueue[1:] // Dequeue 14 | } 15 | fmt.Println(simpleQueue) //All items are dequeued so result should be [] 16 | } 17 | -------------------------------------------------------------------------------- /4-standard-template-library/containers/set.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | s := make(map[int]bool) 7 | 8 | for i := 0; i < 5; i++ { 9 | s[i] = true 10 | } 11 | 12 | delete(s, 4) 13 | 14 | if s[2] { 15 | fmt.Println("s[2] is set") 16 | } 17 | if !s[4] { 18 | fmt.Println("s[4] was deleted") 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /4-standard-template-library/containers/slice.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | // Remove i indexed item in slice 6 | func remove(s []string, i int) []string { 7 | copy(s[i:], s[i+1:]) 8 | return s[:len(s)-1] 9 | } 10 | 11 | func main() { 12 | slice := []string{"foo", "bar", "baz"} // create a slice 13 | slice = append(slice, "tri") // append a slice 14 | fmt.Println("Appended Slice: ", slice) // print slice [foo, bar baz, tri] 15 | slice = remove(slice, 2) // remove slice item #2 (baz) 16 | fmt.Println("After Removed Item: ", slice) // print slice [foo, bar, tri] 17 | } 18 | -------------------------------------------------------------------------------- /4-standard-template-library/containers/stack.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | stack "github.com/golang-collections/collections/stack" 7 | ) 8 | 9 | func main() { 10 | // Create a new stack 11 | fmt.Println("Creating New Stack") 12 | exstack := stack.New() 13 | fmt.Println("Pushing 1 to stack") 14 | exstack.Push(1) // push 1 to stack 15 | fmt.Println("Top of Stack is : ", exstack.Peek()) 16 | fmt.Println("Popping 1 from stack") 17 | exstack.Pop() // remove 1 from stack 18 | fmt.Println("Stack length is : ", exstack.Len()) 19 | } 20 | -------------------------------------------------------------------------------- /4-standard-template-library/functions/functor.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/go-functional/core/functor" 7 | ) 8 | 9 | func main() { 10 | intSlice := []int{1, 3, 5, 7} 11 | fmt.Println("Int Slice:\t", intSlice) 12 | intFunctor := functor.LiftIntSlice(intSlice) 13 | fmt.Println("Lifted Slice:\t", intFunctor) 14 | 15 | // Apply a square to our given functor 16 | squareFunc := func(i int) int { 17 | return i * i 18 | } 19 | 20 | // Apply a mod 3 to our given functor 21 | modThreeFunc := func(i int) int { 22 | return i % 3 23 | } 24 | 25 | squared := intFunctor.Map(squareFunc) 26 | fmt.Println("Squared: \t", squared) 27 | 28 | modded := squared.Map(modThreeFunc) 29 | fmt.Println("Modded: \t", modded) 30 | } 31 | -------------------------------------------------------------------------------- /4-standard-template-library/functions/go.mod: -------------------------------------------------------------------------------- 1 | module . 2 | 3 | go 1.12 4 | 5 | require github.com/go-functional/core v0.0.0-20170807232657-2963c8ec15f6 // indirect 6 | -------------------------------------------------------------------------------- /4-standard-template-library/functions/go.sum: -------------------------------------------------------------------------------- 1 | github.com/go-functional/core v0.0.0-20170807232657-2963c8ec15f6 h1:FFIXjYA6wlryvUEeqt7yYHvjcPBGibw3buSZQ6Ye8FM= 2 | github.com/go-functional/core v0.0.0-20170807232657-2963c8ec15f6/go.mod h1:mVpr89B5FDMBYEuVEPPXKctZcP7FL9YScc5oSB+6Qac= 3 | -------------------------------------------------------------------------------- /4-standard-template-library/iterators/for.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | for i := 0; i < 5; i++ { 7 | fmt.Println("Hi Gophers!") 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /4-standard-template-library/iterators/range.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | stringExample := []string{"foo", "bar", "baz"} 7 | for i, out := range stringExample { 8 | fmt.Println(i, out) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /5-vectors-and-matrices/cscMatrix.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/james-bowman/sparse" 7 | "gonum.org/v1/gonum/mat" 8 | ) 9 | 10 | func main() { 11 | sparseMatrix := sparse.NewDOK(4, 4) 12 | sparseMatrix.Set(0, 2, 1) 13 | sparseMatrix.Set(1, 0, 2) 14 | sparseMatrix.Set(2, 3, 3) 15 | sparseMatrix.Set(3, 1, 4) 16 | fmt.Print("DOK Matrix:\n", mat.Formatted(sparseMatrix), "\n\n") // Dictionary of Keys 17 | fmt.Print("CSC Matrix:\n", sparseMatrix.ToCSC(), "\n\n") // Print CSC version 18 | } 19 | -------------------------------------------------------------------------------- /5-vectors-and-matrices/csrMatrix.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/james-bowman/sparse" 7 | "gonum.org/v1/gonum/mat" 8 | ) 9 | 10 | func main() { 11 | sparseMatrix := sparse.NewDOK(4, 4) 12 | sparseMatrix.Set(0, 2, 1) 13 | sparseMatrix.Set(1, 0, 2) 14 | sparseMatrix.Set(2, 3, 3) 15 | sparseMatrix.Set(3, 1, 4) 16 | fmt.Print("DOK Matrix:\n", mat.Formatted(sparseMatrix), "\n\n") // Dictionary of Keys 17 | fmt.Print("CSR Matrix:\n", sparseMatrix.ToCSR(), "\n\n") // Print CSR version of the matrix 18 | } 19 | -------------------------------------------------------------------------------- /5-vectors-and-matrices/go.mod: -------------------------------------------------------------------------------- 1 | module . 2 | 3 | go 1.12 4 | 5 | require gonum.org/v1/gonum v0.0.0-20190608115022-c5f01565d866 // indirect 6 | -------------------------------------------------------------------------------- /5-vectors-and-matrices/go.sum: -------------------------------------------------------------------------------- 1 | golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 2 | golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 3 | gonum.org/v1/gonum v0.0.0-20190608115022-c5f01565d866 h1:FqYrBXUEWecz6YveEJaEVE2Hz7IZuKxUbyXGn//xmEs= 4 | gonum.org/v1/gonum v0.0.0-20190608115022-c5f01565d866/go.mod h1:zXcK6UmEkbNk22MqyPrZPx3T6fsE/O56XzkDfeYUF+Y= 5 | gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= 6 | -------------------------------------------------------------------------------- /5-vectors-and-matrices/gonumVector.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "gonum.org/v1/gonum/mat" 7 | ) 8 | 9 | func matrixPrint(m mat.Matrix) { 10 | formattedMatrix := mat.Formatted(m, mat.Prefix(""), mat.Squeeze()) 11 | fmt.Printf("%v\n", formattedMatrix) 12 | } 13 | func main() { 14 | v := mat.NewVecDense(4, []float64{0, 1, 2, 3}) 15 | matrixPrint(v) 16 | } 17 | -------------------------------------------------------------------------------- /5-vectors-and-matrices/matrixAdd.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "gonum.org/v1/gonum/mat" 7 | ) 8 | 9 | func main() { 10 | a := mat.NewDense(2, 2, []float64{0, 1, 2, 3}) 11 | b := mat.NewDense(2, 2, []float64{4, 5, 6, 7}) 12 | c := mat.NewDense(2, 2, nil) 13 | c.Sub(b, a) 14 | fmt.Println(c) 15 | } 16 | -------------------------------------------------------------------------------- /5-vectors-and-matrices/matrixMult.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "gonum.org/v1/gonum/mat" 7 | ) 8 | 9 | func main() { 10 | a := mat.NewDense(1, 3, []float64{0.10, 0.42, 0.37}) 11 | b := mat.NewDense(3, 2, []float64{5, 8, 10, 6, 2, 3}) 12 | var c mat.Dense 13 | c.Mul(a, b) 14 | result := mat.Formatted(&c, mat.Prefix(""), mat.Squeeze()) 15 | fmt.Println(result) 16 | } 17 | -------------------------------------------------------------------------------- /5-vectors-and-matrices/matrixMultTwo.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "gonum.org/v1/gonum/mat" 7 | ) 8 | 9 | func main() { 10 | a := mat.NewDense(2, 2, []float64{1, 2, 3, 4}) 11 | b := mat.NewDense(2, 3, []float64{1, 2, 3, 4, 5, 6}) 12 | var c mat.Dense 13 | c.Mul(a, b) 14 | result := mat.Formatted(&c, mat.Prefix(""), mat.Squeeze()) 15 | fmt.Println(result) 16 | } 17 | -------------------------------------------------------------------------------- /5-vectors-and-matrices/matrixScale.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "gonum.org/v1/gonum/mat" 7 | ) 8 | 9 | func main() { 10 | usd := mat.NewDense(3, 3, []float64{0.1, 0.05, 0.03, 0.06, 0.04, 0.02, 0.03, 0.02, 0.01}) 11 | var cad mat.Dense 12 | cad.Scale(1.34, usd) 13 | result := mat.Formatted(&cad, mat.Prefix(""), mat.Squeeze()) 14 | fmt.Println(result) 15 | } 16 | -------------------------------------------------------------------------------- /5-vectors-and-matrices/matrixSub.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "gonum.org/v1/gonum/mat" 7 | ) 8 | 9 | func main() { 10 | a := mat.NewDense(4, 2, []float64{1345, 823, 346, 234, 843, 945, 442, 692}) 11 | b := mat.NewDense(4, 2, []float64{920, 776, 498, 439, 902, 1023, 663, 843}) 12 | var c mat.Dense 13 | c.Sub(b, a) 14 | result := mat.Formatted(&c, mat.Prefix(""), mat.Squeeze()) 15 | fmt.Println(result) 16 | } 17 | -------------------------------------------------------------------------------- /5-vectors-and-matrices/matrixSum.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "gonum.org/v1/gonum/mat" 7 | ) 8 | 9 | func main() { 10 | a := mat.NewDense(3, 3, []float64{1, 2, 3, 4, 5, 6, 7, 8, 9}) 11 | a.Add(a, a) // add a and a together 12 | matrixPrint(a) 13 | } 14 | 15 | func matrixPrint(m mat.Matrix) { 16 | formattedMatrix := mat.Formatted(m, mat.Prefix(""), mat.Squeeze()) 17 | fmt.Printf("%v\n", formattedMatrix) 18 | } 19 | -------------------------------------------------------------------------------- /5-vectors-and-matrices/matrixTranspose.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "gonum.org/v1/gonum/mat" 7 | ) 8 | 9 | func main() { 10 | a := mat.NewDense(3, 3, []float64{5, 3, 10, 1, 6, 4, 8, 7, 2}) 11 | matrixPrint(a) 12 | matrixPrint(a.T()) 13 | } 14 | 15 | func matrixPrint(m mat.Matrix) { 16 | formattedMatrix := mat.Formatted(m, mat.Prefix(""), mat.Squeeze()) 17 | fmt.Printf("%v\n", formattedMatrix) 18 | } 19 | -------------------------------------------------------------------------------- /5-vectors-and-matrices/scaleMatrix.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "gonum.org/v1/gonum/mat" 7 | ) 8 | 9 | func main() { 10 | a := mat.NewDense(3, 3, []float64{1, 2, 3, 4, 5, 6, 7, 8, 9}) 11 | a.Scale(4, a) // Scale matrix by 4 12 | matrixPrint(a) 13 | } 14 | 15 | func matrixPrint(m mat.Matrix) { 16 | formattedMatrix := mat.Formatted(m, mat.Prefix(""), mat.Squeeze()) 17 | fmt.Printf("%v\n", formattedMatrix) 18 | } 19 | -------------------------------------------------------------------------------- /5-vectors-and-matrices/sliceVector.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | v := []int{1, 2, 3} 7 | fmt.Println(v) 8 | } 9 | -------------------------------------------------------------------------------- /5-vectors-and-matrices/sparseMatrix.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/james-bowman/sparse" 7 | "gonum.org/v1/gonum/mat" 8 | ) 9 | 10 | func main() { 11 | sparseMatrix := sparse.NewDOK(3, 3) 12 | sparseMatrix.Set(0, 0, 5) 13 | sparseMatrix.Set(1, 1, 1) 14 | sparseMatrix.Set(2, 1, -3) 15 | fmt.Println(mat.Formatted(sparseMatrix)) 16 | csrMatrix := sparseMatrix.ToCSR() 17 | fmt.Println(mat.Formatted(csrMatrix)) 18 | cscMatrix := sparseMatrix.ToCSC() 19 | fmt.Println(mat.Formatted(cscMatrix)) 20 | } 21 | -------------------------------------------------------------------------------- /5-vectors-and-matrices/testCSRMatrix.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/james-bowman/sparse" 7 | "gonum.org/v1/gonum/mat" 8 | ) 9 | 10 | func main() { 11 | sparseMatrix := sparse.NewDOK(4, 4) 12 | sparseMatrix.Set(1, 0, 5) 13 | sparseMatrix.Set(1, 1, 8) 14 | sparseMatrix.Set(2, 2, 3) 15 | sparseMatrix.Set(3, 1, 6) 16 | fmt.Print("DOK Matrix:\n", mat.Formatted(sparseMatrix), "\n\n") // Dictionary of Keys 17 | fmt.Print("CSR Matrix:\n", sparseMatrix.ToCSR(), "\n\n") // Print CSR version of the matrix 18 | } 19 | -------------------------------------------------------------------------------- /5-vectors-and-matrices/transposeMatrix.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "gonum.org/v1/gonum/mat" 7 | ) 8 | 9 | func main() { 10 | a := mat.NewDense(2, 3, []float64{0, 1, 2, 3, 4, 5}) 11 | matrixPrint(a) 12 | matrixPrint(a.T()) 13 | } 14 | 15 | func matrixPrint(m mat.Matrix) { 16 | formattedMatrix := mat.Formatted(m, mat.Prefix(""), mat.Squeeze()) 17 | fmt.Printf("%v\n", formattedMatrix) 18 | } 19 | -------------------------------------------------------------------------------- /5-vectors-and-matrices/vectorManipulation.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "gonum.org/v1/gonum/mat" 7 | ) 8 | 9 | func main() { 10 | v := mat.NewVecDense(5, []float64{1, 2, 3, 4, 5}) 11 | d := mat.NewVecDense(5, nil) 12 | d.AddVec(v, v) 13 | prettyPrintMatrix(d) 14 | } 15 | 16 | func prettyPrintMatrix(m mat.Matrix) { 17 | formattedM := mat.Formatted(m, mat.Prefix(""), mat.Squeeze()) 18 | fmt.Printf("%v\n", formattedM) 19 | } 20 | -------------------------------------------------------------------------------- /5-vectors-and-matrices/vectorMult.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "gonum.org/v1/gonum/mat" 7 | ) 8 | 9 | func main() { 10 | v := mat.NewVecDense(5, []float64{1, 2, 3, 4, 5}) 11 | d := mat.NewVecDense(5, nil) 12 | d.AddVec(v, v) 13 | fmt.Println(d) 14 | } 15 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/antipatternDirectory/notifications/email/email.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/antipatternDirectory/notifications/email/email.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/antipatternDirectory/notifications/email/email_test.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/antipatternDirectory/notifications/email/email_test.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/antipatternDirectory/notifications/pagerduty/pagerduty.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/antipatternDirectory/notifications/pagerduty/pagerduty.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/antipatternDirectory/notifications/pagerduty/pagerduty_test.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/antipatternDirectory/notifications/pagerduty/pagerduty_test.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/antipatternDirectory/notifications/pushnotify/pushnotify.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/antipatternDirectory/notifications/pushnotify/pushnotify.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/antipatternDirectory/notifications/pushnotify/pushnotify_test.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/antipatternDirectory/notifications/pushnotify/pushnotify_test.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/antipatternDirectory/notifications/slack/slack.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/antipatternDirectory/notifications/slack/slack.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/antipatternDirectory/notifications/slack/slack_test.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/antipatternDirectory/notifications/slack/slack_test.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/antipatternDirectory/notifications/trello/trello.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/antipatternDirectory/notifications/trello/trello.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/antipatternDirectory/notifications/trello/trello_test.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/antipatternDirectory/notifications/trello/trello_test.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/embeddedStructs.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | 7 | type Utensils struct { 8 | fork string 9 | spoon string 10 | knife string 11 | } 12 | 13 | type Appliances struct { 14 | stove string 15 | dishwasher string 16 | oven string 17 | } 18 | 19 | type Kitchen struct { 20 | Utensils 21 | Appliances 22 | } 23 | 24 | bobKitchen := new(Kitchen) 25 | bobKitchen.Utensils.fork = "3 prong" 26 | bobKitchen.Utensils.knife = "dull" 27 | bobKitchen.Utensils.spoon = "deep" 28 | bobKitchen.Appliances.stove = "6 burner" 29 | bobKitchen.Appliances.dishwasher = "3 rack" 30 | bobKitchen.Appliances.oven = "self cleaning" 31 | 32 | fmt.Printf("%+v\n", bobKitchen) 33 | } 34 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/emptyInterface.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var x interface{} 7 | x = "hello Go" 8 | fmt.Printf("(%v, %T)\n", x, x) 9 | x = 123 10 | fmt.Printf("(%v, %T)\n", x, x) 11 | x = true 12 | fmt.Printf("(%v, %T)\n", x, x) 13 | } 14 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/exampleProgram/.dockerignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/exampleProgram/.dockerignore -------------------------------------------------------------------------------- /6-composing-readable-go-code/exampleProgram/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/exampleProgram/.gitignore -------------------------------------------------------------------------------- /6-composing-readable-go-code/exampleProgram/Dockerfile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/exampleProgram/Dockerfile -------------------------------------------------------------------------------- /6-composing-readable-go-code/exampleProgram/Jenkinsfile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/exampleProgram/Jenkinsfile -------------------------------------------------------------------------------- /6-composing-readable-go-code/exampleProgram/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/exampleProgram/README.md -------------------------------------------------------------------------------- /6-composing-readable-go-code/exampleProgram/cmd/examplecli/main.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/exampleProgram/cmd/examplecli/main.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/exampleProgram/cmd/exampleweb/main.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/exampleProgram/cmd/exampleweb/main.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/exampleProgram/go.mod: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/exampleProgram/go.mod -------------------------------------------------------------------------------- /6-composing-readable-go-code/exampleProgram/go.sum: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/exampleProgram/go.sum -------------------------------------------------------------------------------- /6-composing-readable-go-code/exampleProgram/pkg/api/api.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/exampleProgram/pkg/api/api.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/exampleProgram/pkg/api/api_test.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/exampleProgram/pkg/api/api_test.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/exampleProgram/pkg/integration/integration.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/exampleProgram/pkg/integration/integration.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/exampleProgram/pkg/integration/integration_test.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/exampleProgram/pkg/integration/integration_test.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/exampleProgram/pkg/notification/notification.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/exampleProgram/pkg/notification/notification.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/exampleProgram/pkg/notification/notification_test.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/exampleProgram/pkg/notification/notification_test.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "github.com/gin-gonic/gin" 4 | 5 | func main() { 6 | server := gin.Default() 7 | server.GET("/foo", func(c *gin.Context) { 8 | c.JSON(200, gin.H{ 9 | "response": "bar", 10 | }) 11 | }) 12 | server.Run() 13 | } 14 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/gin-contrib/sse/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | go: 4 | - 1.8.x 5 | - 1.9.x 6 | - 1.10.x 7 | - 1.11.x 8 | - 1.12.x 9 | - master 10 | 11 | git: 12 | depth: 10 13 | 14 | matrix: 15 | fast_finish: true 16 | include: 17 | - go: 1.11.x 18 | env: GO111MODULE=on 19 | - go: 1.12.x 20 | env: GO111MODULE=on 21 | 22 | script: 23 | - go test -v -covermode=count -coverprofile=coverage.out 24 | 25 | after_success: 26 | - bash <(curl -s https://codecov.io/bash) 27 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/gin-contrib/sse/writer.go: -------------------------------------------------------------------------------- 1 | package sse 2 | 3 | import "io" 4 | 5 | type stringWriter interface { 6 | io.Writer 7 | WriteString(string) (int, error) 8 | } 9 | 10 | type stringWrapper struct { 11 | io.Writer 12 | } 13 | 14 | func (w stringWrapper) WriteString(str string) (int, error) { 15 | return w.Writer.Write([]byte(str)) 16 | } 17 | 18 | func checkWriter(writer io.Writer) stringWriter { 19 | if w, ok := writer.(stringWriter); ok { 20 | return w 21 | } else { 22 | return stringWrapper{writer} 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/gin-gonic/gin/.gitignore: -------------------------------------------------------------------------------- 1 | vendor/* 2 | !vendor/vendor.json 3 | coverage.out 4 | count.out 5 | test 6 | profile.out 7 | tmp.out 8 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/gin-gonic/gin/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | 3 | - With issues: 4 | - Use the search tool before opening a new issue. 5 | - Please provide source code and commit sha if you found a bug. 6 | - Review existing issues and provide feedback or react to them. 7 | 8 | - With pull requests: 9 | - Open your pull request against `master` 10 | - Your pull request should have no more than two commits, if not you should squash them. 11 | - It should pass all tests in the available continuous integration systems such as TravisCI. 12 | - You should add/modify tests to cover your proposed code changes. 13 | - If your pull request contains a new feature, please document it on the README. 14 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/gin-gonic/gin/binding/query.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package binding 6 | 7 | import "net/http" 8 | 9 | type queryBinding struct{} 10 | 11 | func (queryBinding) Name() string { 12 | return "query" 13 | } 14 | 15 | func (queryBinding) Bind(req *http.Request, obj interface{}) error { 16 | values := req.URL.Query() 17 | if err := mapForm(obj, values); err != nil { 18 | return err 19 | } 20 | return validate(obj) 21 | } 22 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/gin-gonic/gin/binding/uri.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Gin Core Team. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package binding 6 | 7 | type uriBinding struct{} 8 | 9 | func (uriBinding) Name() string { 10 | return "uri" 11 | } 12 | 13 | func (uriBinding) BindUri(m map[string][]string, obj interface{}) error { 14 | if err := mapUri(obj, m); err != nil { 15 | return err 16 | } 17 | return validate(obj) 18 | } 19 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/gin-gonic/gin/codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | notify: 3 | gitter: 4 | default: 5 | url: https://webhooks.gitter.im/e/d90dcdeeab2f1e357165 6 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/gin-gonic/gin/context_appengine.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | //go:build appengine 6 | // +build appengine 7 | 8 | package gin 9 | 10 | func init() { 11 | defaultAppEngine = true 12 | } 13 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/gin-gonic/gin/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Package gin implements a HTTP web framework called gin. 3 | 4 | See https://gin-gonic.com/ for more information about gin. 5 | */ 6 | package gin // import "github.com/gin-gonic/gin" 7 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/gin-gonic/gin/test_helpers.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Manu Martinez-Almeida. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package gin 6 | 7 | import "net/http" 8 | 9 | // CreateTestContext returns a fresh engine and context for testing purposes 10 | func CreateTestContext(w http.ResponseWriter) (c *Context, r *Engine) { 11 | r = New() 12 | c = r.allocateContext() 13 | c.reset() 14 | c.writermem.reset(w) 15 | return 16 | } 17 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/gin-gonic/gin/version.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Gin Core Team. All rights reserved. 2 | // Use of this source code is governed by a MIT style 3 | // license that can be found in the LICENSE file. 4 | 5 | package gin 6 | 7 | // Version is the current gin framework's version. 8 | const Version = "v1.7.0" 9 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/go-playground/locales/.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 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/go-playground/locales/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.13.1 4 | - tip 5 | matrix: 6 | allow_failures: 7 | - go: tip 8 | 9 | notifications: 10 | email: 11 | recipients: dean.karn@gmail.com 12 | on_success: change 13 | on_failure: always 14 | 15 | before_install: 16 | - go install github.com/mattn/goveralls 17 | 18 | # Only clone the most recent commit. 19 | git: 20 | depth: 1 21 | 22 | script: 23 | - go test -v -race -covermode=atomic -coverprofile=coverage.coverprofile ./... 24 | 25 | after_success: | 26 | goveralls -coverprofile=coverage.coverprofile -service travis-ci -repotoken $COVERALLS_TOKEN -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/go-playground/locales/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/goModulesExample/vendor/github.com/go-playground/locales/logo.png -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/go-playground/universal-translator/.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 | *.coverprofile -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/go-playground/universal-translator/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.13.4 4 | - tip 5 | matrix: 6 | allow_failures: 7 | - go: tip 8 | 9 | notifications: 10 | email: 11 | recipients: dean.karn@gmail.com 12 | on_success: change 13 | on_failure: always 14 | 15 | before_install: 16 | - go install github.com/mattn/goveralls 17 | 18 | # Only clone the most recent commit. 19 | git: 20 | depth: 1 21 | 22 | script: 23 | - go test -v -race -covermode=atomic -coverprofile=coverage.coverprofile ./... 24 | 25 | after_success: | 26 | [ $TRAVIS_GO_VERSION = 1.13.4 ] && 27 | goveralls -coverprofile=coverage.coverprofile -service travis-ci -repotoken $COVERALLS_TOKEN -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/go-playground/universal-translator/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/goModulesExample/vendor/github.com/go-playground/universal-translator/logo.png -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/go-playground/validator/v10/.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 | bin 10 | 11 | # Architecture specific extensions/prefixes 12 | *.[568vq] 13 | [568vq].out 14 | 15 | *.cgo1.go 16 | *.cgo2.c 17 | _cgo_defun.c 18 | _cgo_gotypes.go 19 | _cgo_export.* 20 | 21 | _testmain.go 22 | 23 | *.exe 24 | *.test 25 | *.prof 26 | *.test 27 | *.out 28 | *.txt 29 | cover.html 30 | README.html 31 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/go-playground/validator/v10/Makefile: -------------------------------------------------------------------------------- 1 | GOCMD=GO111MODULE=on go 2 | 3 | linters-install: 4 | @golangci-lint --version >/dev/null 2>&1 || { \ 5 | echo "installing linting tools..."; \ 6 | curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.21.0; \ 7 | } 8 | 9 | lint: linters-install 10 | $(PWD)/bin/golangci-lint run 11 | 12 | test: 13 | $(GOCMD) test -cover -race ./... 14 | 15 | bench: 16 | $(GOCMD) test -bench=. -benchmem ./... 17 | 18 | .PHONY: test lint linters-install -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/go-playground/validator/v10/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/goModulesExample/vendor/github.com/go-playground/validator/v10/logo.png -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/go-playground/validator/v10/translations.go: -------------------------------------------------------------------------------- 1 | package validator 2 | 3 | import ut "github.com/go-playground/universal-translator" 4 | 5 | // TranslationFunc is the function type used to register or override 6 | // custom translations 7 | type TranslationFunc func(ut ut.Translator, fe FieldError) string 8 | 9 | // RegisterTranslationsFunc allows for registering of translations 10 | // for a 'ut.Translator' for use within the 'TranslationFunc' 11 | type RegisterTranslationsFunc func(ut ut.Translator) error 12 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/golang/protobuf/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/golang/protobuf/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/json-iterator/go/.codecov.yml: -------------------------------------------------------------------------------- 1 | ignore: 2 | - "output_tests/.*" 3 | 4 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/json-iterator/go/.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | /bug_test.go 3 | /coverage.txt 4 | /.idea 5 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/json-iterator/go/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.8.x 5 | - 1.x 6 | 7 | before_install: 8 | - go get -t -v ./... 9 | 10 | script: 11 | - ./test.sh 12 | 13 | after_success: 14 | - bash <(curl -s https://codecov.io/bash) 15 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/json-iterator/go/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | set -x 4 | 5 | if [ ! -d /tmp/build-golang/src/github.com/json-iterator ]; then 6 | mkdir -p /tmp/build-golang/src/github.com/json-iterator 7 | ln -s $PWD /tmp/build-golang/src/github.com/json-iterator/go 8 | fi 9 | export GOPATH=/tmp/build-golang 10 | go get -u github.com/golang/dep/cmd/dep 11 | cd /tmp/build-golang/src/github.com/json-iterator/go 12 | exec $GOPATH/bin/dep ensure -update 13 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/json-iterator/go/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | echo "" > coverage.txt 5 | 6 | for d in $(go list ./... | grep -v vendor); do 7 | go test -coverprofile=profile.out -coverpkg=github.com/json-iterator/go $d 8 | if [ -f profile.out ]; then 9 | cat profile.out >> coverage.txt 10 | rm profile.out 11 | fi 12 | done 13 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/leodido/go-urn/.gitignore: -------------------------------------------------------------------------------- 1 | *.exe 2 | *.dll 3 | *.so 4 | *.dylib 5 | 6 | *.test 7 | 8 | *.out 9 | *.txt 10 | 11 | vendor/ -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/leodido/go-urn/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.9.x 5 | - 1.10.x 6 | - 1.11.x 7 | - 1.12.x 8 | - 1.13.x 9 | - tip 10 | 11 | before_install: 12 | - go get -t -v ./... 13 | 14 | script: 15 | - go test -race -coverprofile=coverage.txt -covermode=atomic 16 | 17 | after_success: 18 | - bash <(curl -s https://codecov.io/bash) -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/mattn/go-isatty/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | go: 4 | - 1.13.x 5 | - tip 6 | 7 | before_install: 8 | - go get -t -v ./... 9 | 10 | script: 11 | - ./go.test.sh 12 | 13 | after_success: 14 | - bash <(curl -s https://codecov.io/bash) 15 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/mattn/go-isatty/doc.go: -------------------------------------------------------------------------------- 1 | // Package isatty implements interface to isatty 2 | package isatty 3 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/mattn/go-isatty/go.test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | echo "" > coverage.txt 5 | 6 | for d in $(go list ./... | grep -v vendor); do 7 | go test -race -coverprofile=profile.out -covermode=atomic "$d" 8 | if [ -f profile.out ]; then 9 | cat profile.out >> coverage.txt 10 | rm profile.out 11 | fi 12 | done 13 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/mattn/go-isatty/isatty_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import "golang.org/x/sys/unix" 7 | 8 | // IsTerminal return true if the file descriptor is terminal. 9 | func IsTerminal(fd uintptr) bool { 10 | _, err := unix.IoctlGetTermios(int(fd), unix.TIOCGETA) 11 | return err == nil 12 | } 13 | 14 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 15 | // terminal. This is also always false on this environment. 16 | func IsCygwinTerminal(fd uintptr) bool { 17 | return false 18 | } 19 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/mattn/go-isatty/isatty_others.go: -------------------------------------------------------------------------------- 1 | // +build appengine js nacl 2 | 3 | package isatty 4 | 5 | // IsTerminal returns true if the file descriptor is terminal which 6 | // is always false on js and appengine classic which is a sandboxed PaaS. 7 | func IsTerminal(fd uintptr) bool { 8 | return false 9 | } 10 | 11 | // IsCygwinTerminal() return true if the file descriptor is a cygwin or msys2 12 | // terminal. This is also always false on this environment. 13 | func IsCygwinTerminal(fd uintptr) bool { 14 | return false 15 | } 16 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/mattn/go-isatty/isatty_plan9.go: -------------------------------------------------------------------------------- 1 | // +build plan9 2 | 3 | package isatty 4 | 5 | import ( 6 | "syscall" 7 | ) 8 | 9 | // IsTerminal returns true if the given file descriptor is a terminal. 10 | func IsTerminal(fd uintptr) bool { 11 | path, err := syscall.Fd2path(int(fd)) 12 | if err != nil { 13 | return false 14 | } 15 | return path == "/dev/cons" || path == "/mnt/term/dev/cons" 16 | } 17 | 18 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 19 | // terminal. This is also always false on this environment. 20 | func IsCygwinTerminal(fd uintptr) bool { 21 | return false 22 | } 23 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/mattn/go-isatty/isatty_tcgets.go: -------------------------------------------------------------------------------- 1 | // +build linux aix 2 | // +build !appengine 3 | 4 | package isatty 5 | 6 | import "golang.org/x/sys/unix" 7 | 8 | // IsTerminal return true if the file descriptor is terminal. 9 | func IsTerminal(fd uintptr) bool { 10 | _, err := unix.IoctlGetTermios(int(fd), unix.TCGETS) 11 | return err == nil 12 | } 13 | 14 | // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2 15 | // terminal. This is also always false on this environment. 16 | func IsCygwinTerminal(fd uintptr) bool { 17 | return false 18 | } 19 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/mattn/go-isatty/renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ], 5 | "postUpdateOptions": [ 6 | "gomodTidy" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/concurrent/.gitignore: -------------------------------------------------------------------------------- 1 | /coverage.txt 2 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/concurrent/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.8.x 5 | - 1.x 6 | 7 | before_install: 8 | - go get -t -v ./... 9 | 10 | script: 11 | - ./test.sh 12 | 13 | after_success: 14 | - bash <(curl -s https://codecov.io/bash) 15 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/concurrent/executor.go: -------------------------------------------------------------------------------- 1 | package concurrent 2 | 3 | import "context" 4 | 5 | // Executor replace go keyword to start a new goroutine 6 | // the goroutine should cancel itself if the context passed in has been cancelled 7 | // the goroutine started by the executor, is owned by the executor 8 | // we can cancel all executors owned by the executor just by stop the executor itself 9 | // however Executor interface does not Stop method, the one starting and owning executor 10 | // should use the concrete type of executor, instead of this interface. 11 | type Executor interface { 12 | // Go starts a new goroutine controlled by the context 13 | Go(handler func(ctx context.Context)) 14 | } 15 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/concurrent/go_above_19.go: -------------------------------------------------------------------------------- 1 | //+build go1.9 2 | 3 | package concurrent 4 | 5 | import "sync" 6 | 7 | // Map is a wrapper for sync.Map introduced in go1.9 8 | type Map struct { 9 | sync.Map 10 | } 11 | 12 | // NewMap creates a thread safe Map 13 | func NewMap() *Map { 14 | return &Map{} 15 | } 16 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/concurrent/log.go: -------------------------------------------------------------------------------- 1 | package concurrent 2 | 3 | import ( 4 | "os" 5 | "log" 6 | "io/ioutil" 7 | ) 8 | 9 | // ErrorLogger is used to print out error, can be set to writer other than stderr 10 | var ErrorLogger = log.New(os.Stderr, "", 0) 11 | 12 | // InfoLogger is used to print informational message, default to off 13 | var InfoLogger = log.New(ioutil.Discard, "", 0) -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/concurrent/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | echo "" > coverage.txt 5 | 6 | for d in $(go list ./... | grep -v vendor); do 7 | go test -coverprofile=profile.out -coverpkg=github.com/modern-go/concurrent $d 8 | if [ -f profile.out ]; then 9 | cat profile.out >> coverage.txt 10 | rm profile.out 11 | fi 12 | done 13 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | /coverage.txt 3 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.8.x 5 | - 1.x 6 | 7 | before_install: 8 | - go get -t -v ./... 9 | - go get -t -v github.com/modern-go/reflect2-tests/... 10 | 11 | script: 12 | - ./test.sh 13 | 14 | after_success: 15 | - bash <(curl -s https://codecov.io/bash) 16 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | name = "github.com/modern-go/concurrent" 6 | packages = ["."] 7 | revision = "e0a39a4cb4216ea8db28e22a69f4ec25610d513a" 8 | version = "1.0.0" 9 | 10 | [solve-meta] 11 | analyzer-name = "dep" 12 | analyzer-version = 1 13 | inputs-digest = "daee8a88b3498b61c5640056665b8b9eea062006f5e596bbb6a3ed9119a11ec7" 14 | solver-name = "gps-cdcl" 15 | solver-version = 1 16 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/go_above_17.go: -------------------------------------------------------------------------------- 1 | //+build go1.7 2 | 3 | package reflect2 4 | 5 | import "unsafe" 6 | 7 | //go:linkname resolveTypeOff reflect.resolveTypeOff 8 | func resolveTypeOff(rtype unsafe.Pointer, off int32) unsafe.Pointer 9 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/go_above_19.go: -------------------------------------------------------------------------------- 1 | //+build go1.9 2 | 3 | package reflect2 4 | 5 | import ( 6 | "unsafe" 7 | ) 8 | 9 | //go:linkname makemap reflect.makemap 10 | func makemap(rtype unsafe.Pointer, cap int) (m unsafe.Pointer) 11 | 12 | func makeMapWithSize(rtype unsafe.Pointer, cap int) unsafe.Pointer { 13 | return makemap(rtype, cap) 14 | } 15 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/go_below_17.go: -------------------------------------------------------------------------------- 1 | //+build !go1.7 2 | 3 | package reflect2 4 | 5 | import "unsafe" 6 | 7 | func resolveTypeOff(rtype unsafe.Pointer, off int32) unsafe.Pointer { 8 | return nil 9 | } 10 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/go_below_19.go: -------------------------------------------------------------------------------- 1 | //+build !go1.9 2 | 3 | package reflect2 4 | 5 | import ( 6 | "unsafe" 7 | ) 8 | 9 | //go:linkname makemap reflect.makemap 10 | func makemap(rtype unsafe.Pointer) (m unsafe.Pointer) 11 | 12 | func makeMapWithSize(rtype unsafe.Pointer, cap int) unsafe.Pointer { 13 | return makemap(rtype) 14 | } 15 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/reflect2_amd64.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/reflect2_amd64.s -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/relfect2_386.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/relfect2_386.s -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/relfect2_amd64p32.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/relfect2_amd64p32.s -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/relfect2_arm.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/relfect2_arm.s -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/relfect2_arm64.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/relfect2_arm64.s -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/relfect2_mips64x.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/relfect2_mips64x.s -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/relfect2_mipsx.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/relfect2_mipsx.s -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/relfect2_ppc64x.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/relfect2_ppc64x.s -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/relfect2_s390x.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/relfect2_s390x.s -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/modern-go/reflect2/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | echo "" > coverage.txt 5 | 6 | for d in $(go list github.com/modern-go/reflect2-tests/... | grep -v vendor); do 7 | go test -coverprofile=profile.out -coverpkg=github.com/modern-go/reflect2 $d 8 | if [ -f profile.out ]; then 9 | cat profile.out >> coverage.txt 10 | rm profile.out 11 | fi 12 | done 13 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/ugorji/go/codec/0_importpath.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | package codec // import "github.com/ugorji/go/codec" 5 | 6 | // This establishes that this package must be imported as github.com/ugorji/go/codec. 7 | // It makes forking easier, and plays well with pre-module releases of go. 8 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/ugorji/go/codec/codecgen.go: -------------------------------------------------------------------------------- 1 | // +build codecgen generated 2 | 3 | package codec 4 | 5 | // this file is here, to set the codecgen variable to true 6 | // when the build tag codecgen is set. 7 | // 8 | // this allows us do specific things e.g. skip missing fields tests, 9 | // when running in codecgen mode. 10 | 11 | func init() { 12 | codecgen = true 13 | } 14 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/ugorji/go/codec/goversion_arrayof_gte_go15.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build go1.5 5 | 6 | package codec 7 | 8 | import "reflect" 9 | 10 | const reflectArrayOfSupported = true 11 | 12 | func reflectArrayOf(count int, elem reflect.Type) reflect.Type { 13 | return reflect.ArrayOf(count, elem) 14 | } 15 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/ugorji/go/codec/goversion_arrayof_lt_go15.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build !go1.5 5 | 6 | package codec 7 | 8 | import "reflect" 9 | 10 | const reflectArrayOfSupported = false 11 | 12 | func reflectArrayOf(count int, elem reflect.Type) reflect.Type { 13 | panic("codec: reflect.ArrayOf unsupported in this go version") 14 | } 15 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/ugorji/go/codec/goversion_fmt_time_gte_go15.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build go1.5 5 | 6 | package codec 7 | 8 | import "time" 9 | 10 | func fmtTime(t time.Time, b []byte) []byte { 11 | return t.AppendFormat(b, time.RFC3339Nano) 12 | } 13 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/ugorji/go/codec/goversion_fmt_time_lt_go15.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build !go1.5 5 | 6 | package codec 7 | 8 | import "time" 9 | 10 | func fmtTime(t time.Time, b []byte) []byte { 11 | s := t.Format(time.RFC3339Nano) 12 | b = b[:len(s)] 13 | copy(b, s) 14 | return b 15 | } 16 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/ugorji/go/codec/goversion_makemap_gte_go19.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build go1.9 5 | 6 | package codec 7 | 8 | import "reflect" 9 | 10 | func makeMapReflect(t reflect.Type, size int) reflect.Value { 11 | if size < 0 { 12 | return reflect.MakeMapWithSize(t, 4) 13 | } 14 | return reflect.MakeMapWithSize(t, size) 15 | } 16 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/ugorji/go/codec/goversion_makemap_lt_go19.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build !go1.9 5 | 6 | package codec 7 | 8 | import "reflect" 9 | 10 | func makeMapReflect(t reflect.Type, size int) reflect.Value { 11 | return reflect.MakeMap(t) 12 | } 13 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_gte_go110.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build go1.10 5 | 6 | package codec 7 | 8 | const allowSetUnexportedEmbeddedPtr = false 9 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_lt_go110.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build !go1.10 5 | 6 | package codec 7 | 8 | const allowSetUnexportedEmbeddedPtr = true 9 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/ugorji/go/codec/goversion_unsupported_lt_go14.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build !go1.4 5 | 6 | package codec 7 | 8 | // This codec package will only work for go1.4 and above. 9 | // This is for the following reasons: 10 | // - go 1.4 was released in 2014 11 | // - go runtime is written fully in go 12 | // - interface only holds pointers 13 | // - reflect.Value is stabilized as 3 words 14 | 15 | func init() { 16 | panic("codec: go 1.3 and below are not supported") 17 | } 18 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go15.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build go1.5,!go1.6 5 | 6 | package codec 7 | 8 | import "os" 9 | 10 | var genCheckVendor = os.Getenv("GO15VENDOREXPERIMENT") == "1" 11 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go16.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build go1.6,!go1.7 5 | 6 | package codec 7 | 8 | import "os" 9 | 10 | var genCheckVendor = os.Getenv("GO15VENDOREXPERIMENT") != "0" 11 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/ugorji/go/codec/goversion_vendor_gte_go17.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build go1.7 5 | 6 | package codec 7 | 8 | const genCheckVendor = true 9 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/ugorji/go/codec/goversion_vendor_lt_go15.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved. 2 | // Use of this source code is governed by a MIT license found in the LICENSE file. 3 | 4 | // +build !go1.5 5 | 6 | package codec 7 | 8 | var genCheckVendor = false 9 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/github.com/ugorji/go/codec/helper.s: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/goModulesExample/vendor/github.com/ugorji/go/codec/helper.s -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/crypto/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at https://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/crypto/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at https://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/crypto/sha3/keccakf_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 amd64,!appengine,!gccgo 6 | 7 | package sha3 8 | 9 | // This function is implemented in keccakf_amd64.s. 10 | 11 | //go:noescape 12 | 13 | func keccakF1600(a *[25]uint64) 14 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/crypto/sha3/register.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 sha3 8 | 9 | import ( 10 | "crypto" 11 | ) 12 | 13 | func init() { 14 | crypto.RegisterHash(crypto.SHA3_224, New224) 15 | crypto.RegisterHash(crypto.SHA3_256, New256) 16 | crypto.RegisterHash(crypto.SHA3_384, New384) 17 | crypto.RegisterHash(crypto.SHA3_512, New512) 18 | } 19 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/crypto/sha3/shake_generic.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo appengine !s390x 6 | 7 | package sha3 8 | 9 | // newShake128Asm returns an assembly implementation of SHAKE-128 if available, 10 | // otherwise it returns nil. 11 | func newShake128Asm() ShakeHash { 12 | return nil 13 | } 14 | 15 | // newShake256Asm returns an assembly implementation of SHAKE-256 if available, 16 | // otherwise it returns nil. 17 | func newShake256Asm() ShakeHash { 18 | return nil 19 | } 20 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/crypto/sha3/xor.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 !amd64,!386,!ppc64le appengine 6 | 7 | package sha3 8 | 9 | // A storageBuf is an aligned array of maxRate bytes. 10 | type storageBuf [maxRate]byte 11 | 12 | func (b *storageBuf) asBytes() *[maxRate]byte { 13 | return (*[maxRate]byte)(b) 14 | } 15 | 16 | var ( 17 | xorIn = xorInGeneric 18 | copyOut = copyOutGeneric 19 | xorInUnaligned = xorInGeneric 20 | copyOutUnaligned = copyOutGeneric 21 | ) 22 | 23 | const xorImplementationUnaligned = "generic" 24 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/cpu/asm_aix_ppc64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for ppc64, AIX are implemented in runtime/syscall_aix.go 11 | // 12 | 13 | TEXT ·syscall6(SB),NOSPLIT,$0-88 14 | JMP syscall·syscall6(SB) 15 | 16 | TEXT ·rawSyscall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSyscall6(SB) 18 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | package cpu 8 | 9 | func getisar0() uint64 10 | func getisar1() uint64 11 | func getpfr0() uint64 12 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/cpu/cpu_gc_x86.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386 amd64 amd64p32 6 | // +build !gccgo 7 | 8 | package cpu 9 | 10 | // cpuid is implemented in cpu_x86.s for gc compiler 11 | // and in cpu_gccgo.c for gccgo. 12 | func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32) 13 | 14 | // xgetbv with ecx = 0 is implemented in cpu_x86.s for gc compiler 15 | // and in cpu_gccgo.c for gccgo. 16 | func xgetbv() (eax, edx uint32) 17 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | package cpu 8 | 9 | func getisar0() uint64 { return 0 } 10 | func getisar1() uint64 { return 0 } 11 | func getpfr0() uint64 { return 0 } 12 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/cpu/cpu_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !386,!amd64,!amd64p32,!arm64 6 | 7 | package cpu 8 | 9 | func init() { 10 | if err := readHWCAP(); err != nil { 11 | return 12 | } 13 | doinit() 14 | Initialized = true 15 | } 16 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,!arm,!arm64,!ppc64,!ppc64le,!s390x 6 | 7 | package cpu 8 | 9 | func doinit() {} 10 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/cpu/cpu_mips64x.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build mips64 mips64le 6 | 7 | package cpu 8 | 9 | const cacheLineSize = 32 10 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/cpu/cpu_mipsx.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build mips mipsle 6 | 7 | package cpu 8 | 9 | const cacheLineSize = 32 10 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/cpu/cpu_other_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !linux,arm64 6 | 7 | package cpu 8 | 9 | func doinit() {} 10 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/cpu/cpu_riscv64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build riscv64 6 | 7 | package cpu 8 | 9 | const cacheLineSize = 32 10 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/cpu/cpu_wasm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build wasm 6 | 7 | package cpu 8 | 9 | // We're compiling the cpu package for an unknown (software-abstracted) CPU. 10 | // Make CacheLinePad an empty struct and hope that the usual struct alignment 11 | // rules are good enough. 12 | 13 | const cacheLineSize = 0 14 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/.gitignore: -------------------------------------------------------------------------------- 1 | _obj/ 2 | unix.test 3 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/aliases.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build go1.9 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | type Signal = syscall.Signal 13 | type Errno = syscall.Errno 14 | type SysProcAttr = syscall.SysProcAttr 15 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/asm_aix_ppc64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for ppc64, AIX are implemented in runtime/syscall_aix.go 11 | // 12 | 13 | TEXT ·syscall6(SB),NOSPLIT,$0-88 14 | JMP syscall·syscall6(SB) 15 | 16 | TEXT ·rawSyscall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSyscall6(SB) 18 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-88 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-88 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/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 aix 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 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/endian_big.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build ppc64 s390x mips mips64 6 | 7 | package unix 8 | 9 | const isBigEndian = true 10 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/endian_little.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le riscv64 6 | 7 | package unix 8 | 9 | const isBigEndian = false 10 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/fcntl_darwin.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import "unsafe" 8 | 9 | // FcntlInt performs a fcntl syscall on fd with the provided command and argument. 10 | func FcntlInt(fd uintptr, cmd, arg int) (int, error) { 11 | return fcntl(int(fd), cmd, arg) 12 | } 13 | 14 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 15 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 16 | _, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(lk)))) 17 | return err 18 | } 19 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/fcntl_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 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/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 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/pagesize_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // For Unix, get the pagesize from the runtime. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getpagesize() int { 14 | return syscall.Getpagesize() 15 | } 16 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/race0.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 aix darwin,!race linux,!race freebsd,!race netbsd openbsd solaris dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "unsafe" 11 | ) 12 | 13 | const raceenabled = false 14 | 15 | func raceAcquire(addr unsafe.Pointer) { 16 | } 17 | 18 | func raceReleaseMerge(addr unsafe.Pointer) { 19 | } 20 | 21 | func raceReadRange(addr unsafe.Pointer, len int) { 22 | } 23 | 24 | func raceWriteRange(addr unsafe.Pointer, len int) { 25 | } 26 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/readdirent_getdents.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build aix dragonfly freebsd linux netbsd openbsd 6 | 7 | package unix 8 | 9 | // ReadDirent reads directory entries from fd and writes them into buf. 10 | func ReadDirent(fd int, buf []byte) (n int, err error) { 11 | return Getdents(fd, buf) 12 | } 13 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/sockcmsg_dragonfly.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | // Round the length of a raw sockaddr up to align it properly. 8 | func cmsgAlignOf(salen int) int { 9 | salign := SizeofPtr 10 | if SizeofPtr == 8 && !supportsABI(_dragonflyABIChangeVersion) { 11 | // 64-bit Dragonfly before the September 2019 ABI changes still requires 12 | // 32-bit aligned access to network subsystem. 13 | salign = 4 14 | } 15 | return (salen + salign - 1) & ^(salign - 1) 16 | } 17 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/syscall_darwin_386.1_11.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,386,!go1.12 6 | 7 | package unix 8 | 9 | //sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64 10 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/syscall_darwin_amd64.1_11.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,amd64,!go1.12 6 | 7 | package unix 8 | 9 | //sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64 10 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/syscall_darwin_arm.1_11.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,arm,!go1.12 6 | 7 | package unix 8 | 9 | func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { 10 | return 0, ENOSYS 11 | } 12 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/syscall_darwin_arm64.1_11.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin,arm64,!go1.12 6 | 7 | package unix 8 | 9 | func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { 10 | return 0, ENOSYS 11 | } 12 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/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 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/syscall_linux_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,!gccgo 6 | 7 | package unix 8 | 9 | // SyscallNoError may be used instead of Syscall for syscalls that don't fail. 10 | func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 11 | 12 | // RawSyscallNoError may be used instead of RawSyscall for syscalls that don't 13 | // fail. 14 | func RawSyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) 15 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux,!gccgo,386 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // Underlying system call writes to newoffset via pointer. 12 | // Implemented in assembly to avoid allocation. 13 | func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) 14 | 15 | func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 16 | func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno) 17 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.1_13.s: -------------------------------------------------------------------------------- 1 | // go run mkasm_darwin.go 386 2 | // Code generated by the command above; DO NOT EDIT. 3 | 4 | // +build go1.13 5 | 6 | #include "textflag.h" 7 | TEXT ·libc_fdopendir_trampoline(SB),NOSPLIT,$0-0 8 | JMP libc_fdopendir(SB) 9 | TEXT ·libc_closedir_trampoline(SB),NOSPLIT,$0-0 10 | JMP libc_closedir(SB) 11 | TEXT ·libc_readdir_r_trampoline(SB),NOSPLIT,$0-0 12 | JMP libc_readdir_r(SB) 13 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.1_13.s: -------------------------------------------------------------------------------- 1 | // go run mkasm_darwin.go amd64 2 | // Code generated by the command above; DO NOT EDIT. 3 | 4 | // +build go1.13 5 | 6 | #include "textflag.h" 7 | TEXT ·libc_fdopendir_trampoline(SB),NOSPLIT,$0-0 8 | JMP libc_fdopendir(SB) 9 | TEXT ·libc_closedir_trampoline(SB),NOSPLIT,$0-0 10 | JMP libc_closedir(SB) 11 | TEXT ·libc_readdir_r_trampoline(SB),NOSPLIT,$0-0 12 | JMP libc_readdir_r(SB) 13 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.1_13.s: -------------------------------------------------------------------------------- 1 | // go run mkasm_darwin.go arm 2 | // Code generated by the command above; DO NOT EDIT. 3 | 4 | // +build go1.13 5 | 6 | #include "textflag.h" 7 | TEXT ·libc_fdopendir_trampoline(SB),NOSPLIT,$0-0 8 | JMP libc_fdopendir(SB) 9 | TEXT ·libc_closedir_trampoline(SB),NOSPLIT,$0-0 10 | JMP libc_closedir(SB) 11 | TEXT ·libc_readdir_r_trampoline(SB),NOSPLIT,$0-0 12 | JMP libc_readdir_r(SB) 13 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.1_13.s: -------------------------------------------------------------------------------- 1 | // go run mkasm_darwin.go arm64 2 | // Code generated by the command above; DO NOT EDIT. 3 | 4 | // +build go1.13 5 | 6 | #include "textflag.h" 7 | TEXT ·libc_fdopendir_trampoline(SB),NOSPLIT,$0-0 8 | JMP libc_fdopendir(SB) 9 | TEXT ·libc_closedir_trampoline(SB),NOSPLIT,$0-0 10 | JMP libc_closedir(SB) 11 | TEXT ·libc_readdir_r_trampoline(SB),NOSPLIT,$0-0 12 | JMP libc_readdir_r(SB) 13 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/gopkg.in/yaml.v2/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - "1.4.x" 5 | - "1.5.x" 6 | - "1.6.x" 7 | - "1.7.x" 8 | - "1.8.x" 9 | - "1.9.x" 10 | - "1.10.x" 11 | - "1.11.x" 12 | - "1.12.x" 13 | - "1.13.x" 14 | - "tip" 15 | 16 | go_import_path: gopkg.in/yaml.v2 17 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/goModulesExample/vendor/gopkg.in/yaml.v2/NOTICE: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/gofmtSimplify.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | 7 | var tmp = []int{1, 2, 3} 8 | b := tmp[1:len(tmp)] 9 | fmt.Println(b) 10 | for i, _ := range tmp { 11 | fmt.Println(tmp[i]) 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/internalDirectory/cmd/main.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/internalDirectory/cmd/main.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/internalDirectory/internal/structures/types.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/internalDirectory/internal/structures/types.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/internalDirectory/internal/structures/types_test.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/internalDirectory/internal/structures/types_test.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/internalDirectory/pkg/api/api.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/internalDirectory/pkg/api/api.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/internalDirectory/pkg/api/api_test.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/internalDirectory/pkg/api/api_test.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/patternDirectory/notifications/email.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/patternDirectory/notifications/email.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/patternDirectory/notifications/email_test.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/patternDirectory/notifications/email_test.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/patternDirectory/notifications/pagerduty.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/patternDirectory/notifications/pagerduty.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/patternDirectory/notifications/pagerduty_test.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/patternDirectory/notifications/pagerduty_test.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/patternDirectory/notifications/pushnotify.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/patternDirectory/notifications/pushnotify.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/patternDirectory/notifications/pushnotify_test.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/patternDirectory/notifications/pushnotify_test.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/patternDirectory/notifications/slack.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/patternDirectory/notifications/slack.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/patternDirectory/notifications/slack_test.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/patternDirectory/notifications/slack_test.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/patternDirectory/notifications/trello.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/patternDirectory/notifications/trello.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/patternDirectory/notifications/trello_test.go: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/6-composing-readable-go-code/patternDirectory/notifications/trello_test.go -------------------------------------------------------------------------------- /6-composing-readable-go-code/reflectionKinds.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | ) 7 | 8 | func main() { 9 | i := []string{"foo", "bar", "baz"} 10 | ti := reflect.TypeOf(i) 11 | fmt.Println(ti.Kind()) 12 | } 13 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/reflectionTypes.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | ) 7 | 8 | func main() { 9 | var foo string = "Hi Go!" 10 | fooType := reflect.TypeOf(foo) 11 | fmt.Println("Foo type: ", fooType) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/reflectionValues.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | ) 7 | 8 | func main() { 9 | 10 | example := "foo" 11 | exampleVal := reflect.ValueOf(example) 12 | fmt.Println(exampleVal) 13 | 14 | } 15 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/tmp.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | ) 7 | 8 | func main() { 9 | 10 | var x int = 1 11 | v := reflect.ValueOf(x) 12 | fmt.Println(v.Type()) 13 | fmt.Println(reflect.ValueOf(v)) 14 | } 15 | -------------------------------------------------------------------------------- /6-composing-readable-go-code/userMethod.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type User struct { 6 | uid int 7 | name string 8 | email string 9 | phone string 10 | } 11 | 12 | func (u User) displayEmail() { 13 | fmt.Printf("User %d Email: %s\n", u.uid, u.email) 14 | } 15 | 16 | func main() { 17 | 18 | userExample := User{ 19 | uid: 1, 20 | name: "bob", 21 | email: "bob@example.com", 22 | phone: "123-456-7890", 23 | } 24 | 25 | userExample.displayEmail() 26 | } 27 | -------------------------------------------------------------------------------- /7-template-programming-in-go/clitooling/cmd/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/bobstrecansky/HighPerformanceWithGo/7-metaprogramming-in-go/clitooling/cmd 2 | -------------------------------------------------------------------------------- /7-template-programming-in-go/clitooling/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/bobstrecansky/HighPerformanceWithGo/7-metaprogramming-in-go/clitooling 2 | 3 | require ( 4 | github.com/HighPerformanceWithGo/7-metaprogramming-in-go/clitooling/cmd v0.0.0 5 | github.com/bobstrecansky/HighPerformanceWithGo/7-metaprogramming-in-go/clitooling/cmd v0.0.0-20190710015651-4228b09dc063 // indirect 6 | github.com/spf13/cobra v0.0.5 7 | github.com/spf13/viper v1.3.2 8 | ) 9 | 10 | replace github.com/HighPerformanceWithGo/7-metaprogramming-in-go/clitooling/cmd v0.0.0 => ./cmd 11 | -------------------------------------------------------------------------------- /7-template-programming-in-go/clitooling/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/HighPerformanceWithGo/7-metaprogramming-in-go/clitooling/cmd" 8 | ) 9 | 10 | func main() { 11 | 12 | if err := cmd.DateCommand.Execute(); err != nil { 13 | fmt.Println(err) 14 | os.Exit(1) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /7-template-programming-in-go/grpcExample/go.mod: -------------------------------------------------------------------------------- 1 | module HighPerformanceWithGo/7-metaprogramming-in-go/grpc 2 | 3 | require ( 4 | github.com/HighPerformanceWithGo/7-metaprogramming-in-go/grpcExample/userinfo/userinfo v0.0.0 5 | github.com/golang/protobuf v1.3.2 6 | google.golang.org/grpc v1.22.0 7 | ) 8 | 9 | replace github.com/HighPerformanceWithGo/7-metaprogramming-in-go/grpcExample/userinfo/userinfo => ./userinfo 10 | -------------------------------------------------------------------------------- /7-template-programming-in-go/grpcExample/userinfo/README.md: -------------------------------------------------------------------------------- 1 | Generate userinfo.pb.go with: 2 | protoc -I ../userinfo --go_out=plugins=grpc:../userinfo ../userinfo/userinfo.proto 3 | -------------------------------------------------------------------------------- /7-template-programming-in-go/grpcExample/userinfo/go.mod: -------------------------------------------------------------------------------- 1 | module HighPerformanceWithGo/7-metaprogramming-in-go/grpc/userinfo 2 | 3 | require ( 4 | github.com/golang/protobuf v1.3.2 5 | google.golang.org/grpc v1.22.0 6 | ) 7 | -------------------------------------------------------------------------------- /7-template-programming-in-go/grpcExample/userinfo/userinfo.go: -------------------------------------------------------------------------------- 1 | package userinfo 2 | //go:generate protoc -I ../userinfo --go_out=plugins=grpc:../userinfo ../userinfo/userinfo.proto 3 | -------------------------------------------------------------------------------- /7-template-programming-in-go/grpcExample/userinfo/userinfo.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package userinfo; 3 | 4 | service UserInfo { 5 | rpc PrintUserInfo (UserInfoRequest) returns (UserInfoResponse) {} 6 | } 7 | 8 | message UserInfoRequest { 9 | string user = 1; 10 | string email = 2; 11 | } 12 | 13 | message UserInfoResponse { 14 | string response = 1; 15 | } 16 | -------------------------------------------------------------------------------- /7-template-programming-in-go/serialNumber.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | var SerialNumber = "unlicensed" 8 | 9 | func main() { 10 | if SerialNumber == "ABC123" { 11 | fmt.Println("Valid Serial Number!") 12 | } else { 13 | fmt.Println("Invalid Serial Number") 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /7-template-programming-in-go/templates/html/tmp.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | First Program 4 | 5 | 6 | {{ . }} 7 | 8 | 9 | -------------------------------------------------------------------------------- /7-template-programming-in-go/templates/sprig/go.mod: -------------------------------------------------------------------------------- 1 | module HighPerformanceWithGo/7-metaprogramming-in-go/templates/sprig 2 | 3 | require ( 4 | github.com/Masterminds/goutils v1.1.0 // indirect 5 | github.com/Masterminds/semver v1.4.2 // indirect 6 | github.com/Masterminds/sprig v2.20.0+incompatible 7 | github.com/google/uuid v1.1.1 // indirect 8 | github.com/huandu/xstrings v1.2.0 // indirect 9 | github.com/imdario/mergo v0.3.7 // indirect 10 | golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect 11 | ) 12 | -------------------------------------------------------------------------------- /7-template-programming-in-go/templates/sprig/jsonPrettyPrint.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "text/template" 7 | 8 | "github.com/Masterminds/sprig" 9 | ) 10 | 11 | func main() { 12 | jsonDict := map[string]interface{}{"JSONExamples": map[string]interface{}{"foo": "bar", "bool": false, "integer": 7}} 13 | tpl := `{{.JSONExamples | toPrettyJson}}` 14 | functionMap := sprig.TxtFuncMap() 15 | t := template.Must(template.New("String Split").Funcs(functionMap).Parse(tpl)) 16 | err := t.Execute(os.Stdout, jsonDict) 17 | if err != nil { 18 | fmt.Printf("Couldn't create template: %s", err) 19 | return 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /7-template-programming-in-go/templates/sprig/strings.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "text/template" 7 | 8 | "github.com/Masterminds/sprig" 9 | ) 10 | 11 | func main() { 12 | inStr := map[string]interface{}{"Name": " - bob smith"} 13 | transform := `{{.Name | trim | replace "smith" "strecansky" | trimPrefix "-" | title | repeat 10 | wrapWith 14 "\n"}}` 14 | 15 | functionMap := sprig.TxtFuncMap() 16 | t := template.Must(template.New("Name Transformation").Funcs(functionMap).Parse(transform)) 17 | 18 | err := t.Execute(os.Stdout, inStr) 19 | if err != nil { 20 | fmt.Printf("Couldn't create template: %s", err) 21 | return 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /8-memory-management/8-memory-management: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/8-memory-management/8-memory-management -------------------------------------------------------------------------------- /8-memory-management/elf.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "debug/elf" 5 | "log" 6 | ) 7 | 8 | func main() { 9 | f, err := elf.Open("server") 10 | 11 | if err != nil { 12 | log.Fatal(err) 13 | } 14 | 15 | for _, section := range f.Sections { 16 | log.Println(section) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /8-memory-management/elfReader.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "debug/elf" 5 | "fmt" 6 | "log" 7 | "os" 8 | ) 9 | 10 | func main() { 11 | if len(os.Args) != 2 { 12 | fmt.Println("Usage: ./elfReader elf_file") 13 | os.Exit(1) 14 | } 15 | elfFile, err := elf.Open(os.Args[1]) 16 | 17 | if err != nil { 18 | log.Fatal(err) 19 | } 20 | 21 | for _, section := range elfFile.Sections { 22 | fmt.Println(section) 23 | } 24 | 25 | fmt.Println("Machine Type:\t", elfFile.FileHeader.Machine) 26 | fmt.Println("Starting Memory Address:\t", elfFile.FileHeader.Entry) 27 | } 28 | -------------------------------------------------------------------------------- /8-memory-management/escapeAnalysis/out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/8-memory-management/escapeAnalysis/out -------------------------------------------------------------------------------- /8-memory-management/escapeAnalysis/simpleEscapeAnalysis: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/8-memory-management/escapeAnalysis/simpleEscapeAnalysis -------------------------------------------------------------------------------- /8-memory-management/escapeAnalysis/simpleEscapeAnalysis.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | greetingString := "Hello Gophers!" 7 | fmt.Println(greetingString) 8 | } 9 | -------------------------------------------------------------------------------- /8-memory-management/server: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/8-memory-management/server -------------------------------------------------------------------------------- /8-memory-management/server.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "io" 5 | "net/http" 6 | ) 7 | 8 | func main() { 9 | Handler := func(w http.ResponseWriter, req *http.Request) { 10 | io.WriteString(w, "Memory Management Test") 11 | } 12 | 13 | http.HandleFunc("/", Handler) 14 | http.ListenAndServe(":1234", nil) 15 | } 16 | -------------------------------------------------------------------------------- /8-memory-management/simpleProgramMemoryStats/simpleProgramMemoryStats: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/8-memory-management/simpleProgramMemoryStats/simpleProgramMemoryStats -------------------------------------------------------------------------------- /8-memory-management/simpleServer/simpleServer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/8-memory-management/simpleServer/simpleServer -------------------------------------------------------------------------------- /8-memory-management/simpleServer/simpleServer.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "io" 5 | "net/http" 6 | ) 7 | 8 | func main() { 9 | Handler := func(w http.ResponseWriter, req *http.Request) { 10 | io.WriteString(w, "Memory Management Test") 11 | } 12 | http.HandleFunc("/", Handler) 13 | http.ListenAndServe(":1234", nil) 14 | } 15 | -------------------------------------------------------------------------------- /8-memory-management/simpleServerGCStats/simpleServerGCStats: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/8-memory-management/simpleServerGCStats/simpleServerGCStats -------------------------------------------------------------------------------- /8-memory-management/simpleServerMemoryStats/simpleServerMemoryStats: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobstrecansky/HighPerformanceWithGo/6c53e501e4bc32f58b7fac2e534113e2b50f1a10/8-memory-management/simpleServerMemoryStats/simpleServerMemoryStats -------------------------------------------------------------------------------- /9-gpu-parallelization-in-go/cgo/benchmarkCgo.go: -------------------------------------------------------------------------------- 1 | package benchmark 2 | 3 | /* 4 | #include 5 | 6 | const char* hello_gophers() { 7 | return "Hello Gophers!"; 8 | } 9 | */ 10 | import "C" 11 | import "fmt" 12 | 13 | func CgoPrint(n int) { 14 | for i := 0; i < n; i++ { 15 | fmt.Sprintf(C.GoString(C.hello_gophers())) 16 | } 17 | } 18 | 19 | func GoPrint(n int) { 20 | for i := 0; i < n; i++ { 21 | fmt.Sprintf("Hello Gophers!") 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /9-gpu-parallelization-in-go/cgo/benchmarkCgo_test.go: -------------------------------------------------------------------------------- 1 | package benchmark 2 | 3 | import "testing" 4 | 5 | func BenchmarkCPrint(b *testing.B) { 6 | CgoPrint(b.N) 7 | } 8 | 9 | func BenchmarkGoPrint(b *testing.B) { 10 | GoPrint(b.N) 11 | } 12 | -------------------------------------------------------------------------------- /9-gpu-parallelization-in-go/cgo/cgo.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | /* 4 | #include 5 | 6 | const char* hello_gophers() { 7 | return "Hello Gophers!"; 8 | } 9 | */ 10 | import "C" 11 | import "fmt" 12 | 13 | func main() { 14 | fmt.Println(C.GoString(C.hello_gophers())) 15 | } 16 | -------------------------------------------------------------------------------- /9-gpu-parallelization-in-go/cuda/Makefile: -------------------------------------------------------------------------------- 1 | export LD_LIBRARY_PATH := /usr/local/cuda-10.2/lib64 2 | export PATH := /usr/local/cuda-10.2/bin:/usr/local/cuda-10.2/NsightCompute-2019.1:$(PATH) 3 | 4 | target: 5 | nvcc -o cuda_add.so --shared -Xcompiler -fPIC cuda_add.cu 6 | go: 7 | go run cuda_add.go 8 | clean: 9 | rm cuda_add.so 10 | -------------------------------------------------------------------------------- /9-gpu-parallelization-in-go/cuda/cuda_add.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | //#cgo CFLAGS: -I. 6 | //#cgo LDFLAGS: -L. -ltest 7 | //#cgo LDFLAGS: -lcudart 8 | //#include 9 | import "C" 10 | 11 | func main() { 12 | fmt.Printf("Invoking cuda library...\n") 13 | fmt.Println("Done ", C.test_add()) 14 | } 15 | -------------------------------------------------------------------------------- /9-gpu-parallelization-in-go/cuda/cuda_add.h: -------------------------------------------------------------------------------- 1 | int test_add(void); 2 | -------------------------------------------------------------------------------- /9-gpu-parallelization-in-go/docker_cuda/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM tensorflow/tensorflow:latest-gpu 2 | ENV LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64 3 | RUN ln -s /usr/local/cuda-10.1/lib64/libcudart.so /usr/lib/libcudart.so 4 | RUN apt-get install -y golang 5 | COPY . /tmp 6 | WORKDIR /tmp 7 | RUN make 8 | RUN mv libmultiply.so /usr/lib/libmultiply.so 9 | ENTRYPOINT ["/usr/bin/go", "run", "cuda_multiply.go"] 10 | -------------------------------------------------------------------------------- /9-gpu-parallelization-in-go/docker_cuda/Makefile: -------------------------------------------------------------------------------- 1 | # Use these if you'd like to run this on your bare metal OS. 2 | # LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64 3 | # PATH=/usr/local/cuda-10.2/bin 4 | 5 | target: 6 | nvcc -o libmultiply.so --shared -Xcompiler -fPIC cuda_multiply.cu 7 | go: 8 | go run cuda_multiply.go 9 | clean: 10 | rm *.so 11 | -------------------------------------------------------------------------------- /9-gpu-parallelization-in-go/docker_cuda/cuda_multiply.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | //#cgo CFLAGS: -I. 9 | //#cgo LDFLAGS: -L. -lmultiply 10 | //#cgo LDFLAGS: -lcudart 11 | //#include 12 | import "C" 13 | 14 | func main() { 15 | fmt.Printf("Invoking cuda library...\n") 16 | start := time.Now() 17 | C.cuda_multiply() 18 | elapsed := time.Since(start) 19 | fmt.Println("\nCuda Execution took", elapsed) 20 | } 21 | -------------------------------------------------------------------------------- /9-gpu-parallelization-in-go/docker_cuda/cuda_multiply.h: -------------------------------------------------------------------------------- 1 | int cuda_multiply(void); 2 | -------------------------------------------------------------------------------- /frequency_scaling_governor_diable.bash: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | for i in /sys/devices/system/cpu/cpu[0-9]* 3 | do 4 | echo "Disabling Frequency Scaling for CPU $i" 5 | echo performance > $i/cpufreq/scaling_governor 6 | done 7 | --------------------------------------------------------------------------------