├── .gitignore ├── .travis.yml ├── LICENSE ├── Makefile ├── README.md ├── hello_world.go ├── hour01 └── example01.go ├── hour02 ├── example01.go ├── example02.js ├── example03.js ├── example04.go ├── example05.go ├── example06.go ├── example07.go └── example08.go ├── hour03 ├── README.md ├── example01.go ├── example02.go ├── example03.go ├── example04.go ├── example05.go ├── example06.go ├── example07.go ├── example08.go ├── example09.go ├── example10.go ├── example11.go ├── example12.go ├── example13.go ├── example14.go └── example15.go ├── hour04 ├── example01.go ├── example02.go ├── example03.go ├── example04.go ├── example05.go ├── example06.go └── example07.go ├── hour05 ├── example01.go ├── example02.go ├── example03.go ├── example04.go ├── example05.go ├── example06.go ├── example07.go ├── example08.go ├── example09.go ├── example10.go └── example11.go ├── hour06 ├── example01.go ├── example02.go ├── example03.go ├── example04.go ├── example05.go ├── example06.go ├── example07.go └── example08.go ├── hour07 ├── example01.go ├── example02.go ├── example03.go ├── example04.go ├── example05.go ├── example06.go ├── example07.go ├── example08.go ├── example09.go ├── example10.go └── example11.go ├── hour08 ├── example01.go ├── example02.go ├── example03.go ├── example04.go ├── example05.go └── example06.go ├── hour09 ├── README.md ├── example01.go ├── example02.go ├── example03.go ├── example04.go ├── example05.go ├── example06.go ├── example07.go ├── example08.go ├── example09.go ├── example10.go └── example11.go ├── hour10 ├── README.md ├── example01.go ├── example02.go ├── example03.go ├── example04.go └── example05.go ├── hour11 ├── example01.go ├── example02.go ├── example03.go ├── example04.go └── example05.go ├── hour12 ├── example01.go ├── example02.go ├── example03.go ├── example04.go ├── example05.go ├── example06.go ├── example07.go ├── example08.go ├── example09.go └── example10.go ├── hour13 ├── example01.go └── example02 │ ├── example02.go │ └── vendor │ └── github.com │ └── golang │ └── example │ └── stringutil │ ├── reverse.go │ └── reverse_test.go ├── hour14 ├── example01.go ├── example02.go ├── example03 │ └── example03.go └── example04 │ ├── Makefile │ └── example04.go ├── hour15 ├── example01 │ ├── example01.go │ └── example01_test.go ├── example02 │ ├── example02.go │ └── example02_test.go ├── example03 │ ├── example03.go │ └── example03_test.go ├── example04 │ ├── example04.go │ └── example04_test.go ├── example05 │ ├── example05.go │ └── example05_test.go └── example06 │ ├── example06.go │ └── example06_test.go ├── hour16 ├── example01.go ├── example02.go ├── example03.go ├── example04.go ├── example05.go ├── example06.go ├── example07.go ├── example08.go ├── example09.go └── example10.go ├── hour17 ├── README.md ├── example01.go ├── example02.go ├── example03.go ├── example04.go ├── example05.go ├── example06.go └── example07.go ├── hour18 ├── README.md ├── example01.go ├── example02.go ├── example03.go ├── example04.go ├── example05.go └── example06.go ├── hour19 ├── README.md ├── example01.go ├── example02.go ├── example03.go ├── example04.go ├── example05.go └── example06.go ├── hour20 ├── example01.go ├── example02.go ├── example03.go ├── example04.go ├── example05.go ├── example06.go └── example07.go ├── hour21 ├── .gitignore ├── example01 │ ├── example01.go │ └── example01.txt ├── example02.go ├── example03.go ├── example04.go ├── example05 │ ├── example05.go │ └── example05.txt ├── example06 │ ├── deleteme.txt │ └── example06.go ├── example07 │ ├── config.json │ └── example07.go └── example08 │ ├── config.toml │ └── example08.go ├── hour22 ├── example01.go ├── example02.go ├── example03.go ├── example04.go ├── example05.go └── example06.go ├── hour23 ├── example01.go ├── example02.go ├── example03.go ├── example04.go ├── example05.go ├── example06.go └── example07.go ├── hour24 ├── .gitignore ├── example01.go ├── example02 │ ├── Dockerfile │ └── example02.go ├── example03.go └── example04.go ├── hour25 ├── example01 │ ├── Gopkg.lock │ └── Gopkg.toml ├── example02 │ ├── Gopkg.lock │ ├── Gopkg.toml │ └── main.go ├── example03 │ ├── Gopkg.lock │ ├── Gopkg.toml │ ├── main.go │ └── vendor │ │ └── github.com │ │ └── julienschmidt │ │ └── httprouter │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── path.go │ │ ├── path_test.go │ │ ├── router.go │ │ ├── router_test.go │ │ ├── tree.go │ │ └── tree_test.go ├── example04 │ ├── Gopkg.lock │ ├── Gopkg.toml │ ├── main.go │ ├── main_test.go │ └── vendor │ │ └── github.com │ │ └── julienschmidt │ │ └── httprouter │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── path.go │ │ ├── path_test.go │ │ ├── router.go │ │ ├── router_test.go │ │ ├── tree.go │ │ └── tree_test.go ├── example05 │ ├── Gopkg.lock │ ├── Gopkg.toml │ ├── main.go │ ├── main_test.go │ └── vendor │ │ └── github.com │ │ └── julienschmidt │ │ └── httprouter │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── path.go │ │ ├── path_test.go │ │ ├── router.go │ │ ├── router_test.go │ │ ├── tree.go │ │ └── tree_test.go ├── example06 │ ├── Gopkg.lock │ ├── Gopkg.toml │ ├── main.go │ ├── main_test.go │ ├── store.go │ ├── task.go │ ├── tasks.db │ └── vendor │ │ ├── github.com │ │ ├── boltdb │ │ │ └── bolt │ │ │ │ ├── .gitignore │ │ │ │ ├── LICENSE │ │ │ │ ├── Makefile │ │ │ │ ├── README.md │ │ │ │ ├── appveyor.yml │ │ │ │ ├── bolt_386.go │ │ │ │ ├── bolt_amd64.go │ │ │ │ ├── bolt_arm.go │ │ │ │ ├── bolt_arm64.go │ │ │ │ ├── bolt_linux.go │ │ │ │ ├── bolt_openbsd.go │ │ │ │ ├── bolt_ppc.go │ │ │ │ ├── bolt_ppc64.go │ │ │ │ ├── bolt_ppc64le.go │ │ │ │ ├── bolt_s390x.go │ │ │ │ ├── bolt_unix.go │ │ │ │ ├── bolt_unix_solaris.go │ │ │ │ ├── bolt_windows.go │ │ │ │ ├── boltsync_unix.go │ │ │ │ ├── bucket.go │ │ │ │ ├── bucket_test.go │ │ │ │ ├── cmd │ │ │ │ └── bolt │ │ │ │ │ ├── main.go │ │ │ │ │ └── main_test.go │ │ │ │ ├── cursor.go │ │ │ │ ├── cursor_test.go │ │ │ │ ├── db.go │ │ │ │ ├── db_test.go │ │ │ │ ├── doc.go │ │ │ │ ├── errors.go │ │ │ │ ├── freelist.go │ │ │ │ ├── freelist_test.go │ │ │ │ ├── node.go │ │ │ │ ├── node_test.go │ │ │ │ ├── page.go │ │ │ │ ├── page_test.go │ │ │ │ ├── quick_test.go │ │ │ │ ├── simulation_test.go │ │ │ │ ├── tx.go │ │ │ │ └── tx_test.go │ │ └── julienschmidt │ │ │ └── httprouter │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── path.go │ │ │ ├── path_test.go │ │ │ ├── router.go │ │ │ ├── router_test.go │ │ │ ├── tree.go │ │ │ └── tree_test.go │ │ └── golang.org │ │ └── x │ │ └── sys │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── AUTHORS │ │ ├── CONTRIBUTING.md │ │ ├── CONTRIBUTORS │ │ ├── LICENSE │ │ ├── PATENTS │ │ ├── README.md │ │ ├── codereview.cfg │ │ ├── plan9 │ │ ├── asm.s │ │ ├── asm_plan9_386.s │ │ ├── asm_plan9_amd64.s │ │ ├── const_plan9.go │ │ ├── dir_plan9.go │ │ ├── env_plan9.go │ │ ├── env_unset.go │ │ ├── errors_plan9.go │ │ ├── mkall.sh │ │ ├── mkerrors.sh │ │ ├── mksyscall.pl │ │ ├── mksysnum_plan9.sh │ │ ├── pwd_go15_plan9.go │ │ ├── pwd_plan9.go │ │ ├── race.go │ │ ├── race0.go │ │ ├── str.go │ │ ├── syscall.go │ │ ├── syscall_plan9.go │ │ ├── syscall_test.go │ │ ├── zsyscall_plan9_386.go │ │ ├── zsyscall_plan9_amd64.go │ │ └── zsysnum_plan9.go │ │ ├── unix │ │ ├── .gitignore │ │ ├── README.md │ │ ├── asm_darwin_386.s │ │ ├── asm_darwin_amd64.s │ │ ├── asm_darwin_arm.s │ │ ├── asm_darwin_arm64.s │ │ ├── asm_dragonfly_amd64.s │ │ ├── asm_freebsd_386.s │ │ ├── asm_freebsd_amd64.s │ │ ├── asm_freebsd_arm.s │ │ ├── asm_linux_386.s │ │ ├── asm_linux_amd64.s │ │ ├── asm_linux_arm.s │ │ ├── asm_linux_arm64.s │ │ ├── asm_linux_mips64x.s │ │ ├── asm_linux_mipsx.s │ │ ├── asm_linux_ppc64x.s │ │ ├── asm_linux_s390x.s │ │ ├── asm_netbsd_386.s │ │ ├── asm_netbsd_amd64.s │ │ ├── asm_netbsd_arm.s │ │ ├── asm_openbsd_386.s │ │ ├── asm_openbsd_amd64.s │ │ ├── asm_openbsd_arm.s │ │ ├── asm_solaris_amd64.s │ │ ├── bluetooth_linux.go │ │ ├── cap_freebsd.go │ │ ├── constants.go │ │ ├── creds_test.go │ │ ├── dev_darwin.go │ │ ├── dev_darwin_test.go │ │ ├── dev_dragonfly.go │ │ ├── dev_dragonfly_test.go │ │ ├── dev_freebsd.go │ │ ├── dev_linux.go │ │ ├── dev_linux_test.go │ │ ├── dev_netbsd.go │ │ ├── dev_netbsd_test.go │ │ ├── dev_openbsd.go │ │ ├── dev_openbsd_test.go │ │ ├── dev_solaris_test.go │ │ ├── dirent.go │ │ ├── endian_big.go │ │ ├── endian_little.go │ │ ├── env_unix.go │ │ ├── env_unset.go │ │ ├── errors_freebsd_386.go │ │ ├── errors_freebsd_amd64.go │ │ ├── errors_freebsd_arm.go │ │ ├── export_test.go │ │ ├── flock.go │ │ ├── flock_linux_32bit.go │ │ ├── gccgo.go │ │ ├── gccgo_c.c │ │ ├── gccgo_linux_amd64.go │ │ ├── linux │ │ │ ├── Dockerfile │ │ │ ├── mkall.go │ │ │ ├── mksysnum.pl │ │ │ └── types.go │ │ ├── mkall.sh │ │ ├── mkerrors.sh │ │ ├── mkpost.go │ │ ├── mksyscall.pl │ │ ├── mksyscall_solaris.pl │ │ ├── mksysctl_openbsd.pl │ │ ├── mksysnum_darwin.pl │ │ ├── mksysnum_dragonfly.pl │ │ ├── mksysnum_freebsd.pl │ │ ├── mksysnum_netbsd.pl │ │ ├── mksysnum_openbsd.pl │ │ ├── mmap_unix_test.go │ │ ├── openbsd_pledge.go │ │ ├── openbsd_test.go │ │ ├── pagesize_unix.go │ │ ├── race.go │ │ ├── race0.go │ │ ├── sockcmsg_linux.go │ │ ├── sockcmsg_unix.go │ │ ├── str.go │ │ ├── syscall.go │ │ ├── syscall_bsd.go │ │ ├── syscall_bsd_test.go │ │ ├── syscall_darwin.go │ │ ├── syscall_darwin_386.go │ │ ├── syscall_darwin_amd64.go │ │ ├── syscall_darwin_arm.go │ │ ├── syscall_darwin_arm64.go │ │ ├── syscall_dragonfly.go │ │ ├── syscall_dragonfly_amd64.go │ │ ├── syscall_freebsd.go │ │ ├── syscall_freebsd_386.go │ │ ├── syscall_freebsd_amd64.go │ │ ├── syscall_freebsd_arm.go │ │ ├── syscall_freebsd_test.go │ │ ├── syscall_linux.go │ │ ├── syscall_linux_386.go │ │ ├── syscall_linux_amd64.go │ │ ├── syscall_linux_amd64_gc.go │ │ ├── syscall_linux_arm.go │ │ ├── syscall_linux_arm64.go │ │ ├── syscall_linux_mips64x.go │ │ ├── syscall_linux_mipsx.go │ │ ├── syscall_linux_ppc64x.go │ │ ├── syscall_linux_s390x.go │ │ ├── syscall_linux_sparc64.go │ │ ├── syscall_linux_test.go │ │ ├── syscall_netbsd.go │ │ ├── syscall_netbsd_386.go │ │ ├── syscall_netbsd_amd64.go │ │ ├── syscall_netbsd_arm.go │ │ ├── syscall_no_getwd.go │ │ ├── syscall_openbsd.go │ │ ├── syscall_openbsd_386.go │ │ ├── syscall_openbsd_amd64.go │ │ ├── syscall_openbsd_arm.go │ │ ├── syscall_solaris.go │ │ ├── syscall_solaris_amd64.go │ │ ├── syscall_solaris_test.go │ │ ├── syscall_test.go │ │ ├── syscall_unix.go │ │ ├── syscall_unix_gc.go │ │ ├── syscall_unix_test.go │ │ ├── timestruct.go │ │ ├── types_darwin.go │ │ ├── types_dragonfly.go │ │ ├── types_freebsd.go │ │ ├── types_netbsd.go │ │ ├── types_openbsd.go │ │ ├── types_solaris.go │ │ ├── zerrors_darwin_386.go │ │ ├── zerrors_darwin_amd64.go │ │ ├── zerrors_darwin_arm.go │ │ ├── zerrors_darwin_arm64.go │ │ ├── zerrors_dragonfly_amd64.go │ │ ├── zerrors_freebsd_386.go │ │ ├── zerrors_freebsd_amd64.go │ │ ├── zerrors_freebsd_arm.go │ │ ├── zerrors_linux_386.go │ │ ├── zerrors_linux_amd64.go │ │ ├── zerrors_linux_arm.go │ │ ├── zerrors_linux_arm64.go │ │ ├── zerrors_linux_mips.go │ │ ├── zerrors_linux_mips64.go │ │ ├── zerrors_linux_mips64le.go │ │ ├── zerrors_linux_mipsle.go │ │ ├── zerrors_linux_ppc64.go │ │ ├── zerrors_linux_ppc64le.go │ │ ├── zerrors_linux_s390x.go │ │ ├── zerrors_linux_sparc64.go │ │ ├── zerrors_netbsd_386.go │ │ ├── zerrors_netbsd_amd64.go │ │ ├── zerrors_netbsd_arm.go │ │ ├── zerrors_openbsd_386.go │ │ ├── zerrors_openbsd_amd64.go │ │ ├── zerrors_openbsd_arm.go │ │ ├── zerrors_solaris_amd64.go │ │ ├── zptrace386_linux.go │ │ ├── zptracearm_linux.go │ │ ├── zptracemips_linux.go │ │ ├── zptracemipsle_linux.go │ │ ├── zsyscall_darwin_386.go │ │ ├── zsyscall_darwin_amd64.go │ │ ├── zsyscall_darwin_arm.go │ │ ├── zsyscall_darwin_arm64.go │ │ ├── zsyscall_dragonfly_amd64.go │ │ ├── zsyscall_freebsd_386.go │ │ ├── zsyscall_freebsd_amd64.go │ │ ├── zsyscall_freebsd_arm.go │ │ ├── zsyscall_linux_386.go │ │ ├── zsyscall_linux_amd64.go │ │ ├── zsyscall_linux_arm.go │ │ ├── zsyscall_linux_arm64.go │ │ ├── zsyscall_linux_mips.go │ │ ├── zsyscall_linux_mips64.go │ │ ├── zsyscall_linux_mips64le.go │ │ ├── zsyscall_linux_mipsle.go │ │ ├── zsyscall_linux_ppc64.go │ │ ├── zsyscall_linux_ppc64le.go │ │ ├── zsyscall_linux_s390x.go │ │ ├── zsyscall_linux_sparc64.go │ │ ├── zsyscall_netbsd_386.go │ │ ├── zsyscall_netbsd_amd64.go │ │ ├── zsyscall_netbsd_arm.go │ │ ├── zsyscall_openbsd_386.go │ │ ├── zsyscall_openbsd_amd64.go │ │ ├── zsyscall_openbsd_arm.go │ │ ├── zsyscall_solaris_amd64.go │ │ ├── zsysctl_openbsd_386.go │ │ ├── zsysctl_openbsd_amd64.go │ │ ├── zsysctl_openbsd_arm.go │ │ ├── zsysnum_darwin_386.go │ │ ├── zsysnum_darwin_amd64.go │ │ ├── zsysnum_darwin_arm.go │ │ ├── zsysnum_darwin_arm64.go │ │ ├── zsysnum_dragonfly_amd64.go │ │ ├── zsysnum_freebsd_386.go │ │ ├── zsysnum_freebsd_amd64.go │ │ ├── zsysnum_freebsd_arm.go │ │ ├── zsysnum_linux_386.go │ │ ├── zsysnum_linux_amd64.go │ │ ├── zsysnum_linux_arm.go │ │ ├── zsysnum_linux_arm64.go │ │ ├── zsysnum_linux_mips.go │ │ ├── zsysnum_linux_mips64.go │ │ ├── zsysnum_linux_mips64le.go │ │ ├── zsysnum_linux_mipsle.go │ │ ├── zsysnum_linux_ppc64.go │ │ ├── zsysnum_linux_ppc64le.go │ │ ├── zsysnum_linux_s390x.go │ │ ├── zsysnum_linux_sparc64.go │ │ ├── zsysnum_netbsd_386.go │ │ ├── zsysnum_netbsd_amd64.go │ │ ├── zsysnum_netbsd_arm.go │ │ ├── zsysnum_openbsd_386.go │ │ ├── zsysnum_openbsd_amd64.go │ │ ├── zsysnum_openbsd_arm.go │ │ ├── zsysnum_solaris_amd64.go │ │ ├── ztypes_darwin_386.go │ │ ├── ztypes_darwin_amd64.go │ │ ├── ztypes_darwin_arm.go │ │ ├── ztypes_darwin_arm64.go │ │ ├── ztypes_dragonfly_amd64.go │ │ ├── ztypes_freebsd_386.go │ │ ├── ztypes_freebsd_amd64.go │ │ ├── ztypes_freebsd_arm.go │ │ ├── ztypes_linux_386.go │ │ ├── ztypes_linux_amd64.go │ │ ├── ztypes_linux_arm.go │ │ ├── ztypes_linux_arm64.go │ │ ├── ztypes_linux_mips.go │ │ ├── ztypes_linux_mips64.go │ │ ├── ztypes_linux_mips64le.go │ │ ├── ztypes_linux_mipsle.go │ │ ├── ztypes_linux_ppc64.go │ │ ├── ztypes_linux_ppc64le.go │ │ ├── ztypes_linux_s390x.go │ │ ├── ztypes_linux_sparc64.go │ │ ├── ztypes_netbsd_386.go │ │ ├── ztypes_netbsd_amd64.go │ │ ├── ztypes_netbsd_arm.go │ │ ├── ztypes_openbsd_386.go │ │ ├── ztypes_openbsd_amd64.go │ │ ├── ztypes_openbsd_arm.go │ │ └── ztypes_solaris_amd64.go │ │ └── windows │ │ ├── asm_windows_386.s │ │ ├── asm_windows_amd64.s │ │ ├── dll_windows.go │ │ ├── env_unset.go │ │ ├── env_windows.go │ │ ├── eventlog.go │ │ ├── exec_windows.go │ │ ├── memory_windows.go │ │ ├── mksyscall.go │ │ ├── race.go │ │ ├── race0.go │ │ ├── registry │ │ ├── export_test.go │ │ ├── key.go │ │ ├── mksyscall.go │ │ ├── registry_test.go │ │ ├── syscall.go │ │ ├── value.go │ │ └── zsyscall_windows.go │ │ ├── security_windows.go │ │ ├── service.go │ │ ├── str.go │ │ ├── svc │ │ ├── debug │ │ │ ├── log.go │ │ │ └── service.go │ │ ├── event.go │ │ ├── eventlog │ │ │ ├── install.go │ │ │ ├── log.go │ │ │ └── log_test.go │ │ ├── example │ │ │ ├── beep.go │ │ │ ├── install.go │ │ │ ├── main.go │ │ │ ├── manage.go │ │ │ └── service.go │ │ ├── go12.c │ │ ├── go12.go │ │ ├── go13.go │ │ ├── mgr │ │ │ ├── config.go │ │ │ ├── mgr.go │ │ │ ├── mgr_test.go │ │ │ └── service.go │ │ ├── security.go │ │ ├── service.go │ │ ├── svc_test.go │ │ ├── sys_386.s │ │ └── sys_amd64.s │ │ ├── syscall.go │ │ ├── syscall_test.go │ │ ├── syscall_windows.go │ │ ├── syscall_windows_test.go │ │ ├── types_windows.go │ │ ├── types_windows_386.go │ │ ├── types_windows_amd64.go │ │ └── zsyscall_windows.go └── example07 │ ├── Gopkg.lock │ ├── Gopkg.toml │ ├── Makefile │ ├── main.go │ ├── main_test.go │ ├── store.go │ ├── task.go │ ├── tasks.db │ └── vendor │ ├── github.com │ ├── boltdb │ │ └── bolt │ │ │ ├── .gitignore │ │ │ ├── LICENSE │ │ │ ├── Makefile │ │ │ ├── README.md │ │ │ ├── appveyor.yml │ │ │ ├── bolt_386.go │ │ │ ├── bolt_amd64.go │ │ │ ├── bolt_arm.go │ │ │ ├── bolt_arm64.go │ │ │ ├── bolt_linux.go │ │ │ ├── bolt_openbsd.go │ │ │ ├── bolt_ppc.go │ │ │ ├── bolt_ppc64.go │ │ │ ├── bolt_ppc64le.go │ │ │ ├── bolt_s390x.go │ │ │ ├── bolt_unix.go │ │ │ ├── bolt_unix_solaris.go │ │ │ ├── bolt_windows.go │ │ │ ├── boltsync_unix.go │ │ │ ├── bucket.go │ │ │ ├── bucket_test.go │ │ │ ├── cmd │ │ │ └── bolt │ │ │ │ ├── main.go │ │ │ │ └── main_test.go │ │ │ ├── cursor.go │ │ │ ├── cursor_test.go │ │ │ ├── db.go │ │ │ ├── db_test.go │ │ │ ├── doc.go │ │ │ ├── errors.go │ │ │ ├── freelist.go │ │ │ ├── freelist_test.go │ │ │ ├── node.go │ │ │ ├── node_test.go │ │ │ ├── page.go │ │ │ ├── page_test.go │ │ │ ├── quick_test.go │ │ │ ├── simulation_test.go │ │ │ ├── tx.go │ │ │ └── tx_test.go │ └── julienschmidt │ │ └── httprouter │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── path.go │ │ ├── path_test.go │ │ ├── router.go │ │ ├── router_test.go │ │ ├── tree.go │ │ └── tree_test.go │ └── golang.org │ └── x │ └── sys │ ├── .gitattributes │ ├── .gitignore │ ├── AUTHORS │ ├── CONTRIBUTING.md │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ ├── README.md │ ├── codereview.cfg │ ├── plan9 │ ├── asm.s │ ├── asm_plan9_386.s │ ├── asm_plan9_amd64.s │ ├── const_plan9.go │ ├── dir_plan9.go │ ├── env_plan9.go │ ├── env_unset.go │ ├── errors_plan9.go │ ├── mkall.sh │ ├── mkerrors.sh │ ├── mksyscall.pl │ ├── mksysnum_plan9.sh │ ├── pwd_go15_plan9.go │ ├── pwd_plan9.go │ ├── race.go │ ├── race0.go │ ├── str.go │ ├── syscall.go │ ├── syscall_plan9.go │ ├── syscall_test.go │ ├── zsyscall_plan9_386.go │ ├── zsyscall_plan9_amd64.go │ └── zsysnum_plan9.go │ ├── unix │ ├── .gitignore │ ├── README.md │ ├── asm_darwin_386.s │ ├── asm_darwin_amd64.s │ ├── asm_darwin_arm.s │ ├── asm_darwin_arm64.s │ ├── asm_dragonfly_amd64.s │ ├── asm_freebsd_386.s │ ├── asm_freebsd_amd64.s │ ├── asm_freebsd_arm.s │ ├── asm_linux_386.s │ ├── asm_linux_amd64.s │ ├── asm_linux_arm.s │ ├── asm_linux_arm64.s │ ├── asm_linux_mips64x.s │ ├── asm_linux_mipsx.s │ ├── asm_linux_ppc64x.s │ ├── asm_linux_s390x.s │ ├── asm_netbsd_386.s │ ├── asm_netbsd_amd64.s │ ├── asm_netbsd_arm.s │ ├── asm_openbsd_386.s │ ├── asm_openbsd_amd64.s │ ├── asm_openbsd_arm.s │ ├── asm_solaris_amd64.s │ ├── bluetooth_linux.go │ ├── cap_freebsd.go │ ├── constants.go │ ├── creds_test.go │ ├── dev_darwin.go │ ├── dev_darwin_test.go │ ├── dev_dragonfly.go │ ├── dev_dragonfly_test.go │ ├── dev_freebsd.go │ ├── dev_linux.go │ ├── dev_linux_test.go │ ├── dev_netbsd.go │ ├── dev_netbsd_test.go │ ├── dev_openbsd.go │ ├── dev_openbsd_test.go │ ├── dev_solaris_test.go │ ├── dirent.go │ ├── endian_big.go │ ├── endian_little.go │ ├── env_unix.go │ ├── env_unset.go │ ├── errors_freebsd_386.go │ ├── errors_freebsd_amd64.go │ ├── errors_freebsd_arm.go │ ├── export_test.go │ ├── file_unix.go │ ├── flock.go │ ├── flock_linux_32bit.go │ ├── gccgo.go │ ├── gccgo_c.c │ ├── gccgo_linux_amd64.go │ ├── linux │ │ ├── Dockerfile │ │ ├── mkall.go │ │ ├── mksysnum.pl │ │ └── types.go │ ├── mkall.sh │ ├── mkerrors.sh │ ├── mkpost.go │ ├── mksyscall.pl │ ├── mksyscall_solaris.pl │ ├── mksysctl_openbsd.pl │ ├── mksysnum_darwin.pl │ ├── mksysnum_dragonfly.pl │ ├── mksysnum_freebsd.pl │ ├── mksysnum_netbsd.pl │ ├── mksysnum_openbsd.pl │ ├── mmap_unix_test.go │ ├── openbsd_pledge.go │ ├── openbsd_test.go │ ├── pagesize_unix.go │ ├── race.go │ ├── race0.go │ ├── sockcmsg_linux.go │ ├── sockcmsg_unix.go │ ├── str.go │ ├── syscall.go │ ├── syscall_bsd.go │ ├── syscall_bsd_test.go │ ├── syscall_darwin.go │ ├── syscall_darwin_386.go │ ├── syscall_darwin_amd64.go │ ├── syscall_darwin_arm.go │ ├── syscall_darwin_arm64.go │ ├── syscall_dragonfly.go │ ├── syscall_dragonfly_amd64.go │ ├── syscall_freebsd.go │ ├── syscall_freebsd_386.go │ ├── syscall_freebsd_amd64.go │ ├── syscall_freebsd_arm.go │ ├── syscall_freebsd_test.go │ ├── syscall_linux.go │ ├── syscall_linux_386.go │ ├── syscall_linux_amd64.go │ ├── syscall_linux_amd64_gc.go │ ├── syscall_linux_arm.go │ ├── syscall_linux_arm64.go │ ├── syscall_linux_mips64x.go │ ├── syscall_linux_mipsx.go │ ├── syscall_linux_ppc64x.go │ ├── syscall_linux_s390x.go │ ├── syscall_linux_sparc64.go │ ├── syscall_linux_test.go │ ├── syscall_netbsd.go │ ├── syscall_netbsd_386.go │ ├── syscall_netbsd_amd64.go │ ├── syscall_netbsd_arm.go │ ├── syscall_no_getwd.go │ ├── syscall_openbsd.go │ ├── syscall_openbsd_386.go │ ├── syscall_openbsd_amd64.go │ ├── syscall_openbsd_arm.go │ ├── syscall_solaris.go │ ├── syscall_solaris_amd64.go │ ├── syscall_solaris_test.go │ ├── syscall_test.go │ ├── syscall_unix.go │ ├── syscall_unix_gc.go │ ├── syscall_unix_test.go │ ├── timestruct.go │ ├── types_darwin.go │ ├── types_dragonfly.go │ ├── types_freebsd.go │ ├── types_netbsd.go │ ├── types_openbsd.go │ ├── types_solaris.go │ ├── zerrors_darwin_386.go │ ├── zerrors_darwin_amd64.go │ ├── zerrors_darwin_arm.go │ ├── zerrors_darwin_arm64.go │ ├── zerrors_dragonfly_amd64.go │ ├── zerrors_freebsd_386.go │ ├── zerrors_freebsd_amd64.go │ ├── zerrors_freebsd_arm.go │ ├── zerrors_linux_386.go │ ├── zerrors_linux_amd64.go │ ├── zerrors_linux_arm.go │ ├── zerrors_linux_arm64.go │ ├── zerrors_linux_mips.go │ ├── zerrors_linux_mips64.go │ ├── zerrors_linux_mips64le.go │ ├── zerrors_linux_mipsle.go │ ├── zerrors_linux_ppc64.go │ ├── zerrors_linux_ppc64le.go │ ├── zerrors_linux_s390x.go │ ├── zerrors_linux_sparc64.go │ ├── zerrors_netbsd_386.go │ ├── zerrors_netbsd_amd64.go │ ├── zerrors_netbsd_arm.go │ ├── zerrors_openbsd_386.go │ ├── zerrors_openbsd_amd64.go │ ├── zerrors_openbsd_arm.go │ ├── zerrors_solaris_amd64.go │ ├── zptrace386_linux.go │ ├── zptracearm_linux.go │ ├── zptracemips_linux.go │ ├── zptracemipsle_linux.go │ ├── zsyscall_darwin_386.go │ ├── zsyscall_darwin_amd64.go │ ├── zsyscall_darwin_arm.go │ ├── zsyscall_darwin_arm64.go │ ├── zsyscall_dragonfly_amd64.go │ ├── zsyscall_freebsd_386.go │ ├── zsyscall_freebsd_amd64.go │ ├── zsyscall_freebsd_arm.go │ ├── zsyscall_linux_386.go │ ├── zsyscall_linux_amd64.go │ ├── zsyscall_linux_arm.go │ ├── zsyscall_linux_arm64.go │ ├── zsyscall_linux_mips.go │ ├── zsyscall_linux_mips64.go │ ├── zsyscall_linux_mips64le.go │ ├── zsyscall_linux_mipsle.go │ ├── zsyscall_linux_ppc64.go │ ├── zsyscall_linux_ppc64le.go │ ├── zsyscall_linux_s390x.go │ ├── zsyscall_linux_sparc64.go │ ├── zsyscall_netbsd_386.go │ ├── zsyscall_netbsd_amd64.go │ ├── zsyscall_netbsd_arm.go │ ├── zsyscall_openbsd_386.go │ ├── zsyscall_openbsd_amd64.go │ ├── zsyscall_openbsd_arm.go │ ├── zsyscall_solaris_amd64.go │ ├── zsysctl_openbsd_386.go │ ├── zsysctl_openbsd_amd64.go │ ├── zsysctl_openbsd_arm.go │ ├── zsysnum_darwin_386.go │ ├── zsysnum_darwin_amd64.go │ ├── zsysnum_darwin_arm.go │ ├── zsysnum_darwin_arm64.go │ ├── zsysnum_dragonfly_amd64.go │ ├── zsysnum_freebsd_386.go │ ├── zsysnum_freebsd_amd64.go │ ├── zsysnum_freebsd_arm.go │ ├── zsysnum_linux_386.go │ ├── zsysnum_linux_amd64.go │ ├── zsysnum_linux_arm.go │ ├── zsysnum_linux_arm64.go │ ├── zsysnum_linux_mips.go │ ├── zsysnum_linux_mips64.go │ ├── zsysnum_linux_mips64le.go │ ├── zsysnum_linux_mipsle.go │ ├── zsysnum_linux_ppc64.go │ ├── zsysnum_linux_ppc64le.go │ ├── zsysnum_linux_s390x.go │ ├── zsysnum_linux_sparc64.go │ ├── zsysnum_netbsd_386.go │ ├── zsysnum_netbsd_amd64.go │ ├── zsysnum_netbsd_arm.go │ ├── zsysnum_openbsd_386.go │ ├── zsysnum_openbsd_amd64.go │ ├── zsysnum_openbsd_arm.go │ ├── zsysnum_solaris_amd64.go │ ├── ztypes_darwin_386.go │ ├── ztypes_darwin_amd64.go │ ├── ztypes_darwin_arm.go │ ├── ztypes_darwin_arm64.go │ ├── ztypes_dragonfly_amd64.go │ ├── ztypes_freebsd_386.go │ ├── ztypes_freebsd_amd64.go │ ├── ztypes_freebsd_arm.go │ ├── ztypes_linux_386.go │ ├── ztypes_linux_amd64.go │ ├── ztypes_linux_arm.go │ ├── ztypes_linux_arm64.go │ ├── ztypes_linux_mips.go │ ├── ztypes_linux_mips64.go │ ├── ztypes_linux_mips64le.go │ ├── ztypes_linux_mipsle.go │ ├── ztypes_linux_ppc64.go │ ├── ztypes_linux_ppc64le.go │ ├── ztypes_linux_s390x.go │ ├── ztypes_linux_sparc64.go │ ├── ztypes_netbsd_386.go │ ├── ztypes_netbsd_amd64.go │ ├── ztypes_netbsd_arm.go │ ├── ztypes_openbsd_386.go │ ├── ztypes_openbsd_amd64.go │ ├── ztypes_openbsd_arm.go │ └── ztypes_solaris_amd64.go │ └── windows │ ├── asm_windows_386.s │ ├── asm_windows_amd64.s │ ├── dll_windows.go │ ├── env_unset.go │ ├── env_windows.go │ ├── eventlog.go │ ├── exec_windows.go │ ├── memory_windows.go │ ├── mksyscall.go │ ├── race.go │ ├── race0.go │ ├── registry │ ├── export_test.go │ ├── key.go │ ├── mksyscall.go │ ├── registry_test.go │ ├── syscall.go │ ├── value.go │ └── zsyscall_windows.go │ ├── security_windows.go │ ├── service.go │ ├── str.go │ ├── svc │ ├── debug │ │ ├── log.go │ │ └── service.go │ ├── event.go │ ├── eventlog │ │ ├── install.go │ │ ├── log.go │ │ └── log_test.go │ ├── example │ │ ├── beep.go │ │ ├── install.go │ │ ├── main.go │ │ ├── manage.go │ │ └── service.go │ ├── go12.c │ ├── go12.go │ ├── go13.go │ ├── mgr │ │ ├── config.go │ │ ├── mgr.go │ │ ├── mgr_test.go │ │ └── service.go │ ├── security.go │ ├── service.go │ ├── svc_test.go │ ├── sys_386.s │ └── sys_amd64.s │ ├── syscall.go │ ├── syscall_test.go │ ├── syscall_windows.go │ ├── syscall_windows_test.go │ ├── types_windows.go │ ├── types_windows_386.go │ ├── types_windows_amd64.go │ └── zsyscall_windows.go └── hour26 ├── example01.go ├── example02.go ├── example03.go ├── example04.go └── example05.go /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.swo 3 | .DS_Store 4 | *~ 5 | *.log 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.9 5 | - 1.8 6 | - 1.7 7 | - 1.6 8 | 9 | script: 10 | - make 11 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | files=$(shell find . -name '*.go' | grep -v hour15/example04/example04.go | grep -v hour14/example01.go | grep -v hour14/example04/example04.go | grep -v vendor) 2 | 3 | GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./**/vendor/*") 4 | 5 | all: check-gofmt 6 | 7 | check-gofmt: 8 | @if [ -n "$(shell gofmt -l ${files})" ]; then \ 9 | echo 1>&2 'The following files need to be formatted:'; \ 10 | gofmt -l .; \ 11 | exit 1; \ 12 | fi 13 | 14 | vet: 15 | @go vet ${GOFILES_NOVENDOR} 16 | 17 | lint: 18 | @golint ${GOFILES_NOVENDOR} 19 | -------------------------------------------------------------------------------- /hello_world.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println("Hello World!") 7 | } 8 | -------------------------------------------------------------------------------- /hour01/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println("Hello World!") 7 | } 8 | -------------------------------------------------------------------------------- /hour02/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func sayHello(s string) string { 6 | return "Hello " + s 7 | } 8 | 9 | func main() { 10 | fmt.Println(sayHello("George")) 11 | } 12 | -------------------------------------------------------------------------------- /hour02/example02.js: -------------------------------------------------------------------------------- 1 | var addition = function (x,y) { 2 | return x + y; 3 | } 4 | 5 | console.log(addition(1,3)) 6 | -------------------------------------------------------------------------------- /hour02/example03.js: -------------------------------------------------------------------------------- 1 | var addition = function (x,y) { 2 | return x + y; 3 | } 4 | 5 | console.log(addition(1, "three")) 6 | -------------------------------------------------------------------------------- /hour02/example04.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func addition(x int, y int) int { 6 | return x + y 7 | } 8 | 9 | func main() { 10 | var s string = "three" 11 | fmt.Println(addition(1, s)) 12 | } 13 | -------------------------------------------------------------------------------- /hour02/example05.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var b bool 7 | fmt.Println(b) 8 | } 9 | -------------------------------------------------------------------------------- /hour02/example06.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var b bool 7 | fmt.Println(b) 8 | b = true 9 | fmt.Println(b) 10 | } 11 | -------------------------------------------------------------------------------- /hour02/example07.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | ) 7 | 8 | func main() { 9 | var s string = "string" 10 | var i int = 10 11 | var f float32 = 1.2 12 | 13 | fmt.Println(reflect.TypeOf(s)) 14 | fmt.Println(reflect.TypeOf(i)) 15 | fmt.Println(reflect.TypeOf(f)) 16 | } 17 | -------------------------------------------------------------------------------- /hour02/example08.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | "strconv" 7 | ) 8 | 9 | func main() { 10 | var b bool = true 11 | fmt.Println(reflect.TypeOf(b)) 12 | var s string = strconv.FormatBool(true) 13 | fmt.Println(reflect.TypeOf(s)) 14 | } 15 | -------------------------------------------------------------------------------- /hour03/README.md: -------------------------------------------------------------------------------- 1 | # Hour 3 - Variables 2 | 3 | What You'll Learn in This Hour: 4 | 5 | * How To Declare A Variable 6 | * The Difference Between A Variable And A Constant 7 | * What A Zero Value Variable Is 8 | * What Variable Scope Is 9 | * How To Use Pointers 10 | -------------------------------------------------------------------------------- /hour03/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var s string = "Hello World" 7 | fmt.Println(s) 8 | } 9 | -------------------------------------------------------------------------------- /hour03/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var s string 7 | s = "Hello World" 8 | fmt.Println(s) 9 | } 10 | -------------------------------------------------------------------------------- /hour03/example03.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var i int 7 | i = "One" 8 | fmt.Println(i) 9 | } 10 | -------------------------------------------------------------------------------- /hour03/example04.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var s, t string = "foo", "bar" 7 | fmt.Println(s) 8 | fmt.Println(t) 9 | } 10 | -------------------------------------------------------------------------------- /hour03/example05.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var ( 7 | s string = "foo" 8 | t int = 4 9 | ) 10 | fmt.Println(s) 11 | fmt.Println(t) 12 | } 13 | -------------------------------------------------------------------------------- /hour03/example06.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var i int 7 | var f float64 8 | var b bool 9 | var s string 10 | fmt.Printf("%v %v %v %q\n", i, f, b, s) 11 | } 12 | -------------------------------------------------------------------------------- /hour03/example07.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var s string 7 | if s == "" { 8 | fmt.Println("s has not been assigned a value and is zero valued") 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /hour03/example08.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | s := "Hello world" 7 | fmt.Println(s) 8 | } 9 | -------------------------------------------------------------------------------- /hour03/example09.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | var s = "Hello World" 6 | 7 | func main() { 8 | i := 42 9 | fmt.Println(s) 10 | fmt.Println(i) 11 | } 12 | -------------------------------------------------------------------------------- /hour03/example10.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | var s = "Hello world" 8 | 9 | func main() { 10 | fmt.Printf("Printing `s` variable from outer block %v\n", s) 11 | b := true 12 | if b { 13 | fmt.Printf("Printing `b` variable from outer block %v\n", b) 14 | i := 42 15 | if b != false { 16 | fmt.Printf("Printing `i` variable from outer block %v\n", i) 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /hour03/example11.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func main() { 8 | s := "Hello world" 9 | fmt.Println(&s) 10 | } 11 | -------------------------------------------------------------------------------- /hour03/example12.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func showMemoryAddress(x int) { 8 | fmt.Println(&x) 9 | return 10 | } 11 | 12 | func main() { 13 | i := 1 14 | fmt.Println(&i) 15 | showMemoryAddress(i) 16 | } 17 | -------------------------------------------------------------------------------- /hour03/example13.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func showMemoryAddress(x *int) { 8 | fmt.Println(x) 9 | return 10 | } 11 | 12 | func main() { 13 | i := 1 14 | fmt.Println(&i) 15 | showMemoryAddress(&i) 16 | } 17 | -------------------------------------------------------------------------------- /hour03/example14.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | const greeting string = "Hello, world" 8 | 9 | func main() { 10 | fmt.Println(greeting) 11 | } 12 | -------------------------------------------------------------------------------- /hour03/example15.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | const greeting string = "Hello, world" 8 | 9 | func main() { 10 | greeting = "Goodbye, cruel world" 11 | fmt.Println(greeting) 12 | } 13 | -------------------------------------------------------------------------------- /hour04/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func isEven(i int) bool { 6 | return i%2 == 0 7 | } 8 | 9 | func main() { 10 | fmt.Printf("%v\n", isEven(1)) 11 | fmt.Printf("%v\n", isEven(2)) 12 | } 13 | -------------------------------------------------------------------------------- /hour04/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func getPrize() (int, string) { 6 | i := 2 7 | s := "goldfish" 8 | return i, s 9 | } 10 | 11 | func main() { 12 | quantity, prize := getPrize() 13 | fmt.Printf("You won %v %v\n", quantity, prize) 14 | } 15 | -------------------------------------------------------------------------------- /hour04/example03.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func sumNumbers(numbers ...int) int { 6 | total := 0 7 | for _, number := range numbers { 8 | total += number 9 | } 10 | return total 11 | } 12 | 13 | func main() { 14 | result := sumNumbers(1, 2, 3, 4) 15 | fmt.Printf("The result is %v\n", result) 16 | } 17 | -------------------------------------------------------------------------------- /hour04/example04.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func sayHi() (x, y string) { 6 | x = "hello" 7 | y = "world" 8 | return 9 | } 10 | 11 | func main() { 12 | fmt.Println(sayHi()) 13 | } 14 | -------------------------------------------------------------------------------- /hour04/example05.go: -------------------------------------------------------------------------------- 1 | /* recursive function */ 2 | package main 3 | 4 | import "fmt" 5 | 6 | func feedMe(portion int, eaten int) int { 7 | eaten = portion + eaten 8 | if eaten >= 5 { 9 | fmt.Printf("I'm full! I've eaten %d\n", eaten) 10 | return eaten 11 | } 12 | fmt.Printf("I'm still hungry! I've eaten %d\n", eaten) 13 | return feedMe(portion, eaten) 14 | } 15 | 16 | func main() { 17 | feedMe(1, 0) 18 | } 19 | -------------------------------------------------------------------------------- /hour04/example06.go: -------------------------------------------------------------------------------- 1 | /* recursive function */ 2 | package main 3 | 4 | import "fmt" 5 | 6 | func main() { 7 | fn := func() { 8 | fmt.Println("function called") 9 | } 10 | fn() 11 | 12 | } 13 | -------------------------------------------------------------------------------- /hour04/example07.go: -------------------------------------------------------------------------------- 1 | /* recursive function */ 2 | package main 3 | 4 | import "fmt" 5 | 6 | func anotherFunction(f func() string) string { 7 | return f() 8 | } 9 | 10 | func main() { 11 | fn := func() string { 12 | return "function called" 13 | } 14 | fmt.Println(anotherFunction(fn)) 15 | 16 | } 17 | -------------------------------------------------------------------------------- /hour05/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | b := true 7 | if b { 8 | fmt.Println("b is true!") 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /hour05/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | b := false 7 | if b { 8 | fmt.Println("b is true!") 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /hour05/example03.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | b := false 7 | if b { 8 | fmt.Println("b is true!") 9 | } else { 10 | fmt.Println("b is false") 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /hour05/example04.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | i := 2 7 | if i == 3 { 8 | fmt.Println("i is 3") 9 | } else if i == 2 { 10 | fmt.Println("i is 2") 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /hour05/example05.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | i := 2 7 | 8 | switch i { 9 | case 2: 10 | fmt.Println("Two!") 11 | case 3: 12 | fmt.Println("Three!") 13 | case 4: 14 | fmt.Println("Four!") 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /hour05/example06.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | s := "c" 7 | 8 | switch s { 9 | case "a": 10 | fmt.Println("The letter a!") 11 | case "b": 12 | fmt.Println("The letter b!") 13 | default: 14 | fmt.Println("I don't recognize that letter!") 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /hour05/example07.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | i := 0 7 | for i < 10 { 8 | i++ 9 | fmt.Println("i is", i) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /hour05/example08.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | for i := 0; i < 10; i++ { 7 | fmt.Println("i is", i) 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /hour05/example09.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | numbers := []int{1, 2, 3, 4} 7 | for i, n := range numbers { 8 | fmt.Println("The index of the loop is", i) 9 | fmt.Println("The value from the slice is", n) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /hour05/example10.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | defer fmt.Println("I am run after the function completes") 7 | fmt.Println("Hello World!") 8 | } 9 | -------------------------------------------------------------------------------- /hour05/example11.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | defer fmt.Println("I am the first defer statement") 7 | defer fmt.Println("I am the second defer statement") 8 | defer fmt.Println("I am the third defer statement") 9 | fmt.Println("Hello World!") 10 | } 11 | -------------------------------------------------------------------------------- /hour06/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var cheeses [2]string 7 | cheeses[0] = "Mariolles" 8 | cheeses[1] = "Époisses de Bourgogne" 9 | fmt.Println(cheeses[0]) 10 | fmt.Println(cheeses[1]) 11 | fmt.Println(cheeses) 12 | } 13 | -------------------------------------------------------------------------------- /hour06/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var cheeses [2]string 7 | cheeses[0] = "Mariolles" 8 | cheeses[1] = "Époisses de Bourgogne" 9 | cheeses[2] = "Camembert" 10 | fmt.Println(cheeses[0]) 11 | fmt.Println(cheeses[1]) 12 | fmt.Println(cheeses) 13 | } 14 | -------------------------------------------------------------------------------- /hour06/example03.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var cheeses = make([]string, 2) 7 | cheeses[0] = "Mariolles" 8 | cheeses[1] = "Époisses de Bourgogne" 9 | cheeses = append(cheeses, "Camembert") 10 | fmt.Println(cheeses[2]) 11 | } 12 | -------------------------------------------------------------------------------- /hour06/example04.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var cheeses = make([]string, 2) 7 | cheeses[0] = "Mariolles" 8 | cheeses[1] = "Époisses de Bourgogne" 9 | cheeses = append(cheeses, "Camembert", "Reblochon", "Picodon") 10 | fmt.Println(cheeses) 11 | } 12 | -------------------------------------------------------------------------------- /hour06/example05.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var cheeses = make([]string, 3) 7 | cheeses[0] = "Mariolles" 8 | cheeses[1] = "Époisses de Bourgogne" 9 | cheeses[2] = "Camembert" 10 | fmt.Println(len(cheeses)) 11 | fmt.Println(cheeses) 12 | cheeses = append(cheeses[:2], cheeses[2+1:]...) 13 | fmt.Println(len(cheeses)) 14 | fmt.Println(cheeses) 15 | } 16 | -------------------------------------------------------------------------------- /hour06/example06.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var cheeses = make([]string, 2) 7 | cheeses[0] = "Mariolles" 8 | cheeses[1] = "Époisses de Bourgogne" 9 | var smellyCheeses = make([]string, 2) 10 | copy(smellyCheeses, cheeses) 11 | fmt.Println(smellyCheeses) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /hour06/example07.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var players = make(map[string]int) 7 | players["cook"] = 32 8 | players["bairstow"] = 27 9 | players["stokes"] = 26 10 | fmt.Println(players["cook"]) 11 | fmt.Println(players["bairstow"]) 12 | } 13 | -------------------------------------------------------------------------------- /hour06/example08.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var players = make(map[string]int) 7 | players["cook"] = 32 8 | players["bairstow"] = 27 9 | players["stokes"] = 26 10 | delete(players, "cook") 11 | fmt.Println(players) 12 | } 13 | -------------------------------------------------------------------------------- /hour07/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type Movie struct { 6 | Name string 7 | Rating float32 8 | } 9 | 10 | func main() { 11 | m := Movie{ 12 | Name: "Citizen Kane", 13 | Rating: 10, 14 | } 15 | fmt.Println(m.Name, m.Rating) 16 | } 17 | -------------------------------------------------------------------------------- /hour07/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type Movie struct { 6 | Name string 7 | Rating float32 8 | } 9 | 10 | func main() { 11 | var m Movie 12 | fmt.Printf("%+v\n", m) 13 | } 14 | -------------------------------------------------------------------------------- /hour07/example03.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type Movie struct { 6 | Name string 7 | Rating float32 8 | } 9 | 10 | func main() { 11 | var m Movie 12 | fmt.Printf("%+v\n", m) 13 | m.Name = "Metropolis" 14 | m.Rating = 0.99 15 | fmt.Printf("%+v\n", m) 16 | } 17 | -------------------------------------------------------------------------------- /hour07/example04.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type Movie struct { 6 | Name string 7 | Rating float32 8 | } 9 | 10 | func main() { 11 | m := new(Movie) 12 | m.Name = "Metropolis" 13 | m.Rating = 0.99 14 | fmt.Printf("%+v\n", m) 15 | } 16 | -------------------------------------------------------------------------------- /hour07/example05.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type Movie struct { 6 | Name string 7 | Rating float32 8 | } 9 | 10 | func main() { 11 | m := Movie{ 12 | Name: "Metropolis", 13 | Rating: 0.99, 14 | } 15 | fmt.Printf("%+v\n", m) 16 | } 17 | -------------------------------------------------------------------------------- /hour07/example06.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type Superhero struct { 6 | Name string 7 | Age int 8 | Address Address 9 | } 10 | 11 | type Address struct { 12 | Number int 13 | Street string 14 | City string 15 | } 16 | 17 | func main() { 18 | e := Superhero{ 19 | Name: "Batman", 20 | Age: 32, 21 | Address: Address{ 22 | Number: 1007, 23 | Street: "Mountain Drive", 24 | City: "Gotham", 25 | }, 26 | } 27 | fmt.Printf("%+v\n", e) 28 | } 29 | -------------------------------------------------------------------------------- /hour07/example07.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type Alarm struct { 6 | Time string 7 | Sound string 8 | } 9 | 10 | func NewAlarm(time string) Alarm { 11 | a := Alarm{ 12 | Time: time, 13 | Sound: "Klaxon", 14 | } 15 | return a 16 | } 17 | 18 | func main() { 19 | fmt.Printf("%+v\n", NewAlarm("07:00")) 20 | } 21 | -------------------------------------------------------------------------------- /hour07/example08.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type Drink struct { 6 | Name string 7 | Ice bool 8 | } 9 | 10 | func main() { 11 | a := Drink{ 12 | Name: "Lemonade", 13 | Ice: true, 14 | } 15 | b := Drink{ 16 | Name: "Lemonade", 17 | Ice: true, 18 | } 19 | if a == b { 20 | fmt.Println("a and b are the same") 21 | } 22 | fmt.Printf("%+v\n", a) 23 | fmt.Printf("%+v\n", b) 24 | } 25 | -------------------------------------------------------------------------------- /hour07/example09.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | ) 7 | 8 | type Drink struct { 9 | Name string 10 | Ice bool 11 | } 12 | 13 | func main() { 14 | a := Drink{ 15 | Name: "Lemonade", 16 | Ice: true, 17 | } 18 | b := Drink{ 19 | Name: "Lemonade", 20 | Ice: true, 21 | } 22 | fmt.Println(reflect.TypeOf(a)) 23 | fmt.Println(reflect.TypeOf(b)) 24 | } 25 | -------------------------------------------------------------------------------- /hour07/example10.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type Drink struct { 6 | Name string 7 | Ice bool 8 | } 9 | 10 | func main() { 11 | a := Drink{ 12 | Name: "Lemonade", 13 | Ice: true, 14 | } 15 | b := a 16 | b.Ice = false 17 | fmt.Printf("%+v\n", b) 18 | fmt.Printf("%+v\n", a) 19 | fmt.Printf("%p\n", &a) 20 | fmt.Printf("%p\n", &b) 21 | } 22 | -------------------------------------------------------------------------------- /hour07/example11.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type Drink struct { 6 | Name string 7 | Ice bool 8 | } 9 | 10 | func main() { 11 | a := Drink{ 12 | Name: "Lemonade", 13 | Ice: true, 14 | } 15 | b := &a 16 | b.Ice = false 17 | fmt.Printf("%+v\n", *b) 18 | fmt.Printf("%+v\n", a) 19 | fmt.Printf("%p\n", b) 20 | fmt.Printf("%p\n", &a) 21 | } 22 | -------------------------------------------------------------------------------- /hour08/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | type Movie struct { 9 | Name string 10 | Rating float64 11 | } 12 | 13 | func (m *Movie) summary() string { 14 | r := strconv.FormatFloat(m.Rating, 'f', 1, 64) 15 | return m.Name + ", " + r 16 | } 17 | 18 | func main() { 19 | m := Movie{ 20 | Name: "Spiderman", 21 | Rating: 3.2, 22 | } 23 | 24 | fmt.Println(m.summary()) 25 | } 26 | -------------------------------------------------------------------------------- /hour08/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "math" 6 | ) 7 | 8 | type Sphere struct { 9 | Radius float64 10 | } 11 | 12 | func (s *Sphere) SurfaceArea() float64 { 13 | return float64(4) * math.Pi * (s.Radius * s.Radius) 14 | } 15 | 16 | func (s *Sphere) Volume() float64 { 17 | radiusCubed := s.Radius * s.Radius * s.Radius 18 | return (float64(4) / float64(3)) * math.Pi * radiusCubed 19 | } 20 | 21 | func main() { 22 | 23 | s := Sphere{ 24 | Radius: 5, 25 | } 26 | fmt.Println(s.SurfaceArea()) 27 | fmt.Println(s.Volume()) 28 | 29 | } 30 | -------------------------------------------------------------------------------- /hour08/example03.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type Triangle struct { 8 | base float64 9 | height float64 10 | } 11 | 12 | func (t *Triangle) area() float64 { 13 | return 0.5 * (t.base * t.height) 14 | } 15 | 16 | func main() { 17 | t := Triangle{base: 3, height: 1} 18 | fmt.Println(t.area()) 19 | } 20 | -------------------------------------------------------------------------------- /hour08/example04.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type Triangle struct { 8 | base float64 9 | height float64 10 | } 11 | 12 | func (t Triangle) changeBase(f float64) { 13 | t.base = f 14 | return 15 | } 16 | 17 | func main() { 18 | t := Triangle{base: 3, height: 1} 19 | t.changeBase(4) 20 | fmt.Println(t.base) 21 | } 22 | -------------------------------------------------------------------------------- /hour08/example05.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type Triangle struct { 8 | base float64 9 | height float64 10 | } 11 | 12 | func (t *Triangle) changeBase(f float64) { 13 | t.base = f 14 | return 15 | } 16 | 17 | func main() { 18 | t := Triangle{base: 3, height: 1} 19 | t.changeBase(4) 20 | fmt.Println(t.base) 21 | } 22 | -------------------------------------------------------------------------------- /hour09/README.md: -------------------------------------------------------------------------------- 1 | # Hour 09 - Strings 2 | 3 | What You'll Learn in This Hour: 4 | 5 | * How to Create a String 6 | * How to Use Rune Literals 7 | * How to Concatenate Strings 8 | * An Introduction To Encoding 9 | -------------------------------------------------------------------------------- /hour09/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | s := "I am an interpreted string literal" 7 | fmt.Println(s) 8 | } 9 | -------------------------------------------------------------------------------- /hour09/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | s := "After a backslash, certain single character escapes represent special values\nn is a line feed or new line \n\t t is a tab" 7 | fmt.Println(s) 8 | } 9 | -------------------------------------------------------------------------------- /hour09/example03.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | s := `After a backslash, certain single character escapes represent special values 7 | n is a line feed or new line 8 | t is a tab` 9 | 10 | fmt.Println(s) 11 | } 12 | -------------------------------------------------------------------------------- /hour09/example04.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | s := "Oh sweet ignition" + " be my fuse" 7 | fmt.Println(s) 8 | } 9 | -------------------------------------------------------------------------------- /hour09/example05.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | s := "Can you hear me?" 7 | s += "\nHear me screamin'?" 8 | fmt.Println(s) 9 | } 10 | -------------------------------------------------------------------------------- /hour09/example06.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | var i = 1 // int 7 | var s = " egg" // string 8 | var breakfast string = i + s 9 | fmt.Println(breakfast) 10 | } 11 | -------------------------------------------------------------------------------- /hour09/example07.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | func main() { 9 | var i = 1 // int 10 | intToString := strconv.Itoa(i) 11 | var s = " egg" // string 12 | var breakfast = intToString + s 13 | fmt.Println(breakfast) 14 | } 15 | -------------------------------------------------------------------------------- /hour09/example08.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | ) 7 | 8 | func main() { 9 | var buffer bytes.Buffer 10 | 11 | for i := 0; i < 500; i++ { 12 | buffer.WriteString("z") 13 | } 14 | 15 | fmt.Println(buffer.String()) 16 | } 17 | -------------------------------------------------------------------------------- /hour09/example09.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | func main() { 9 | fmt.Println(strings.ToLower("VERY IMPORTANT MESSAGE")) 10 | } 11 | -------------------------------------------------------------------------------- /hour09/example10.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | func main() { 9 | fmt.Println(strings.Index("surface", "face")) 10 | fmt.Println(strings.Index("moon", "aer")) 11 | } 12 | -------------------------------------------------------------------------------- /hour09/example11.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | func main() { 9 | fmt.Println(strings.TrimSpace(" I don't need all this space ")) 10 | } 11 | -------------------------------------------------------------------------------- /hour10/README.md: -------------------------------------------------------------------------------- 1 | # Hour 10 - Error Handling 2 | 3 | What You'll Learn in This Hour: 4 | 5 | * How to work with errors in Go 6 | * How to create errors 7 | * How to use Go's idiomatic approach to errors 8 | * How to write good error messages 9 | -------------------------------------------------------------------------------- /hour10/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | ) 7 | 8 | func main() { 9 | var file []byte 10 | var err error 11 | file, err = ioutil.ReadFile("foo.txt") 12 | if err != nil { 13 | fmt.Println(err) 14 | return 15 | } 16 | fmt.Printf("%s", file) 17 | } 18 | -------------------------------------------------------------------------------- /hour10/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | ) 7 | 8 | func main() { 9 | err := errors.New("Something went wrong") 10 | if err != nil { 11 | fmt.Println(err) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /hour10/example03.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func main() { 8 | name, role := "Richard Jupp", "Drummer" 9 | err := fmt.Errorf("The %v %v quit", role, name) 10 | if err != nil { 11 | fmt.Println(err) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /hour10/example04.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | // Half takes an integer and returns half the value 8 | func Half(numberToHalf int) (int, error) { 9 | if numberToHalf%2 != 0 { 10 | return -1, fmt.Errorf("Cannot half %v", numberToHalf) 11 | } 12 | return numberToHalf / 2, nil 13 | } 14 | 15 | func main() { 16 | n, err := Half(19) 17 | if err != nil { 18 | fmt.Println(err) 19 | return 20 | } 21 | fmt.Println(n) 22 | } 23 | -------------------------------------------------------------------------------- /hour10/example05.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println("This is executed") 7 | panic("Oh no. I can do no more. Goodbye.") 8 | // fmt.Println("This is not executed") 9 | } 10 | -------------------------------------------------------------------------------- /hour11/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func slowFunc() { 9 | time.Sleep(time.Second * 2) 10 | fmt.Println("sleeper() finished") 11 | } 12 | 13 | func main() { 14 | slowFunc() 15 | fmt.Println("I am not shown until slowFunc() completes") 16 | } 17 | -------------------------------------------------------------------------------- /hour11/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func slowFunc() { 9 | time.Sleep(time.Second * 2) 10 | fmt.Println("slowFunc() finished") 11 | } 12 | 13 | func main() { 14 | go slowFunc() 15 | fmt.Println("I am now shown straightaway!") 16 | } 17 | -------------------------------------------------------------------------------- /hour11/example03.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func slowFunc() { 9 | time.Sleep(time.Second * 2) 10 | fmt.Println("slowFunc() finished") 11 | } 12 | 13 | func main() { 14 | go slowFunc() 15 | fmt.Println("I am now shown straightaway!") 16 | time.Sleep(time.Second * 3) 17 | } 18 | -------------------------------------------------------------------------------- /hour11/example04.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "net/http" 7 | "time" 8 | ) 9 | 10 | func responseTime(url string) { 11 | 12 | start := time.Now() 13 | 14 | res, err := http.Get(url) 15 | 16 | if err != nil { 17 | log.Fatal(err) 18 | } 19 | 20 | defer res.Body.Close() 21 | 22 | elapsed := time.Since(start).Seconds() 23 | 24 | fmt.Printf("%s took %v seconds \n", url, elapsed) 25 | 26 | } 27 | 28 | func main() { 29 | urls := make([]string, 3) 30 | urls[0] = "https://www.usa.gov/" 31 | urls[1] = "https://www.gov.uk/" 32 | urls[2] = "http://www.gouvernement.fr/" 33 | 34 | for _, u := range urls { 35 | responseTime(u) 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /hour11/example05.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "os" 7 | "time" 8 | ) 9 | 10 | func responseTime(url string) { 11 | 12 | start := time.Now() 13 | 14 | res, err := http.Get(url) 15 | 16 | if err != nil { 17 | fmt.Println(err) 18 | os.Exit(1) 19 | } 20 | 21 | defer res.Body.Close() 22 | 23 | elapsed := time.Since(start).Seconds() 24 | 25 | fmt.Printf("%s took %v seconds \n", url, elapsed) 26 | 27 | } 28 | 29 | func main() { 30 | urls := make([]string, 3) 31 | urls[0] = "https://www.usa.gov/" 32 | urls[1] = "https://www.gov.uk/" 33 | urls[2] = "http://www.gouvernement.fr/" 34 | 35 | for _, u := range urls { 36 | go responseTime(u) 37 | } 38 | 39 | time.Sleep(time.Second * 5) 40 | 41 | } 42 | -------------------------------------------------------------------------------- /hour12/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func slowFunc(c chan string) { 9 | time.Sleep(time.Second * 2) 10 | c <- "slowFunc() finished" 11 | } 12 | 13 | func main() { 14 | c := make(chan string) 15 | go slowFunc(c) 16 | 17 | msg := <-c 18 | fmt.Println(msg) 19 | } 20 | -------------------------------------------------------------------------------- /hour12/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func receiver(c chan string) { 9 | for msg := range c { 10 | fmt.Println(msg) 11 | } 12 | } 13 | 14 | func main() { 15 | 16 | messages := make(chan string, 2) 17 | messages <- "hello" 18 | messages <- "world" 19 | close(messages) 20 | fmt.Println("Pushed two messages onto channel with no receivers") 21 | time.Sleep(time.Second * 1) 22 | receiver(messages) 23 | 24 | } 25 | -------------------------------------------------------------------------------- /hour12/example03.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func pinger(c chan string) { 9 | t := time.NewTicker(1 * time.Second) 10 | for { 11 | c <- "ping" 12 | <-t.C 13 | } 14 | } 15 | 16 | func main() { 17 | messages := make(chan string) 18 | go pinger(messages) 19 | msg := <-messages 20 | fmt.Println(msg) 21 | } 22 | -------------------------------------------------------------------------------- /hour12/example04.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func pinger(c chan string) { 9 | t := time.NewTicker(1 * time.Second) 10 | for { 11 | c <- "ping" 12 | <-t.C 13 | } 14 | } 15 | 16 | func main() { 17 | messages := make(chan string) 18 | go pinger(messages) 19 | for { 20 | msg := <-messages 21 | fmt.Println(msg) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /hour12/example05.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "time" 4 | import "fmt" 5 | 6 | func ping1(c chan string) { 7 | time.Sleep(time.Second * 1) 8 | c <- "ping on channel1" 9 | } 10 | 11 | func ping2(c chan string) { 12 | time.Sleep(time.Second * 2) 13 | c <- "ping on channel2" 14 | } 15 | 16 | func main() { 17 | 18 | channel1 := make(chan string) 19 | channel2 := make(chan string) 20 | 21 | go ping1(channel1) 22 | go ping2(channel2) 23 | 24 | select { 25 | case msg1 := <-channel1: 26 | fmt.Println("received", msg1) 27 | case msg2 := <-channel2: 28 | fmt.Println("received", msg2) 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /hour12/example06.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "time" 4 | import "fmt" 5 | 6 | func ping1(c chan string) { 7 | time.Sleep(time.Second * 3) 8 | c <- "ping on channel1" 9 | } 10 | 11 | func ping2(c chan string) { 12 | time.Sleep(time.Second * 2) 13 | c <- "ping on channel2" 14 | } 15 | 16 | func main() { 17 | 18 | channel1 := make(chan string) 19 | channel2 := make(chan string) 20 | 21 | go ping1(channel1) 22 | go ping2(channel2) 23 | 24 | select { 25 | case msg1 := <-channel1: 26 | fmt.Println("received", msg1) 27 | case msg2 := <-channel2: 28 | fmt.Println("received", msg2) 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /hour12/example07.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "time" 4 | import "fmt" 5 | 6 | func ping1(c chan string) { 7 | time.Sleep(time.Second * 2) 8 | c <- "ping on channel one" 9 | } 10 | 11 | func ping2(c chan string) { 12 | time.Sleep(time.Second * 1) 13 | c <- "ping on channel two" 14 | } 15 | 16 | func main() { 17 | 18 | channel1 := make(chan string) 19 | channel2 := make(chan string) 20 | 21 | go ping1(channel1) 22 | go ping2(channel2) 23 | 24 | select { 25 | case msg1 := <-channel1: 26 | fmt.Println("received", msg1) 27 | case msg2 := <-channel2: 28 | fmt.Println("received", msg2) 29 | case <-time.After(500 * time.Millisecond): 30 | fmt.Println("no messages received. giving up.") 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /hour12/example08.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func sender(c chan string) { 9 | t := time.NewTicker(1 * time.Second) 10 | for { 11 | c <- "I'm sending a message" 12 | <-t.C 13 | } 14 | } 15 | 16 | func main() { 17 | messages := make(chan string) 18 | go sender(messages) 19 | 20 | for { 21 | select { 22 | case msg := <-messages: 23 | fmt.Println(msg) 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /hour12/example09.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func sender(c chan string) { 9 | t := time.NewTicker(1 * time.Second) 10 | for { 11 | c <- "I'm sending a message" 12 | <-t.C 13 | } 14 | } 15 | 16 | func main() { 17 | messages := make(chan string) 18 | stop := make(chan bool) 19 | go sender(messages) 20 | go func() { 21 | time.Sleep(time.Second * 2) 22 | fmt.Println("Time's up!") 23 | stop <- true 24 | }() 25 | 26 | for { 27 | select { 28 | case <-stop: 29 | return 30 | case msg := <-messages: 31 | fmt.Println(msg) 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /hour13/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/golang/example/stringutil" 6 | ) 7 | 8 | func main() { 9 | s := "ti esrever dna ti pilf nwod gniht ym tup I" 10 | fmt.Println(stringutil.Reverse(s)) 11 | } 12 | -------------------------------------------------------------------------------- /hour13/example02/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/golang/example/stringutil" 6 | ) 7 | 8 | func main() { 9 | s := "ti esrever dna ti pilf nwod gniht ym tup I" 10 | fmt.Println(stringutil.Reverse(s)) 11 | } 12 | -------------------------------------------------------------------------------- /hour14/example01.go: -------------------------------------------------------------------------------- 1 | package main; import "fmt"; 2 | 3 | func main() { 4 | fmt.Println("Hello World") } 5 | -------------------------------------------------------------------------------- /hour14/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | const Foo string = "constant string" 6 | 7 | func main() { 8 | fmt.Println(Foo) 9 | a_string := "hello" 10 | fmt.Println(a_string) 11 | } 12 | -------------------------------------------------------------------------------- /hour14/example03/example03.go: -------------------------------------------------------------------------------- 1 | // Package example03 shows how to use the godoc tool. 2 | package example03 3 | 4 | import ( 5 | "errors" 6 | ) 7 | 8 | // Animal specifies an animal 9 | type Animal struct { 10 | Name string // Name holds the name of an Animal. 11 | 12 | // Age holds the name of an Animal. 13 | Age int 14 | } 15 | 16 | // ErrNotAnAnimal is returned if the name field of the Animal struct is Human. 17 | var ErrNotAnAnimal = errors.New("Name is not an animal") 18 | 19 | // Hello sends a greeting to the animal. 20 | func (a Animal) Hello() (string, error) { 21 | if a.Name == "Human" { 22 | return "", ErrNotAnAnimal 23 | } 24 | s := "Hello " + a.Name 25 | return s, nil 26 | } 27 | -------------------------------------------------------------------------------- /hour14/example04/Makefile: -------------------------------------------------------------------------------- 1 | all: check-gofmt vet 2 | 3 | check-gofmt: 4 | @if [ -n "$(shell gofmt -l .)" ]; then \ 5 | echo 1>&2 'The following files need to be formatted:'; \ 6 | gofmt -l .; \ 7 | exit 1; \ 8 | fi 9 | 10 | vet: 11 | @go vet ./... 12 | 13 | lint: 14 | @golint ./... 15 | -------------------------------------------------------------------------------- /hour14/example04/example04.go: -------------------------------------------------------------------------------- 1 | package main; import "fmt"; 2 | 3 | func main() { 4 | fmt.Println("Hello World") } 5 | -------------------------------------------------------------------------------- /hour15/example01/example01.go: -------------------------------------------------------------------------------- 1 | package example01 2 | -------------------------------------------------------------------------------- /hour15/example01/example01_test.go: -------------------------------------------------------------------------------- 1 | package example01 2 | 3 | import "testing" 4 | 5 | func TestTruth(t *testing.T) { 6 | if true != true { 7 | t.Fatal("The world is crumbling") 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /hour15/example02/example02.go: -------------------------------------------------------------------------------- 1 | package example02 2 | 3 | func Greeting(s string) string { 4 | return ("Hello " + s) 5 | } 6 | -------------------------------------------------------------------------------- /hour15/example02/example02_test.go: -------------------------------------------------------------------------------- 1 | package example02 2 | 3 | import "testing" 4 | 5 | func TestGreeting(t *testing.T) { 6 | got := Greeting("George") 7 | want := "Hello George" 8 | if got != want { 9 | t.Fatalf("Expected %q, got %q", want, got) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /hour15/example03/example03.go: -------------------------------------------------------------------------------- 1 | package example03 2 | 3 | func translate(s string) string { 4 | switch s { 5 | case "en-US": 6 | return "Hello " 7 | case "fr-FR": 8 | return "Bonjour " 9 | case "it-IT": 10 | return "Ciao " 11 | default: 12 | return "Hello " 13 | } 14 | } 15 | 16 | func Greeting(name, locale string) string { 17 | salutation := translate(locale) 18 | return (salutation + name) 19 | } 20 | -------------------------------------------------------------------------------- /hour15/example03/example03_test.go: -------------------------------------------------------------------------------- 1 | package example03 2 | 3 | import "testing" 4 | 5 | func TestFrTranslation(t *testing.T) { 6 | got := translate("fr") 7 | want := "Bonjour " 8 | if got != want { 9 | t.Fatalf("Expected %q, got %q", want, got) 10 | } 11 | } 12 | 13 | func TestUSTranslation(t *testing.T) { 14 | got := Greeting("George", "en-US") 15 | want := "Hello George" 16 | if got != want { 17 | t.Fatalf("Expected %q, got %q", want, got) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /hour15/example04/example04.go: -------------------------------------------------------------------------------- 1 | package example04 2 | 3 | func translate(s string) string { 4 | switch s { 5 | case "en-US": 6 | return "Hello " 7 | case "fr-FR": 8 | return "Bonjour " 9 | case "it-IT": 10 | return "Ciao " 11 | default: 12 | return "Hello " 13 | } 14 | } 15 | 16 | func Greeting(name, locale string) string { 17 | salutation := translate(locale) 18 | return (salutation + name) 19 | } 20 | -------------------------------------------------------------------------------- /hour15/example04/example04_test.go: -------------------------------------------------------------------------------- 1 | package example04 2 | 3 | import "testing" 4 | 5 | type GreetingTest struct { 6 | name string 7 | locale string 8 | want string 9 | } 10 | 11 | var greetingTests = []GreetingTest{ 12 | {"George", "en-US", "Hello George"}, 13 | {"Chloé", "fr-FR", "Bonjour Chloé"}, 14 | {"Giuseppe", "it-IT", "Ciao Giuseppe"}, 15 | } 16 | 17 | func TestGreeting(t *testing.T) { 18 | for _, test := range greetingTests { 19 | got := Greeting(test.name, test.locale) 20 | if got != test.want { 21 | t.Errorf("Greeting(%s,%s) = %v; want %v", test.name, test.locale, got, test.want) 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /hour15/example05/example05.go: -------------------------------------------------------------------------------- 1 | package example05 2 | 3 | import ( 4 | "bytes" 5 | "strings" 6 | ) 7 | 8 | func StringFromAssignment(j int) string { 9 | var s string 10 | for i := 0; i < j; i++ { 11 | s += "a" 12 | } 13 | return s 14 | } 15 | 16 | func StringFromAppendJoin(j int) string { 17 | s := []string{} 18 | for i := 0; i < j; i++ { 19 | s = append(s, "a") 20 | } 21 | return strings.Join(s, "") 22 | } 23 | 24 | func StringFromBuffer(j int) string { 25 | var buffer bytes.Buffer 26 | for i := 0; i < j; i++ { 27 | buffer.WriteString("a") 28 | } 29 | return buffer.String() 30 | } 31 | -------------------------------------------------------------------------------- /hour15/example06/example06.go: -------------------------------------------------------------------------------- 1 | package example06 2 | 3 | func Greeting(s string) string { 4 | return ("Hello " + s) 5 | } 6 | 7 | func Farewell(s string) string { 8 | return ("Goodbye " + s) 9 | } 10 | -------------------------------------------------------------------------------- /hour15/example06/example06_test.go: -------------------------------------------------------------------------------- 1 | package example06 2 | 3 | import "testing" 4 | 5 | func TestGreeting(t *testing.T) { 6 | got := Greeting("George") 7 | want := "Hello George" 8 | if got != want { 9 | t.Fatalf("Expected %q, got %q", want, got) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /hour16/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "log" 4 | 5 | func main() { 6 | log.Printf("This is a log message") 7 | } 8 | -------------------------------------------------------------------------------- /hour16/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "errors" 5 | "log" 6 | ) 7 | 8 | func main() { 9 | var errFatal = errors.New("We only just started and we are crashing") 10 | log.Fatal(errFatal) 11 | } 12 | -------------------------------------------------------------------------------- /hour16/example03.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "os" 6 | ) 7 | 8 | func main() { 9 | f, err := os.OpenFile("example03.log", os.O_APPEND|os.O_CREATE|os.O_RDWR, 0666) 10 | if err != nil { 11 | log.Fatal(err) 12 | } 13 | 14 | defer f.Close() 15 | 16 | log.SetOutput(f) 17 | 18 | for i := 1; i <= 5; i++ { 19 | log.Printf("Log iteration %d", i) 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /hour16/example04.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | ) 6 | 7 | func main() { 8 | for i := 1; i <= 5; i++ { 9 | log.Printf("Log iteration %d", i) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /hour16/example05.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "os" 7 | "strings" 8 | ) 9 | 10 | func main() { 11 | reader := bufio.NewReader(os.Stdin) 12 | fmt.Print("Guess the name of my pet to win a prize: ") 13 | text, _ := reader.ReadString('\n') 14 | text = strings.Replace(text, "\n", "", -1) 15 | 16 | if text == "John" { 17 | fmt.Println("You won! You win chocolate!") 18 | } else { 19 | fmt.Println("You didn't win. Better luck next time") 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hour16/example06.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "fmt" 6 | "os" 7 | "strings" 8 | ) 9 | 10 | func main() { 11 | reader := bufio.NewReader(os.Stdin) 12 | fmt.Print("Guess the name of my pet to win a prize: ") 13 | text, _ := reader.ReadString('\n') 14 | text = strings.Replace(text, "\n", "", -1) 15 | fmt.Println("[DEBUG] text is:", text) 16 | 17 | if text == "John" { 18 | fmt.Println("You won! You win chocolate!") 19 | } else { 20 | fmt.Println("You didn't win. Better luck next time") 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /hour16/example07.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func main() { 8 | s := "Hello World" 9 | fmt.Printf("String is %v\n", s) 10 | } 11 | -------------------------------------------------------------------------------- /hour16/example08.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func main() { 8 | s := "Hello World" 9 | t := "Goodbye, Cruel World" 10 | fmt.Printf("s is %v, t is %v\n", s, t) 11 | } 12 | -------------------------------------------------------------------------------- /hour16/example09.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type Animal struct { 8 | Name string 9 | Color string 10 | } 11 | 12 | func main() { 13 | a := Animal{ 14 | Name: "Cat", 15 | Color: "Black", 16 | } 17 | fmt.Printf("%v\n", a) 18 | fmt.Printf("%+v\n", a) 19 | } 20 | -------------------------------------------------------------------------------- /hour16/example10.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func echo(s string) { 8 | fmt.Println(s) 9 | return 10 | } 11 | 12 | func main() { 13 | s := "Hello World" 14 | t := "Goodbye Cruel World" 15 | echo(s) 16 | echo(t) 17 | } 18 | -------------------------------------------------------------------------------- /hour17/README.md: -------------------------------------------------------------------------------- 1 | # Command Line Tools 2 | 3 | What You'll Learn in This Hour: 4 | 5 | * How To Receive Raw Arguments 6 | * How To Parse Command Line Flags 7 | * How To Customize Help Text 8 | * How To Create Subcommands 9 | 10 | -------------------------------------------------------------------------------- /hour17/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | ) 7 | 8 | func main() { 9 | for i, arg := range os.Args { 10 | fmt.Println("argument", i, "is", arg) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /hour17/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | ) 7 | 8 | func main() { 9 | s := flag.String("s", "Hello world", "String help text") 10 | flag.Parse() 11 | fmt.Println("value of s:", *s) 12 | } 13 | -------------------------------------------------------------------------------- /hour17/example03.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | ) 7 | 8 | func main() { 9 | s := flag.String("s", "Hello world", "String help text") 10 | i := flag.Int("i", 1, "Int help text") 11 | b := flag.Bool("b", false, "Bool help text") 12 | flag.Parse() 13 | fmt.Println("value of s:", *s) 14 | fmt.Println("value of i:", *i) 15 | fmt.Println("value of b:", *b) 16 | } 17 | -------------------------------------------------------------------------------- /hour17/example04.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "flag" 5 | "fmt" 6 | "os" 7 | ) 8 | 9 | func main() { 10 | flag.Usage = func() { 11 | usageText := `Usage example04 [OPTION] 12 | An example of customising usage output 13 | 14 | -s, --s example string argument, default: String help text 15 | -i, --i example integer argument, default: Int help text 16 | -b, --b example boolean argument, default: Bool help text` 17 | fmt.Fprintf(os.Stderr, "%s\n", usageText) 18 | 19 | } 20 | s := flag.String("s", "Hello world", "String help text") 21 | i := flag.Int("i", 1, "Int help text") 22 | b := flag.Bool("b", true, "Bool help text") 23 | flag.Parse() 24 | fmt.Println("value of s:", *s) 25 | fmt.Println("value of i:", *i) 26 | fmt.Println("value of b:", *b) 27 | } 28 | -------------------------------------------------------------------------------- /hour17/example07.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println("Hurray! You are a Gopher!") 7 | } 8 | -------------------------------------------------------------------------------- /hour18/README.md: -------------------------------------------------------------------------------- 1 | # HTTP Servers 2 | 3 | What You'll Learn in This Hour: 4 | 5 | * How To Create A HTTP Server 6 | * How Routing Works 7 | * How Handler Functions Work 8 | * How To Handle Different Types Of Request 9 | * How To Serve Different Types Of Content 10 | 11 | 12 | -------------------------------------------------------------------------------- /hour18/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | ) 6 | 7 | func helloWorld(w http.ResponseWriter, r *http.Request) { 8 | w.Write([]byte("Hello World\n")) 9 | } 10 | 11 | func main() { 12 | http.HandleFunc("/", helloWorld) 13 | http.ListenAndServe(":8000", nil) 14 | } 15 | -------------------------------------------------------------------------------- /hour18/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | ) 6 | 7 | func helloWorld(w http.ResponseWriter, r *http.Request) { 8 | if r.URL.Path != "/" { 9 | http.NotFound(w, r) 10 | return 11 | } 12 | w.Write([]byte("Hello World\n")) 13 | } 14 | 15 | func main() { 16 | http.HandleFunc("/", helloWorld) 17 | http.ListenAndServe(":8000", nil) 18 | } 19 | -------------------------------------------------------------------------------- /hour18/example03.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | ) 6 | 7 | func helloWorld(w http.ResponseWriter, r *http.Request) { 8 | if r.URL.Path != "/" { 9 | http.NotFound(w, r) 10 | return 11 | } 12 | w.Header().Set("Content-Type", "application/json; charset=utf-8") 13 | w.Write([]byte(`{"hello": "world"}`)) 14 | } 15 | 16 | func main() { 17 | http.HandleFunc("/", helloWorld) 18 | http.ListenAndServe(":8000", nil) 19 | } 20 | -------------------------------------------------------------------------------- /hour18/example04.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | ) 6 | 7 | func helloWorld(w http.ResponseWriter, r *http.Request) { 8 | if r.URL.Path != "/" { 9 | http.NotFound(w, r) 10 | return 11 | } 12 | switch r.Header.Get("Accept") { 13 | case "application/json": 14 | w.Header().Set("Content-Type", "application/json; charset=utf-8") 15 | w.Write([]byte(`{"message": "Hello World"}`)) 16 | case "application/xml": 17 | w.Header().Set("Content-Type", "application/xml; charset=utf-8") 18 | w.Write([]byte(`Hello World`)) 19 | default: 20 | w.Header().Set("Content-Type", "text/plain; charset=utf-8") 21 | w.Write([]byte("Hello World\n")) 22 | } 23 | 24 | } 25 | 26 | func main() { 27 | http.HandleFunc("/", helloWorld) 28 | http.ListenAndServe(":8000", nil) 29 | } 30 | -------------------------------------------------------------------------------- /hour18/example05.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "net/http" 5 | ) 6 | 7 | func helloWorld(w http.ResponseWriter, r *http.Request) { 8 | if r.URL.Path != "/" { 9 | http.NotFound(w, r) 10 | return 11 | } 12 | switch r.Method { 13 | case "GET": 14 | w.Write([]byte("Received a GET request\n")) 15 | case "POST": 16 | w.Write([]byte("Received a POST request\n")) 17 | default: 18 | w.WriteHeader(http.StatusNotImplemented) 19 | w.Write([]byte(http.StatusText(http.StatusNotImplemented) + "\n")) 20 | } 21 | 22 | } 23 | 24 | func main() { 25 | http.HandleFunc("/", helloWorld) 26 | http.ListenAndServe(":8000", nil) 27 | } 28 | -------------------------------------------------------------------------------- /hour19/README.md: -------------------------------------------------------------------------------- 1 | # Hour 19 - HTTP Clients 2 | 3 | What You'll Learn In This Hour: 4 | 5 | * How To Create A Simple Http Client 6 | * How To Make A GET Request 7 | * How To Make A POST Request 8 | * How To Have Finer Control Over HTTP Requests 9 | * How To Debug HTTP Requests 10 | * How To Deal With Timeouts 11 | -------------------------------------------------------------------------------- /hour19/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "log" 7 | "net/http" 8 | ) 9 | 10 | func main() { 11 | response, err := http.Get("https://ifconfig.co/") 12 | if err != nil { 13 | log.Fatal(err) 14 | } 15 | defer response.Body.Close() 16 | body, err := ioutil.ReadAll(response.Body) 17 | if err != nil { 18 | log.Fatal(err) 19 | } 20 | fmt.Printf("%s", body) 21 | 22 | } 23 | -------------------------------------------------------------------------------- /hour19/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "log" 7 | "net/http" 8 | "strings" 9 | ) 10 | 11 | func main() { 12 | postData := strings.NewReader(`{ "some": "json" }`) 13 | response, err := http.Post("https://httpbin.org/post", "application/json", postData) 14 | if err != nil { 15 | log.Fatal(err) 16 | } 17 | defer response.Body.Close() 18 | body, err := ioutil.ReadAll(response.Body) 19 | if err != nil { 20 | log.Fatal(err) 21 | } 22 | fmt.Printf("%s", body) 23 | 24 | } 25 | -------------------------------------------------------------------------------- /hour19/example03.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "log" 7 | "net/http" 8 | ) 9 | 10 | func main() { 11 | client := &http.Client{} 12 | request, err := http.NewRequest("GET", "https://ifconfig.co", nil) 13 | if err != nil { 14 | log.Fatal(err) 15 | } 16 | response, err := client.Do(request) 17 | if err != nil { 18 | log.Fatal(err) 19 | } 20 | defer response.Body.Close() 21 | body, err := ioutil.ReadAll(response.Body) 22 | if err != nil { 23 | log.Fatal(err) 24 | } 25 | fmt.Printf("%s", body) 26 | 27 | } 28 | -------------------------------------------------------------------------------- /hour19/example06.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "log" 7 | "net/http" 8 | "time" 9 | ) 10 | 11 | func main() { 12 | 13 | client := &http.Client{ 14 | Timeout: 50 * time.Millisecond, 15 | } 16 | request, err := http.NewRequest("GET", "https://ifconfig.co", nil) 17 | if err != nil { 18 | log.Fatal(err) 19 | } 20 | 21 | response, err := client.Do(request) 22 | if err != nil { 23 | log.Fatal(err) 24 | } 25 | defer response.Body.Close() 26 | 27 | body, err := ioutil.ReadAll(response.Body) 28 | if err != nil { 29 | log.Fatal(err) 30 | } 31 | 32 | fmt.Printf("%s", body) 33 | 34 | } 35 | -------------------------------------------------------------------------------- /hour20/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | type Person struct { 6 | Name string 7 | Age int 8 | Hobbies []string 9 | } 10 | 11 | func main() { 12 | hobbies := []string{"Cycling", "Cheese", "Techno"} 13 | p := Person{ 14 | Name: "George", 15 | Age: 40, 16 | Hobbies: hobbies, 17 | } 18 | fmt.Printf("%+v\n", p) 19 | } 20 | -------------------------------------------------------------------------------- /hour20/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "log" 7 | ) 8 | 9 | type Person struct { 10 | Name string 11 | Age int 12 | Hobbies []string 13 | } 14 | 15 | func main() { 16 | hobbies := []string{"Cycling", "Cheese", "Techno"} 17 | p := Person{ 18 | Name: "George", 19 | Age: 40, 20 | Hobbies: hobbies, 21 | } 22 | fmt.Printf("%+v\n", p) 23 | jsonByteData, err := json.Marshal(p) 24 | if err != nil { 25 | log.Fatal(err) 26 | } 27 | jsonStringData := string(jsonByteData) 28 | fmt.Println(jsonStringData) 29 | } 30 | -------------------------------------------------------------------------------- /hour20/example03.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "log" 7 | ) 8 | 9 | type Person struct { 10 | Name string `json:"name"` 11 | Age int `json:"age"` 12 | Hobbies []string `json:"hobbies"` 13 | } 14 | 15 | func main() { 16 | hobbies := []string{"Cycling", "Cheese", "Techno"} 17 | p := Person{ 18 | Name: "George", 19 | Age: 40, 20 | Hobbies: hobbies, 21 | } 22 | fmt.Printf("%+v\n", p) 23 | jsonByteData, err := json.Marshal(p) 24 | if err != nil { 25 | log.Fatal(err) 26 | } 27 | jsonStringData := string(jsonByteData) 28 | fmt.Println(jsonStringData) 29 | } 30 | -------------------------------------------------------------------------------- /hour20/example04.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "log" 7 | ) 8 | 9 | type Person struct { 10 | Name string `json:"name,omitempty"` 11 | Age int `json:"age,omitempty"` 12 | Hobbies []string `json:"hobbies,omitempty"` 13 | } 14 | 15 | func main() { 16 | p := Person{} 17 | jsonByteData, err := json.Marshal(p) 18 | if err != nil { 19 | log.Fatal(err) 20 | } 21 | jsonStringData := string(jsonByteData) 22 | fmt.Println(jsonStringData) 23 | } 24 | -------------------------------------------------------------------------------- /hour20/example05.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "log" 7 | ) 8 | 9 | type Person struct { 10 | Name string `json:"name"` 11 | Age int `json:"age"` 12 | Hobbies []string `json:"hobbies"` 13 | } 14 | 15 | func main() { 16 | jsonStringData := `{"name":"George","age":40,"hobbies":["Cycling","Cheese","Techno"]}` 17 | jsonByteData := []byte(jsonStringData) 18 | p := Person{} 19 | err := json.Unmarshal(jsonByteData, &p) 20 | if err != nil { 21 | log.Fatal(err) 22 | } 23 | fmt.Printf("%+v\n", p) 24 | } 25 | -------------------------------------------------------------------------------- /hour20/example06.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "log" 7 | ) 8 | 9 | type Switch struct { 10 | On bool `json:"on"` 11 | } 12 | 13 | func main() { 14 | jsonStringData := `{"on":"true"}` 15 | jsonByteData := []byte(jsonStringData) 16 | s := Switch{} 17 | err := json.Unmarshal(jsonByteData, &s) 18 | if err != nil { 19 | log.Fatal(err) 20 | } 21 | fmt.Printf("%+v\n", s) 22 | } 23 | -------------------------------------------------------------------------------- /hour20/example07.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "log" 7 | "net/http" 8 | ) 9 | 10 | type User struct { 11 | Name string `json:"name"` 12 | Blog string `json:"blog"` 13 | } 14 | 15 | func main() { 16 | var u User 17 | res, err := http.Get("https://api.github.com/users/shapeshed") 18 | if err != nil { 19 | log.Fatal(err) 20 | } 21 | defer res.Body.Close() 22 | err = json.NewDecoder(res.Body).Decode(&u) 23 | if err != nil { 24 | log.Fatal(err) 25 | } 26 | fmt.Printf("%+v\n", u) 27 | } 28 | -------------------------------------------------------------------------------- /hour21/.gitignore: -------------------------------------------------------------------------------- 1 | example02.txt 2 | example03.txt 3 | example05.copy.txt 4 | -------------------------------------------------------------------------------- /hour21/example01/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "log" 7 | ) 8 | 9 | func main() { 10 | fileBytes, err := ioutil.ReadFile("example01.txt") 11 | if err != nil { 12 | log.Fatal(err) 13 | } 14 | 15 | fmt.Println(fileBytes) 16 | 17 | fileString := string(fileBytes) 18 | fmt.Println(fileString) 19 | } 20 | -------------------------------------------------------------------------------- /hour21/example01/example01.txt: -------------------------------------------------------------------------------- 1 | This is a text file 2 | -------------------------------------------------------------------------------- /hour21/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "io/ioutil" 5 | "log" 6 | ) 7 | 8 | func main() { 9 | b := make([]byte, 0) 10 | err := ioutil.WriteFile("example02.txt", b, 0644) 11 | if err != nil { 12 | log.Fatal(err) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /hour21/example03.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "io/ioutil" 5 | "log" 6 | ) 7 | 8 | func main() { 9 | s := "Hello World" 10 | err := ioutil.WriteFile("example03.txt", []byte(s), 0644) 11 | if err != nil { 12 | log.Fatal(err) 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /hour21/example04.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "log" 7 | ) 8 | 9 | func main() { 10 | files, err := ioutil.ReadDir(".") 11 | if err != nil { 12 | log.Fatal(err) 13 | } 14 | 15 | for _, file := range files { 16 | fmt.Println(file.Mode(), file.Name()) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /hour21/example05/example05.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "io" 5 | "log" 6 | "os" 7 | ) 8 | 9 | func main() { 10 | from, err := os.Open("./example05.txt") 11 | if err != nil { 12 | log.Fatal(err) 13 | } 14 | defer from.Close() 15 | 16 | to, err := os.OpenFile("./example05.copy.txt", os.O_RDWR|os.O_CREATE, 0666) 17 | if err != nil { 18 | log.Fatal(err) 19 | } 20 | defer to.Close() 21 | 22 | _, err = io.Copy(to, from) 23 | if err != nil { 24 | log.Fatal(err) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /hour21/example05/example05.txt: -------------------------------------------------------------------------------- 1 | Hello world 2 | -------------------------------------------------------------------------------- /hour21/example06/deleteme.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shapeshed/golang-book-examples/d2421999e73701994706d35e1a117526b103a619/hour21/example06/deleteme.txt -------------------------------------------------------------------------------- /hour21/example06/example06.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "os" 6 | ) 7 | 8 | func main() { 9 | err := os.Remove("./deleteme.txt") 10 | if err != nil { 11 | log.Fatal(err) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /hour21/example07/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "George", 3 | "awake": true, 4 | "hungry": false 5 | } 6 | -------------------------------------------------------------------------------- /hour21/example07/example07.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "io/ioutil" 7 | "log" 8 | ) 9 | 10 | type Config struct { 11 | Name string `json:"name"` 12 | Awake bool `json:"awake"` 13 | Hungry bool `json:"hungry"` 14 | } 15 | 16 | func main() { 17 | f, err := ioutil.ReadFile("config.json") 18 | if err != nil { 19 | log.Fatal(err) 20 | } 21 | c := Config{} 22 | err = json.Unmarshal(f, &c) 23 | if err != nil { 24 | log.Fatal(err) 25 | } 26 | fmt.Printf("%+v\n", c) 27 | } 28 | -------------------------------------------------------------------------------- /hour21/example08/config.toml: -------------------------------------------------------------------------------- 1 | Name = "George" 2 | Awake = true 3 | Hungry = false 4 | -------------------------------------------------------------------------------- /hour21/example08/example08.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | 7 | "github.com/BurntSushi/toml" 8 | ) 9 | 10 | type Config struct { 11 | Name string 12 | Awake bool 13 | Hungry bool 14 | } 15 | 16 | func main() { 17 | c := Config{} 18 | _, err := toml.DecodeFile("config.toml", &c) 19 | if err != nil { 20 | log.Fatal(err) 21 | } 22 | fmt.Printf("%+v\n", c) 23 | } 24 | -------------------------------------------------------------------------------- /hour22/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "regexp" 7 | ) 8 | 9 | func main() { 10 | needle := "chocolate" 11 | haystack := "Chocolate is my favorite!" 12 | match, err := regexp.MatchString(needle, haystack) 13 | if err != nil { 14 | log.Fatal(err) 15 | } 16 | fmt.Println(match) 17 | } 18 | -------------------------------------------------------------------------------- /hour22/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "regexp" 7 | ) 8 | 9 | func main() { 10 | needle := "(?i)chocolate" 11 | haystack := "Chocolate is my favorite!" 12 | match, err := regexp.MatchString(needle, haystack) 13 | if err != nil { 14 | log.Fatal(err) 15 | } 16 | fmt.Println(match) 17 | } 18 | -------------------------------------------------------------------------------- /hour22/example03.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "regexp" 6 | ) 7 | 8 | func main() { 9 | re := regexp.MustCompile("^[a-zA-Z0-9]{5,12}") 10 | fmt.Println(re.MatchString("slimshady99")) 11 | fmt.Println(re.MatchString("!asdf£33£3")) 12 | fmt.Println(re.MatchString("roger")) 13 | fmt.Println(re.MatchString("iamthebestuserofthisappevaaaar")) 14 | } 15 | -------------------------------------------------------------------------------- /hour22/example04.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "regexp" 6 | ) 7 | 8 | func main() { 9 | usernames := [4]string{ 10 | "slimshady99", 11 | "!asdf£33£3", 12 | "roger", 13 | "Iamthebestuserofthisappevaaaar", 14 | } 15 | 16 | re := regexp.MustCompile("^[a-zA-Z0-9]{5,12}") 17 | an := regexp.MustCompile("[[:^alnum:]]") 18 | 19 | for _, username := range usernames { 20 | if len(username) > 12 { 21 | username = username[:12] 22 | fmt.Printf("trimmed username to %v\n", username) 23 | } 24 | if !re.MatchString(username) { 25 | username = an.ReplaceAllString(username, "x") 26 | fmt.Printf("rewrote username to %v\n", username) 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /hour22/example05.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "log" 7 | "net/http" 8 | "regexp" 9 | ) 10 | 11 | func main() { 12 | resp, err := http.Get("https://petition.parliament.uk/petitions") 13 | if err != nil { 14 | log.Fatal(err) 15 | } 16 | defer resp.Body.Close() 17 | body, err := ioutil.ReadAll(resp.Body) 18 | if err != nil { 19 | log.Fatal(err) 20 | } 21 | 22 | src := string(body) 23 | 24 | re := regexp.MustCompile("\\.*\\") 25 | titles := re.FindAllString(src, -1) 26 | 27 | for _, title := range titles { 28 | fmt.Println(title) 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /hour22/example06.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | "log" 7 | "net/http" 8 | "regexp" 9 | ) 10 | 11 | func main() { 12 | resp, err := http.Get("https://petition.parliament.uk/petitions") 13 | if err != nil { 14 | log.Fatal(err) 15 | } 16 | defer resp.Body.Close() 17 | body, err := ioutil.ReadAll(resp.Body) 18 | if err != nil { 19 | log.Fatal(err) 20 | } 21 | 22 | src := string(body) 23 | 24 | re := regexp.MustCompile("\\.*\\") 25 | rHTML := regexp.MustCompile("<[^>]*>") 26 | titles := re.FindAllString(src, -1) 27 | 28 | for _, title := range titles { 29 | cleanTitle := rHTML.ReplaceAllString(title, "") 30 | fmt.Println(cleanTitle) 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /hour23/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | fmt.Println(time.Now()) 10 | } 11 | -------------------------------------------------------------------------------- /hour23/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | time.Sleep(3 * time.Second) 10 | fmt.Println("I'm awake") 11 | } 12 | -------------------------------------------------------------------------------- /hour23/example03.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | fmt.Println("You have two seconds to calculate 19 * 4") 10 | for { 11 | select { 12 | case <-time.After(2 * time.Second): 13 | fmt.Println("Time's up! The answer is 74. Did you get it?") 14 | return 15 | } 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /hour23/example04.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | func main() { 9 | c := time.Tick(5 * time.Second) 10 | for t := range c { 11 | fmt.Printf("The time is now %v\n", t) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /hour23/example05.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "time" 7 | ) 8 | 9 | func main() { 10 | s := "2006-01-02T15:04:05+07:00" 11 | t, err := time.Parse(time.RFC3339, s) 12 | if err != nil { 13 | log.Fatal(err) 14 | } 15 | fmt.Println(t) 16 | } 17 | -------------------------------------------------------------------------------- /hour23/example06.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "time" 7 | ) 8 | 9 | func main() { 10 | s := "2006-01-02T15:04:05+07:00" 11 | t, err := time.Parse(time.RFC3339, s) 12 | if err != nil { 13 | log.Fatal(err) 14 | } 15 | fmt.Printf("The hour is %v\n", t.Hour()) 16 | fmt.Printf("The minute is %v\n", t.Minute()) 17 | fmt.Printf("The second is %v\n", t.Second()) 18 | fmt.Printf("The day is %v\n", t.Day()) 19 | fmt.Printf("The month is %v\n", t.Month()) 20 | fmt.Printf("UNIX time is %v\n", t.Unix()) 21 | fmt.Printf("The day of the week is %v\n", t.Weekday()) 22 | } 23 | -------------------------------------------------------------------------------- /hour23/example07.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "time" 7 | ) 8 | 9 | func main() { 10 | s1 := "2017-09-03T18:00:00+00:00" 11 | s2 := "2017-09-04T18:00:00+00:00" 12 | today, err := time.Parse(time.RFC3339, s1) 13 | if err != nil { 14 | log.Fatal(err) 15 | } 16 | tomorrow, err := time.Parse(time.RFC3339, s2) 17 | if err != nil { 18 | log.Fatal(err) 19 | } 20 | fmt.Println(today.After(tomorrow)) 21 | fmt.Println(today.Before(tomorrow)) 22 | fmt.Println(today.Equal(tomorrow)) 23 | } 24 | -------------------------------------------------------------------------------- /hour24/.gitignore: -------------------------------------------------------------------------------- 1 | example01 2 | example01.exe 3 | example03 4 | example04 5 | -------------------------------------------------------------------------------- /hour24/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println("Hello world!") 7 | } 8 | -------------------------------------------------------------------------------- /hour24/example02/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM golang:1.9 2 | COPY example02.go / 3 | RUN go build -o /example02 /example02.go 4 | EXPOSE 8000 5 | ENTRYPOINT ["/example02"] 6 | 7 | -------------------------------------------------------------------------------- /hour24/example02/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "net/http" 4 | 5 | func helloWorld(w http.ResponseWriter, r *http.Request) { 6 | w.Write([]byte("Hello World.\n")) 7 | } 8 | 9 | func main() { 10 | http.HandleFunc("/", helloWorld) 11 | http.ListenAndServe(":8000", nil) 12 | } 13 | -------------------------------------------------------------------------------- /hour24/example03.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println("Hello world!") 7 | } 8 | -------------------------------------------------------------------------------- /hour24/example04.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "fmt" 4 | 5 | func main() { 6 | fmt.Println("Hello world!") 7 | fmt.Println("I am a hacker. I am going to delete everything.") 8 | } 9 | -------------------------------------------------------------------------------- /hour25/example01/Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [solve-meta] 5 | analyzer-name = "dep" 6 | analyzer-version = 1 7 | inputs-digest = "ab4fef131ee828e96ba67d31a7d690bd5f2f42040c6766b1b12fe856f87e0ff7" 8 | solver-name = "gps-cdcl" 9 | solver-version = 1 10 | -------------------------------------------------------------------------------- /hour25/example01/Gopkg.toml: -------------------------------------------------------------------------------- 1 | 2 | # Gopkg.toml example 3 | # 4 | # Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md 5 | # for detailed Gopkg.toml documentation. 6 | # 7 | # required = ["github.com/user/thing/cmd/thing"] 8 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 9 | # 10 | # [[constraint]] 11 | # name = "github.com/user/project" 12 | # version = "1.0.0" 13 | # 14 | # [[constraint]] 15 | # name = "github.com/user/project2" 16 | # branch = "dev" 17 | # source = "github.com/myfork/project2" 18 | # 19 | # [[override]] 20 | # name = "github.com/x/y" 21 | # version = "2.4.0" 22 | 23 | -------------------------------------------------------------------------------- /hour25/example02/Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [solve-meta] 5 | analyzer-name = "dep" 6 | analyzer-version = 1 7 | inputs-digest = "ab4fef131ee828e96ba67d31a7d690bd5f2f42040c6766b1b12fe856f87e0ff7" 8 | solver-name = "gps-cdcl" 9 | solver-version = 1 10 | -------------------------------------------------------------------------------- /hour25/example02/Gopkg.toml: -------------------------------------------------------------------------------- 1 | 2 | # Gopkg.toml example 3 | # 4 | # Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md 5 | # for detailed Gopkg.toml documentation. 6 | # 7 | # required = ["github.com/user/thing/cmd/thing"] 8 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 9 | # 10 | # [[constraint]] 11 | # name = "github.com/user/project" 12 | # version = "1.0.0" 13 | # 14 | # [[constraint]] 15 | # name = "github.com/user/project2" 16 | # branch = "dev" 17 | # source = "github.com/myfork/project2" 18 | # 19 | # [[override]] 20 | # name = "github.com/x/y" 21 | # version = "2.4.0" 22 | 23 | -------------------------------------------------------------------------------- /hour25/example02/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "github.com/julienschmidt/httprouter" 6 | "log" 7 | "net/http" 8 | ) 9 | 10 | func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { 11 | fmt.Fprint(w, "Welcome!\n") 12 | } 13 | 14 | func Hello(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { 15 | fmt.Fprintf(w, "hello, %s!\n", ps.ByName("name")) 16 | } 17 | 18 | func main() { 19 | router := httprouter.New() 20 | router.GET("/", Index) 21 | router.GET("/hello/:name", Hello) 22 | 23 | log.Fatal(http.ListenAndServe(":8080", router)) 24 | } 25 | -------------------------------------------------------------------------------- /hour25/example03/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/julienschmidt/httprouter" 6 | packages = ["."] 7 | revision = "8c199fb6259ffc1af525cc3ad52ee60ba8359669" 8 | version = "v1.1" 9 | 10 | [solve-meta] 11 | analyzer-name = "dep" 12 | analyzer-version = 1 13 | inputs-digest = "4368a84c877fb4752452ba91aaadffeab050a12dac9f66e08b2196102e7903f5" 14 | solver-name = "gps-cdcl" 15 | solver-version = 1 16 | -------------------------------------------------------------------------------- /hour25/example03/Gopkg.toml: -------------------------------------------------------------------------------- 1 | 2 | # Gopkg.toml example 3 | # 4 | # Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md 5 | # for detailed Gopkg.toml documentation. 6 | # 7 | # required = ["github.com/user/thing/cmd/thing"] 8 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 9 | # 10 | # [[constraint]] 11 | # name = "github.com/user/project" 12 | # version = "1.0.0" 13 | # 14 | # [[constraint]] 15 | # name = "github.com/user/project2" 16 | # branch = "dev" 17 | # source = "github.com/myfork/project2" 18 | # 19 | # [[override]] 20 | # name = "github.com/x/y" 21 | # version = "2.4.0" 22 | 23 | -------------------------------------------------------------------------------- /hour25/example03/vendor/github.com/julienschmidt/httprouter/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | go: 4 | - 1.1 5 | - 1.2 6 | - 1.3 7 | - 1.4 8 | - tip 9 | -------------------------------------------------------------------------------- /hour25/example04/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/julienschmidt/httprouter" 6 | packages = ["."] 7 | revision = "8c199fb6259ffc1af525cc3ad52ee60ba8359669" 8 | version = "v1.1" 9 | 10 | [solve-meta] 11 | analyzer-name = "dep" 12 | analyzer-version = 1 13 | inputs-digest = "4368a84c877fb4752452ba91aaadffeab050a12dac9f66e08b2196102e7903f5" 14 | solver-name = "gps-cdcl" 15 | solver-version = 1 16 | -------------------------------------------------------------------------------- /hour25/example04/Gopkg.toml: -------------------------------------------------------------------------------- 1 | 2 | # Gopkg.toml example 3 | # 4 | # Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md 5 | # for detailed Gopkg.toml documentation. 6 | # 7 | # required = ["github.com/user/thing/cmd/thing"] 8 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 9 | # 10 | # [[constraint]] 11 | # name = "github.com/user/project" 12 | # version = "1.0.0" 13 | # 14 | # [[constraint]] 15 | # name = "github.com/user/project2" 16 | # branch = "dev" 17 | # source = "github.com/myfork/project2" 18 | # 19 | # [[override]] 20 | # name = "github.com/x/y" 21 | # version = "2.4.0" 22 | 23 | -------------------------------------------------------------------------------- /hour25/example04/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/julienschmidt/httprouter" 5 | "net/http" 6 | "net/http/httptest" 7 | "testing" 8 | ) 9 | 10 | func TestListTasksHandler(t *testing.T) { 11 | router := httprouter.New() 12 | router.GET("/", ListTasks) 13 | r, _ := http.NewRequest("GET", "/", nil) 14 | w := httptest.NewRecorder() 15 | router.ServeHTTP(w, r) 16 | 17 | expectedContentTypeHeader := "application/json; charset=utf-8" 18 | if w.Header().Get("Content-Type") != expectedContentTypeHeader { 19 | t.Errorf("handler returned unexpected Content-Type header: got %v want %v", 20 | w.Header().Get("Content-Type"), expectedContentTypeHeader) 21 | } 22 | 23 | expectedCode := http.StatusOK 24 | if w.Code != expectedCode { 25 | t.Errorf("handler returned unexpected status code: got %v want %v", 26 | w.Code, expectedCode) 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /hour25/example04/vendor/github.com/julienschmidt/httprouter/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | go: 4 | - 1.1 5 | - 1.2 6 | - 1.3 7 | - 1.4 8 | - tip 9 | -------------------------------------------------------------------------------- /hour25/example05/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/julienschmidt/httprouter" 6 | packages = ["."] 7 | revision = "8c199fb6259ffc1af525cc3ad52ee60ba8359669" 8 | version = "v1.1" 9 | 10 | [solve-meta] 11 | analyzer-name = "dep" 12 | analyzer-version = 1 13 | inputs-digest = "4368a84c877fb4752452ba91aaadffeab050a12dac9f66e08b2196102e7903f5" 14 | solver-name = "gps-cdcl" 15 | solver-version = 1 16 | -------------------------------------------------------------------------------- /hour25/example05/Gopkg.toml: -------------------------------------------------------------------------------- 1 | 2 | # Gopkg.toml example 3 | # 4 | # Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md 5 | # for detailed Gopkg.toml documentation. 6 | # 7 | # required = ["github.com/user/thing/cmd/thing"] 8 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 9 | # 10 | # [[constraint]] 11 | # name = "github.com/user/project" 12 | # version = "1.0.0" 13 | # 14 | # [[constraint]] 15 | # name = "github.com/user/project2" 16 | # branch = "dev" 17 | # source = "github.com/myfork/project2" 18 | # 19 | # [[override]] 20 | # name = "github.com/x/y" 21 | # version = "2.4.0" 22 | 23 | -------------------------------------------------------------------------------- /hour25/example05/vendor/github.com/julienschmidt/httprouter/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | go: 4 | - 1.1 5 | - 1.2 6 | - 1.3 7 | - 1.4 8 | - tip 9 | -------------------------------------------------------------------------------- /hour25/example06/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/boltdb/bolt" 6 | packages = ["."] 7 | revision = "2f1ce7a837dcb8da3ec595b1dac9d0632f0f99e8" 8 | version = "v1.3.1" 9 | 10 | [[projects]] 11 | name = "github.com/julienschmidt/httprouter" 12 | packages = ["."] 13 | revision = "8c199fb6259ffc1af525cc3ad52ee60ba8359669" 14 | version = "v1.1" 15 | 16 | [[projects]] 17 | branch = "master" 18 | name = "golang.org/x/sys" 19 | packages = ["unix"] 20 | revision = "4b45465282a4624cf39876842a017334f13b8aff" 21 | 22 | [solve-meta] 23 | analyzer-name = "dep" 24 | analyzer-version = 1 25 | inputs-digest = "32617917312e5eae653202672f12c27eb44e0a68fb710949aceb9b3b25995283" 26 | solver-name = "gps-cdcl" 27 | solver-version = 1 28 | -------------------------------------------------------------------------------- /hour25/example06/Gopkg.toml: -------------------------------------------------------------------------------- 1 | 2 | # Gopkg.toml example 3 | # 4 | # Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md 5 | # for detailed Gopkg.toml documentation. 6 | # 7 | # required = ["github.com/user/thing/cmd/thing"] 8 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 9 | # 10 | # [[constraint]] 11 | # name = "github.com/user/project" 12 | # version = "1.0.0" 13 | # 14 | # [[constraint]] 15 | # name = "github.com/user/project2" 16 | # branch = "dev" 17 | # source = "github.com/myfork/project2" 18 | # 19 | # [[override]] 20 | # name = "github.com/x/y" 21 | # version = "2.4.0" 22 | 23 | -------------------------------------------------------------------------------- /hour25/example06/task.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Task struct { 4 | Id int `json:"id"` 5 | Title string `json:"title"` 6 | } 7 | -------------------------------------------------------------------------------- /hour25/example06/tasks.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shapeshed/golang-book-examples/d2421999e73701994706d35e1a117526b103a619/hour25/example06/tasks.db -------------------------------------------------------------------------------- /hour25/example06/vendor/github.com/boltdb/bolt/.gitignore: -------------------------------------------------------------------------------- 1 | *.prof 2 | *.test 3 | *.swp 4 | /bin/ 5 | -------------------------------------------------------------------------------- /hour25/example06/vendor/github.com/boltdb/bolt/Makefile: -------------------------------------------------------------------------------- 1 | BRANCH=`git rev-parse --abbrev-ref HEAD` 2 | COMMIT=`git rev-parse --short HEAD` 3 | GOLDFLAGS="-X main.branch $(BRANCH) -X main.commit $(COMMIT)" 4 | 5 | default: build 6 | 7 | race: 8 | @go test -v -race -test.run="TestSimulate_(100op|1000op)" 9 | 10 | # go get github.com/kisielk/errcheck 11 | errcheck: 12 | @errcheck -ignorepkg=bytes -ignore=os:Remove github.com/boltdb/bolt 13 | 14 | test: 15 | @go test -v -cover . 16 | @go test -v ./cmd/bolt 17 | 18 | .PHONY: fmt test 19 | -------------------------------------------------------------------------------- /hour25/example06/vendor/github.com/boltdb/bolt/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: "{build}" 2 | 3 | os: Windows Server 2012 R2 4 | 5 | clone_folder: c:\gopath\src\github.com\boltdb\bolt 6 | 7 | environment: 8 | GOPATH: c:\gopath 9 | 10 | install: 11 | - echo %PATH% 12 | - echo %GOPATH% 13 | - go version 14 | - go env 15 | - go get -v -t ./... 16 | 17 | build_script: 18 | - go test -v ./... 19 | -------------------------------------------------------------------------------- /hour25/example06/vendor/github.com/boltdb/bolt/bolt_386.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | // maxMapSize represents the largest mmap size supported by Bolt. 4 | const maxMapSize = 0x7FFFFFFF // 2GB 5 | 6 | // maxAllocSize is the size used when creating array pointers. 7 | const maxAllocSize = 0xFFFFFFF 8 | 9 | // Are unaligned load/stores broken on this arch? 10 | var brokenUnaligned = false 11 | -------------------------------------------------------------------------------- /hour25/example06/vendor/github.com/boltdb/bolt/bolt_amd64.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | // maxMapSize represents the largest mmap size supported by Bolt. 4 | const maxMapSize = 0xFFFFFFFFFFFF // 256TB 5 | 6 | // maxAllocSize is the size used when creating array pointers. 7 | const maxAllocSize = 0x7FFFFFFF 8 | 9 | // Are unaligned load/stores broken on this arch? 10 | var brokenUnaligned = false 11 | -------------------------------------------------------------------------------- /hour25/example06/vendor/github.com/boltdb/bolt/bolt_arm64.go: -------------------------------------------------------------------------------- 1 | // +build arm64 2 | 3 | package bolt 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0xFFFFFFFFFFFF // 256TB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0x7FFFFFFF 10 | 11 | // Are unaligned load/stores broken on this arch? 12 | var brokenUnaligned = false 13 | -------------------------------------------------------------------------------- /hour25/example06/vendor/github.com/boltdb/bolt/bolt_linux.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | // fdatasync flushes written data to a file descriptor. 8 | func fdatasync(db *DB) error { 9 | return syscall.Fdatasync(int(db.file.Fd())) 10 | } 11 | -------------------------------------------------------------------------------- /hour25/example06/vendor/github.com/boltdb/bolt/bolt_openbsd.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | const ( 9 | msAsync = 1 << iota // perform asynchronous writes 10 | msSync // perform synchronous writes 11 | msInvalidate // invalidate cached data 12 | ) 13 | 14 | func msync(db *DB) error { 15 | _, _, errno := syscall.Syscall(syscall.SYS_MSYNC, uintptr(unsafe.Pointer(db.data)), uintptr(db.datasz), msInvalidate) 16 | if errno != 0 { 17 | return errno 18 | } 19 | return nil 20 | } 21 | 22 | func fdatasync(db *DB) error { 23 | if db.data != nil { 24 | return msync(db) 25 | } 26 | return db.file.Sync() 27 | } 28 | -------------------------------------------------------------------------------- /hour25/example06/vendor/github.com/boltdb/bolt/bolt_ppc.go: -------------------------------------------------------------------------------- 1 | // +build ppc 2 | 3 | package bolt 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0x7FFFFFFF // 2GB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0xFFFFFFF 10 | -------------------------------------------------------------------------------- /hour25/example06/vendor/github.com/boltdb/bolt/bolt_ppc64.go: -------------------------------------------------------------------------------- 1 | // +build ppc64 2 | 3 | package bolt 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0xFFFFFFFFFFFF // 256TB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0x7FFFFFFF 10 | 11 | // Are unaligned load/stores broken on this arch? 12 | var brokenUnaligned = false 13 | -------------------------------------------------------------------------------- /hour25/example06/vendor/github.com/boltdb/bolt/bolt_ppc64le.go: -------------------------------------------------------------------------------- 1 | // +build ppc64le 2 | 3 | package bolt 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0xFFFFFFFFFFFF // 256TB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0x7FFFFFFF 10 | 11 | // Are unaligned load/stores broken on this arch? 12 | var brokenUnaligned = false 13 | -------------------------------------------------------------------------------- /hour25/example06/vendor/github.com/boltdb/bolt/bolt_s390x.go: -------------------------------------------------------------------------------- 1 | // +build s390x 2 | 3 | package bolt 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0xFFFFFFFFFFFF // 256TB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0x7FFFFFFF 10 | 11 | // Are unaligned load/stores broken on this arch? 12 | var brokenUnaligned = false 13 | -------------------------------------------------------------------------------- /hour25/example06/vendor/github.com/boltdb/bolt/boltsync_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows,!plan9,!linux,!openbsd 2 | 3 | package bolt 4 | 5 | // fdatasync flushes written data to a file descriptor. 6 | func fdatasync(db *DB) error { 7 | return db.file.Sync() 8 | } 9 | -------------------------------------------------------------------------------- /hour25/example06/vendor/github.com/julienschmidt/httprouter/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | go: 4 | - 1.1 5 | - 1.2 6 | - 1.3 7 | - 1.4 8 | - tip 9 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/.gitattributes: -------------------------------------------------------------------------------- 1 | # Treat all files in this repo as binary, with no git magic updating 2 | # line endings. Windows users contributing to Go will need to use a 3 | # modern version of git and editors capable of LF line endings. 4 | # 5 | # We'll prevent accidental CRLF line endings from entering the repo 6 | # via the git-review gofmt checks. 7 | # 8 | # See golang.org/issue/9281 9 | 10 | * -text 11 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/.gitignore: -------------------------------------------------------------------------------- 1 | # Add no patterns to .hgignore except for files generated by the build. 2 | last-change 3 | -------------------------------------------------------------------------------- /hour25/example06/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 | -------------------------------------------------------------------------------- /hour25/example06/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 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/README.md: -------------------------------------------------------------------------------- 1 | # sys 2 | 3 | This repository holds supplemental Go packages for low-level interactions with 4 | the operating system. 5 | 6 | ## Download/Install 7 | 8 | The easiest way to install is to run `go get -u golang.org/x/sys`. You can 9 | also manually git clone the repository to `$GOPATH/src/golang.org/x/sys`. 10 | 11 | ## Report Issues / Send Patches 12 | 13 | This repository uses Gerrit for code changes. To learn how to submit changes to 14 | this repository, see https://golang.org/doc/contribute.html. 15 | 16 | The main issue tracker for the sys repository is located at 17 | https://github.com/golang/go/issues. Prefix your issue with "x/sys:" in the 18 | subject line, so it is easy to find. 19 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/codereview.cfg: -------------------------------------------------------------------------------- 1 | issuerepo: golang/go 2 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/plan9/asm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | #include "textflag.h" 6 | 7 | TEXT ·use(SB),NOSPLIT,$0 8 | RET 9 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/plan9/asm_plan9_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 | #include "textflag.h" 6 | 7 | // 8 | // System call support for 386, Plan 9 9 | // 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-32 15 | JMP syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-44 18 | JMP syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 21 | JMP syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 24 | JMP syscall·RawSyscall6(SB) 25 | 26 | TEXT ·seek(SB),NOSPLIT,$0-36 27 | JMP syscall·seek(SB) 28 | 29 | TEXT ·exit(SB),NOSPLIT,$4-4 30 | JMP syscall·exit(SB) 31 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/plan9/asm_plan9_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 | #include "textflag.h" 6 | 7 | // 8 | // System call support for amd64, Plan 9 9 | // 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-64 15 | JMP syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 18 | JMP syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 21 | JMP syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | JMP syscall·RawSyscall6(SB) 25 | 26 | TEXT ·seek(SB),NOSPLIT,$0-56 27 | JMP syscall·seek(SB) 28 | 29 | TEXT ·exit(SB),NOSPLIT,$8-8 30 | JMP syscall·exit(SB) 31 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/plan9/env_plan9.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 | // Plan 9 environment variables. 6 | 7 | package plan9 8 | 9 | import ( 10 | "syscall" 11 | ) 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/plan9/env_unset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.4 6 | 7 | package plan9 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/plan9/mksysnum_plan9.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | 6 | COMMAND="mksysnum_plan9.sh $@" 7 | 8 | cat <= 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 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/.gitignore: -------------------------------------------------------------------------------- 1 | _obj/ 2 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-64 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-112 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-64 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-88 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 29 | JMP syscall·gettimeofday(SB) 30 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | B syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | B syscall·RawSyscall6(SB) 27 | 28 | TEXT ·seek(SB),NOSPLIT,$0-32 29 | B syscall·seek(SB) 30 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 21 | B syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | B syscall·RawSyscall6(SB) 25 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | JMP syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | JMP syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/asm_linux_mipsx.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips mipsle 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-28 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 25 | JMP syscall·Syscall9(SB) 26 | 27 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 28 | JMP syscall·RawSyscall(SB) 29 | 30 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 31 | JMP syscall·RawSyscall6(SB) 32 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/asm_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/asm_openbsd_arm.s: -------------------------------------------------------------------------------- 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 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example06/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 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /hour25/example06/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 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/endian_little.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le 6 | 7 | package unix 8 | 9 | const isBigEndian = false 10 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/env_unset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.4 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/export_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | var Itoa = itoa 10 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/flock.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 12 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 13 | var fcntl64Syscall uintptr = SYS_FCNTL 14 | 15 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 16 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 17 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 18 | if errno == 0 { 19 | return nil 20 | } 21 | return errno 22 | } 23 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm linux,mips linux,mipsle 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /hour25/example06/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 | -------------------------------------------------------------------------------- /hour25/example06/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 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 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/race.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 darwin,race linux,race freebsd,race 6 | 7 | package unix 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /hour25/example06/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 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 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/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 darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + uitoa(uint(-val)) 12 | } 13 | return uitoa(uint(val)) 14 | } 15 | 16 | func uitoa(val uint) string { 17 | var buf [32]byte // big enough for int64 18 | i := len(buf) - 1 19 | for val >= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /hour25/example06/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 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/syscall_no_getwd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build dragonfly freebsd netbsd openbsd 6 | 7 | package unix 8 | 9 | const ImplementsGetwd = false 10 | 11 | func Getwd() (string, error) { return "", ENOTSUP } 12 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func (iov *Iovec) SetLen(length int) { 18 | iov.Len = uint64(length) 19 | } 20 | 21 | func (cmsg *Cmsghdr) SetLen(length int) { 22 | cmsg.Len = uint32(length) 23 | } 24 | 25 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 26 | // TODO(aram): implement this, see issue 5847. 27 | panic("unimplemented") 28 | } 29 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/syscall_unix_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | // TODO(aram): remove these before Go 1.3. 10 | const ( 11 | SYS_EXECVE = 59 12 | SYS_FCNTL = 62 13 | ) 14 | -------------------------------------------------------------------------------- /hour25/example06/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-8 10 | JMP syscall·getprocaddress(SB) 11 | 12 | TEXT ·loadlibrary(SB), 7, $0-4 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /hour25/example06/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-8 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/windows/env_unset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | // +build go1.4 7 | 8 | package windows 9 | 10 | import "syscall" 11 | 12 | func Unsetenv(key string) error { 13 | // This was added in Go 1.4. 14 | return syscall.Unsetenv(key) 15 | } 16 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/windows/env_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Windows environment variables. 6 | 7 | package windows 8 | 9 | import "syscall" 10 | 11 | func Getenv(key string) (value string, found bool) { 12 | return syscall.Getenv(key) 13 | } 14 | 15 | func Setenv(key, value string) error { 16 | return syscall.Setenv(key, value) 17 | } 18 | 19 | func Clearenv() { 20 | syscall.Clearenv() 21 | } 22 | 23 | func Environ() []string { 24 | return syscall.Environ() 25 | } 26 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/windows/memory_windows.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 | package windows 6 | 7 | const ( 8 | MEM_COMMIT = 0x00001000 9 | MEM_RESERVE = 0x00002000 10 | MEM_DECOMMIT = 0x00004000 11 | MEM_RELEASE = 0x00008000 12 | MEM_RESET = 0x00080000 13 | MEM_TOP_DOWN = 0x00100000 14 | MEM_WRITE_WATCH = 0x00200000 15 | MEM_PHYSICAL = 0x00400000 16 | MEM_RESET_UNDO = 0x01000000 17 | MEM_LARGE_PAGES = 0x20000000 18 | 19 | PAGE_NOACCESS = 0x01 20 | PAGE_READONLY = 0x02 21 | PAGE_READWRITE = 0x04 22 | PAGE_WRITECOPY = 0x08 23 | PAGE_EXECUTE_READ = 0x20 24 | PAGE_EXECUTE_READWRITE = 0x40 25 | PAGE_EXECUTE_WRITECOPY = 0x80 26 | ) 27 | -------------------------------------------------------------------------------- /hour25/example06/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 | package windows 6 | 7 | //go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go eventlog.go service.go syscall_windows.go security_windows.go 8 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/windows/race.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 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /hour25/example06/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 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/windows/registry/export_test.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 windows 6 | 7 | package registry 8 | 9 | func (k Key) SetValue(name string, valtype uint32, data []byte) error { 10 | return k.setValue(name, valtype, data) 11 | } 12 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/windows/registry/mksyscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package registry 6 | 7 | //go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go syscall.go 8 | -------------------------------------------------------------------------------- /hour25/example06/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 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/windows/svc/example/beep.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 6 | 7 | package main 8 | 9 | import ( 10 | "syscall" 11 | ) 12 | 13 | // BUG(brainman): MessageBeep Windows api is broken on Windows 7, 14 | // so this example does not beep when runs as service on Windows 7. 15 | 16 | var ( 17 | beepFunc = syscall.MustLoadDLL("user32.dll").MustFindProc("MessageBeep") 18 | ) 19 | 20 | func beep() { 21 | beepFunc.Call(0xffffffff) 22 | } 23 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/windows/svc/go12.c: -------------------------------------------------------------------------------- 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 6 | // +build !go1.3 7 | 8 | // copied from pkg/runtime 9 | typedef unsigned int uint32; 10 | typedef unsigned long long int uint64; 11 | #ifdef _64BIT 12 | typedef uint64 uintptr; 13 | #else 14 | typedef uint32 uintptr; 15 | #endif 16 | 17 | // from sys_386.s or sys_amd64.s 18 | void ·servicemain(void); 19 | 20 | void 21 | ·getServiceMain(uintptr *r) 22 | { 23 | *r = (uintptr)·servicemain; 24 | } 25 | -------------------------------------------------------------------------------- /hour25/example06/vendor/golang.org/x/sys/windows/svc/go12.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 windows 6 | // +build !go1.3 7 | 8 | package svc 9 | 10 | // from go12.c 11 | func getServiceMain(r *uintptr) 12 | -------------------------------------------------------------------------------- /hour25/example06/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 | -------------------------------------------------------------------------------- /hour25/example06/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 | -------------------------------------------------------------------------------- /hour25/example07/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/boltdb/bolt" 6 | packages = ["."] 7 | revision = "2f1ce7a837dcb8da3ec595b1dac9d0632f0f99e8" 8 | version = "v1.3.1" 9 | 10 | [[projects]] 11 | name = "github.com/julienschmidt/httprouter" 12 | packages = ["."] 13 | revision = "8c199fb6259ffc1af525cc3ad52ee60ba8359669" 14 | version = "v1.1" 15 | 16 | [[projects]] 17 | branch = "master" 18 | name = "golang.org/x/sys" 19 | packages = ["unix"] 20 | revision = "8eb05f94d449fdf134ec24630ce69ada5b469c1c" 21 | 22 | [solve-meta] 23 | analyzer-name = "dep" 24 | analyzer-version = 1 25 | inputs-digest = "2447f8761bbf2e22c42b0a87e8f6c6e9cb55b9e2af2d0f4a644cd625769c35de" 26 | solver-name = "gps-cdcl" 27 | solver-version = 1 28 | -------------------------------------------------------------------------------- /hour25/example07/Gopkg.toml: -------------------------------------------------------------------------------- 1 | 2 | # Gopkg.toml example 3 | # 4 | # Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md 5 | # for detailed Gopkg.toml documentation. 6 | # 7 | # required = ["github.com/user/thing/cmd/thing"] 8 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 9 | # 10 | # [[constraint]] 11 | # name = "github.com/user/project" 12 | # version = "1.0.0" 13 | # 14 | # [[constraint]] 15 | # name = "github.com/user/project2" 16 | # branch = "dev" 17 | # source = "github.com/myfork/project2" 18 | # 19 | # [[override]] 20 | # name = "github.com/x/y" 21 | # version = "2.4.0" 22 | 23 | 24 | [[constraint]] 25 | name = "github.com/julienschmidt/httprouter" 26 | version = "1.1.0" 27 | 28 | [[constraint]] 29 | name = "github.com/boltdb/bolt" 30 | version = "1.3.1" 31 | -------------------------------------------------------------------------------- /hour25/example07/Makefile: -------------------------------------------------------------------------------- 1 | .DEFAULT_GOAL := test 2 | GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*") 3 | SHELL=/bin/bash 4 | 5 | test: 6 | @go test ${GOFILES_NOVENDOR} 7 | 8 | 9 | -------------------------------------------------------------------------------- /hour25/example07/task.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | type Task struct { 4 | Id int `json:"id"` 5 | Title string `json:"title"` 6 | } 7 | -------------------------------------------------------------------------------- /hour25/example07/tasks.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shapeshed/golang-book-examples/d2421999e73701994706d35e1a117526b103a619/hour25/example07/tasks.db -------------------------------------------------------------------------------- /hour25/example07/vendor/github.com/boltdb/bolt/.gitignore: -------------------------------------------------------------------------------- 1 | *.prof 2 | *.test 3 | *.swp 4 | /bin/ 5 | -------------------------------------------------------------------------------- /hour25/example07/vendor/github.com/boltdb/bolt/Makefile: -------------------------------------------------------------------------------- 1 | BRANCH=`git rev-parse --abbrev-ref HEAD` 2 | COMMIT=`git rev-parse --short HEAD` 3 | GOLDFLAGS="-X main.branch $(BRANCH) -X main.commit $(COMMIT)" 4 | 5 | default: build 6 | 7 | race: 8 | @go test -v -race -test.run="TestSimulate_(100op|1000op)" 9 | 10 | # go get github.com/kisielk/errcheck 11 | errcheck: 12 | @errcheck -ignorepkg=bytes -ignore=os:Remove github.com/boltdb/bolt 13 | 14 | test: 15 | @go test -v -cover . 16 | @go test -v ./cmd/bolt 17 | 18 | .PHONY: fmt test 19 | -------------------------------------------------------------------------------- /hour25/example07/vendor/github.com/boltdb/bolt/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: "{build}" 2 | 3 | os: Windows Server 2012 R2 4 | 5 | clone_folder: c:\gopath\src\github.com\boltdb\bolt 6 | 7 | environment: 8 | GOPATH: c:\gopath 9 | 10 | install: 11 | - echo %PATH% 12 | - echo %GOPATH% 13 | - go version 14 | - go env 15 | - go get -v -t ./... 16 | 17 | build_script: 18 | - go test -v ./... 19 | -------------------------------------------------------------------------------- /hour25/example07/vendor/github.com/boltdb/bolt/bolt_386.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | // maxMapSize represents the largest mmap size supported by Bolt. 4 | const maxMapSize = 0x7FFFFFFF // 2GB 5 | 6 | // maxAllocSize is the size used when creating array pointers. 7 | const maxAllocSize = 0xFFFFFFF 8 | 9 | // Are unaligned load/stores broken on this arch? 10 | var brokenUnaligned = false 11 | -------------------------------------------------------------------------------- /hour25/example07/vendor/github.com/boltdb/bolt/bolt_amd64.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | // maxMapSize represents the largest mmap size supported by Bolt. 4 | const maxMapSize = 0xFFFFFFFFFFFF // 256TB 5 | 6 | // maxAllocSize is the size used when creating array pointers. 7 | const maxAllocSize = 0x7FFFFFFF 8 | 9 | // Are unaligned load/stores broken on this arch? 10 | var brokenUnaligned = false 11 | -------------------------------------------------------------------------------- /hour25/example07/vendor/github.com/boltdb/bolt/bolt_arm64.go: -------------------------------------------------------------------------------- 1 | // +build arm64 2 | 3 | package bolt 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0xFFFFFFFFFFFF // 256TB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0x7FFFFFFF 10 | 11 | // Are unaligned load/stores broken on this arch? 12 | var brokenUnaligned = false 13 | -------------------------------------------------------------------------------- /hour25/example07/vendor/github.com/boltdb/bolt/bolt_linux.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | import ( 4 | "syscall" 5 | ) 6 | 7 | // fdatasync flushes written data to a file descriptor. 8 | func fdatasync(db *DB) error { 9 | return syscall.Fdatasync(int(db.file.Fd())) 10 | } 11 | -------------------------------------------------------------------------------- /hour25/example07/vendor/github.com/boltdb/bolt/bolt_openbsd.go: -------------------------------------------------------------------------------- 1 | package bolt 2 | 3 | import ( 4 | "syscall" 5 | "unsafe" 6 | ) 7 | 8 | const ( 9 | msAsync = 1 << iota // perform asynchronous writes 10 | msSync // perform synchronous writes 11 | msInvalidate // invalidate cached data 12 | ) 13 | 14 | func msync(db *DB) error { 15 | _, _, errno := syscall.Syscall(syscall.SYS_MSYNC, uintptr(unsafe.Pointer(db.data)), uintptr(db.datasz), msInvalidate) 16 | if errno != 0 { 17 | return errno 18 | } 19 | return nil 20 | } 21 | 22 | func fdatasync(db *DB) error { 23 | if db.data != nil { 24 | return msync(db) 25 | } 26 | return db.file.Sync() 27 | } 28 | -------------------------------------------------------------------------------- /hour25/example07/vendor/github.com/boltdb/bolt/bolt_ppc.go: -------------------------------------------------------------------------------- 1 | // +build ppc 2 | 3 | package bolt 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0x7FFFFFFF // 2GB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0xFFFFFFF 10 | -------------------------------------------------------------------------------- /hour25/example07/vendor/github.com/boltdb/bolt/bolt_ppc64.go: -------------------------------------------------------------------------------- 1 | // +build ppc64 2 | 3 | package bolt 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0xFFFFFFFFFFFF // 256TB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0x7FFFFFFF 10 | 11 | // Are unaligned load/stores broken on this arch? 12 | var brokenUnaligned = false 13 | -------------------------------------------------------------------------------- /hour25/example07/vendor/github.com/boltdb/bolt/bolt_ppc64le.go: -------------------------------------------------------------------------------- 1 | // +build ppc64le 2 | 3 | package bolt 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0xFFFFFFFFFFFF // 256TB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0x7FFFFFFF 10 | 11 | // Are unaligned load/stores broken on this arch? 12 | var brokenUnaligned = false 13 | -------------------------------------------------------------------------------- /hour25/example07/vendor/github.com/boltdb/bolt/bolt_s390x.go: -------------------------------------------------------------------------------- 1 | // +build s390x 2 | 3 | package bolt 4 | 5 | // maxMapSize represents the largest mmap size supported by Bolt. 6 | const maxMapSize = 0xFFFFFFFFFFFF // 256TB 7 | 8 | // maxAllocSize is the size used when creating array pointers. 9 | const maxAllocSize = 0x7FFFFFFF 10 | 11 | // Are unaligned load/stores broken on this arch? 12 | var brokenUnaligned = false 13 | -------------------------------------------------------------------------------- /hour25/example07/vendor/github.com/boltdb/bolt/boltsync_unix.go: -------------------------------------------------------------------------------- 1 | // +build !windows,!plan9,!linux,!openbsd 2 | 3 | package bolt 4 | 5 | // fdatasync flushes written data to a file descriptor. 6 | func fdatasync(db *DB) error { 7 | return db.file.Sync() 8 | } 9 | -------------------------------------------------------------------------------- /hour25/example07/vendor/github.com/julienschmidt/httprouter/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: go 3 | go: 4 | - 1.1 5 | - 1.2 6 | - 1.3 7 | - 1.4 8 | - tip 9 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/.gitattributes: -------------------------------------------------------------------------------- 1 | # Treat all files in this repo as binary, with no git magic updating 2 | # line endings. Windows users contributing to Go will need to use a 3 | # modern version of git and editors capable of LF line endings. 4 | # 5 | # We'll prevent accidental CRLF line endings from entering the repo 6 | # via the git-review gofmt checks. 7 | # 8 | # See golang.org/issue/9281 9 | 10 | * -text 11 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/.gitignore: -------------------------------------------------------------------------------- 1 | # Add no patterns to .hgignore except for files generated by the build. 2 | last-change 3 | -------------------------------------------------------------------------------- /hour25/example07/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 | -------------------------------------------------------------------------------- /hour25/example07/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 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/README.md: -------------------------------------------------------------------------------- 1 | # sys 2 | 3 | This repository holds supplemental Go packages for low-level interactions with 4 | the operating system. 5 | 6 | ## Download/Install 7 | 8 | The easiest way to install is to run `go get -u golang.org/x/sys`. You can 9 | also manually git clone the repository to `$GOPATH/src/golang.org/x/sys`. 10 | 11 | ## Report Issues / Send Patches 12 | 13 | This repository uses Gerrit for code changes. To learn how to submit changes to 14 | this repository, see https://golang.org/doc/contribute.html. 15 | 16 | The main issue tracker for the sys repository is located at 17 | https://github.com/golang/go/issues. Prefix your issue with "x/sys:" in the 18 | subject line, so it is easy to find. 19 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/codereview.cfg: -------------------------------------------------------------------------------- 1 | issuerepo: golang/go 2 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/plan9/asm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | #include "textflag.h" 6 | 7 | TEXT ·use(SB),NOSPLIT,$0 8 | RET 9 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/plan9/asm_plan9_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 | #include "textflag.h" 6 | 7 | // 8 | // System call support for 386, Plan 9 9 | // 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-32 15 | JMP syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-44 18 | JMP syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 21 | JMP syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 24 | JMP syscall·RawSyscall6(SB) 25 | 26 | TEXT ·seek(SB),NOSPLIT,$0-36 27 | JMP syscall·seek(SB) 28 | 29 | TEXT ·exit(SB),NOSPLIT,$4-4 30 | JMP syscall·exit(SB) 31 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/plan9/asm_plan9_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 | #include "textflag.h" 6 | 7 | // 8 | // System call support for amd64, Plan 9 9 | // 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-64 15 | JMP syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 18 | JMP syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 21 | JMP syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | JMP syscall·RawSyscall6(SB) 25 | 26 | TEXT ·seek(SB),NOSPLIT,$0-56 27 | JMP syscall·seek(SB) 28 | 29 | TEXT ·exit(SB),NOSPLIT,$8-8 30 | JMP syscall·exit(SB) 31 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/plan9/env_plan9.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 | // Plan 9 environment variables. 6 | 7 | package plan9 8 | 9 | import ( 10 | "syscall" 11 | ) 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/plan9/env_unset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.4 6 | 7 | package plan9 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/plan9/mksysnum_plan9.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | 6 | COMMAND="mksysnum_plan9.sh $@" 7 | 8 | cat <= 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 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/.gitignore: -------------------------------------------------------------------------------- 1 | _obj/ 2 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-64 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-112 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-64 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-88 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 29 | JMP syscall·gettimeofday(SB) 30 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | B syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | B syscall·RawSyscall6(SB) 27 | 28 | TEXT ·seek(SB),NOSPLIT,$0-32 29 | B syscall·seek(SB) 30 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 21 | B syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | B syscall·RawSyscall6(SB) 25 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/asm_linux_mips64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build mips64 mips64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for mips64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | JMP syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | JMP syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | JMP syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | JMP syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/asm_linux_s390x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build s390x 6 | // +build linux 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for s390x, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/asm_openbsd_arm.s: -------------------------------------------------------------------------------- 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 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /hour25/example07/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 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/bluetooth_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Bluetooth sockets and messages 6 | 7 | package unix 8 | 9 | // Bluetooth Protocols 10 | const ( 11 | BTPROTO_L2CAP = 0 12 | BTPROTO_HCI = 1 13 | BTPROTO_SCO = 2 14 | BTPROTO_RFCOMM = 3 15 | BTPROTO_BNEP = 4 16 | BTPROTO_CMTP = 5 17 | BTPROTO_HIDP = 6 18 | BTPROTO_AVDTP = 7 19 | ) 20 | 21 | const ( 22 | HCI_CHANNEL_RAW = 0 23 | HCI_CHANNEL_USER = 1 24 | HCI_CHANNEL_MONITOR = 2 25 | HCI_CHANNEL_CONTROL = 3 26 | ) 27 | 28 | // Socketoption Level 29 | const ( 30 | SOL_BLUETOOTH = 0x112 31 | SOL_HCI = 0x0 32 | SOL_L2CAP = 0x6 33 | SOL_RFCOMM = 0x12 34 | SOL_SCO = 0x11 35 | ) 36 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /hour25/example07/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 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/endian_little.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | // 5 | // +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le 6 | 7 | package unix 8 | 9 | const isBigEndian = false 10 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/env_unset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.4 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/export_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | var Itoa = itoa 10 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/file_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 | package unix 6 | 7 | import ( 8 | "os" 9 | "syscall" 10 | ) 11 | 12 | // FIXME: unexported function from os 13 | // syscallMode returns the syscall-specific mode bits from Go's portable mode bits. 14 | func syscallMode(i os.FileMode) (o uint32) { 15 | o |= uint32(i.Perm()) 16 | if i&os.ModeSetuid != 0 { 17 | o |= syscall.S_ISUID 18 | } 19 | if i&os.ModeSetgid != 0 { 20 | o |= syscall.S_ISGID 21 | } 22 | if i&os.ModeSticky != 0 { 23 | o |= syscall.S_ISVTX 24 | } 25 | // No mapping for Go's ModeTemporary (plan9 only). 26 | return 27 | } 28 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/flock.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd 6 | 7 | package unix 8 | 9 | import "unsafe" 10 | 11 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 12 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 13 | var fcntl64Syscall uintptr = SYS_FCNTL 14 | 15 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 16 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 17 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 18 | if errno == 0 { 19 | return nil 20 | } 21 | return errno 22 | } 23 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm linux,mips linux,mipsle 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /hour25/example07/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 | -------------------------------------------------------------------------------- /hour25/example07/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 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 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/race.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 darwin,race linux,race freebsd,race 6 | 7 | package unix 8 | 9 | import ( 10 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /hour25/example07/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 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 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/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 darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | func itoa(val int) string { // do it here rather than with fmt to avoid dependency 10 | if val < 0 { 11 | return "-" + uitoa(uint(-val)) 12 | } 13 | return uitoa(uint(val)) 14 | } 15 | 16 | func uitoa(val uint) string { 17 | var buf [32]byte // big enough for int64 18 | i := len(buf) - 1 19 | for val >= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /hour25/example07/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 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/syscall_no_getwd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build dragonfly freebsd netbsd openbsd 6 | 7 | package unix 8 | 9 | const ImplementsGetwd = false 10 | 11 | func Getwd() (string, error) { return "", ENOTSUP } 12 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | func setTimespec(sec, nsec int64) Timespec { 10 | return Timespec{Sec: sec, Nsec: nsec} 11 | } 12 | 13 | func setTimeval(sec, usec int64) Timeval { 14 | return Timeval{Sec: sec, Usec: usec} 15 | } 16 | 17 | func (iov *Iovec) SetLen(length int) { 18 | iov.Len = uint64(length) 19 | } 20 | 21 | func (cmsg *Cmsghdr) SetLen(length int) { 22 | cmsg.Len = uint32(length) 23 | } 24 | 25 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 26 | // TODO(aram): implement this, see issue 5847. 27 | panic("unimplemented") 28 | } 29 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/syscall_unix_gc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | // +build !gccgo 7 | 8 | package unix 9 | 10 | import "syscall" 11 | 12 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 16 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | // TODO(aram): remove these before Go 1.3. 10 | const ( 11 | SYS_EXECVE = 59 12 | SYS_FCNTL = 62 13 | ) 14 | -------------------------------------------------------------------------------- /hour25/example07/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-8 10 | JMP syscall·getprocaddress(SB) 11 | 12 | TEXT ·loadlibrary(SB), 7, $0-4 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /hour25/example07/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-8 13 | JMP syscall·loadlibrary(SB) 14 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/windows/env_unset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build windows 6 | // +build go1.4 7 | 8 | package windows 9 | 10 | import "syscall" 11 | 12 | func Unsetenv(key string) error { 13 | // This was added in Go 1.4. 14 | return syscall.Unsetenv(key) 15 | } 16 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/windows/env_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Windows environment variables. 6 | 7 | package windows 8 | 9 | import "syscall" 10 | 11 | func Getenv(key string) (value string, found bool) { 12 | return syscall.Getenv(key) 13 | } 14 | 15 | func Setenv(key, value string) error { 16 | return syscall.Setenv(key, value) 17 | } 18 | 19 | func Clearenv() { 20 | syscall.Clearenv() 21 | } 22 | 23 | func Environ() []string { 24 | return syscall.Environ() 25 | } 26 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/windows/memory_windows.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 | package windows 6 | 7 | const ( 8 | MEM_COMMIT = 0x00001000 9 | MEM_RESERVE = 0x00002000 10 | MEM_DECOMMIT = 0x00004000 11 | MEM_RELEASE = 0x00008000 12 | MEM_RESET = 0x00080000 13 | MEM_TOP_DOWN = 0x00100000 14 | MEM_WRITE_WATCH = 0x00200000 15 | MEM_PHYSICAL = 0x00400000 16 | MEM_RESET_UNDO = 0x01000000 17 | MEM_LARGE_PAGES = 0x20000000 18 | 19 | PAGE_NOACCESS = 0x01 20 | PAGE_READONLY = 0x02 21 | PAGE_READWRITE = 0x04 22 | PAGE_WRITECOPY = 0x08 23 | PAGE_EXECUTE_READ = 0x20 24 | PAGE_EXECUTE_READWRITE = 0x40 25 | PAGE_EXECUTE_WRITECOPY = 0x80 26 | ) 27 | -------------------------------------------------------------------------------- /hour25/example07/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 | package windows 6 | 7 | //go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go eventlog.go service.go syscall_windows.go security_windows.go 8 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/windows/race.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 | "runtime" 11 | "unsafe" 12 | ) 13 | 14 | const raceenabled = true 15 | 16 | func raceAcquire(addr unsafe.Pointer) { 17 | runtime.RaceAcquire(addr) 18 | } 19 | 20 | func raceReleaseMerge(addr unsafe.Pointer) { 21 | runtime.RaceReleaseMerge(addr) 22 | } 23 | 24 | func raceReadRange(addr unsafe.Pointer, len int) { 25 | runtime.RaceReadRange(addr, len) 26 | } 27 | 28 | func raceWriteRange(addr unsafe.Pointer, len int) { 29 | runtime.RaceWriteRange(addr, len) 30 | } 31 | -------------------------------------------------------------------------------- /hour25/example07/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 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/windows/registry/export_test.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 windows 6 | 7 | package registry 8 | 9 | func (k Key) SetValue(name string, valtype uint32, data []byte) error { 10 | return k.setValue(name, valtype, data) 11 | } 12 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/windows/registry/mksyscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package registry 6 | 7 | //go:generate go run $GOROOT/src/syscall/mksyscall_windows.go -output zsyscall_windows.go syscall.go 8 | -------------------------------------------------------------------------------- /hour25/example07/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 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/windows/svc/example/beep.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 6 | 7 | package main 8 | 9 | import ( 10 | "syscall" 11 | ) 12 | 13 | // BUG(brainman): MessageBeep Windows api is broken on Windows 7, 14 | // so this example does not beep when runs as service on Windows 7. 15 | 16 | var ( 17 | beepFunc = syscall.MustLoadDLL("user32.dll").MustFindProc("MessageBeep") 18 | ) 19 | 20 | func beep() { 21 | beepFunc.Call(0xffffffff) 22 | } 23 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/windows/svc/go12.c: -------------------------------------------------------------------------------- 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 6 | // +build !go1.3 7 | 8 | // copied from pkg/runtime 9 | typedef unsigned int uint32; 10 | typedef unsigned long long int uint64; 11 | #ifdef _64BIT 12 | typedef uint64 uintptr; 13 | #else 14 | typedef uint32 uintptr; 15 | #endif 16 | 17 | // from sys_386.s or sys_amd64.s 18 | void ·servicemain(void); 19 | 20 | void 21 | ·getServiceMain(uintptr *r) 22 | { 23 | *r = (uintptr)·servicemain; 24 | } 25 | -------------------------------------------------------------------------------- /hour25/example07/vendor/golang.org/x/sys/windows/svc/go12.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 windows 6 | // +build !go1.3 7 | 8 | package svc 9 | 10 | // from go12.c 11 | func getServiceMain(r *uintptr) 12 | -------------------------------------------------------------------------------- /hour25/example07/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 | -------------------------------------------------------------------------------- /hour25/example07/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 | -------------------------------------------------------------------------------- /hour26/example01.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | "net" 6 | ) 7 | 8 | func main() { 9 | server, err := net.Listen("tcp", ":8080") 10 | if err != nil { 11 | log.Fatal(err) 12 | } 13 | defer server.Close() 14 | 15 | for { 16 | conn, err := server.Accept() 17 | if err != nil { 18 | log.Fatal(err) 19 | } 20 | 21 | conn.Write([]byte("Hello World!\n")) 22 | 23 | conn.Close() 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /hour26/example02.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "io" 5 | "log" 6 | "net" 7 | ) 8 | 9 | func main() { 10 | server, err := net.Listen("tcp", ":8080") 11 | if err != nil { 12 | log.Fatal(err) 13 | } 14 | defer server.Close() 15 | 16 | for { 17 | conn, err := server.Accept() 18 | if err != nil { 19 | log.Fatal(err) 20 | } 21 | 22 | go handleRequest(conn) 23 | 24 | } 25 | } 26 | 27 | func handleRequest(conn net.Conn) { 28 | io.Copy(conn, conn) 29 | } 30 | --------------------------------------------------------------------------------