From ab086e2ef9cbcdf525f1394911c258fa08583bd5 Mon Sep 17 00:00:00 2001 From: iampeterbanjo Date: Sat, 13 Oct 2018 17:48:27 +0100 Subject: [PATCH 1/6] fix markdown linting --- readme.md | 157 +++++++++++++++++++++++++++--------------------------- 1 file changed, 78 insertions(+), 79 deletions(-) diff --git a/readme.md b/readme.md index eb1af98..20e29e7 100755 --- a/readme.md +++ b/readme.md @@ -1,10 +1,10 @@ # Go Examples -[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FSimonWaldherr%2Fgolang-examples.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FSimonWaldherr%2Fgolang-examples?ref=badge_shield) +[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FSimonWaldherr%2Fgolang-examples.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2FSimonWaldherr%2Fgolang-examples?ref=badge_shield) ## About - -These examples explain the basics of golang. There will be more examples from time to time. + +These examples explain the basics of golang. There will be more examples from time to time. if you like, feel free to add more golang examples. Many thanks to all [contributors](https://github.com/SimonWaldherr/golang-examples/graphs/contributors). @@ -12,24 +12,24 @@ if you like, feel free to add more golang examples. Many thanks to all [contribu with [homebrew](http://mxcl.github.io/homebrew/): -``` +```Shell sudo brew install go ``` with [apt](http://packages.qa.debian.org/a/apt.html)-get: -``` +```Shell sudo apt-get install golang ``` -[install golang manually](https://golang.org/doc/install) -or -[compile it yourself](https://golang.org/doc/install/source) +[install golang manually](https://golang.org/doc/install) +or +[compile it yourself](https://golang.org/doc/install/source) ## Examples -The examples are divided into three levels of difficulty. The [Beginner](https://github.com/SimonWaldherr/golang-examples#beginner) section contains very easy examples, starting with **Hello World** but also containing a few easy algorithms. The [Advanced](https://github.com/SimonWaldherr/golang-examples#advanced) section uses more complicated features of golang. Finally, the [Expert](https://github.com/SimonWaldherr/golang-examples#expert) section contains applications like telnet-clients or http-server (even with SSL). -If you want even more golang examples, you can take a look at my other go repositories at github: +The examples are divided into three levels of difficulty. The [Beginner](https://github.com/SimonWaldherr/golang-examples#beginner) section contains very easy examples, starting with **Hello World** but also containing a few easy algorithms. The [Advanced](https://github.com/SimonWaldherr/golang-examples#advanced) section uses more complicated features of golang. Finally, the [Expert](https://github.com/SimonWaldherr/golang-examples#expert) section contains applications like telnet-clients or http-server (even with SSL). +If you want even more golang examples, you can take a look at my other go repositories at github: * [GolangSortingVisualization](https://github.com/SimonWaldherr/GolangSortingVisualization) visualizes various sorting algorithms on the terminal or as gif * [golang-minigames](https://github.com/SimonWaldherr/golang-minigames) currently only contains a snake clone @@ -57,157 +57,157 @@ If you know ```#!```, also known as [Shebang](https://en.wikipedia.org/wiki/Sheb Print Hello World with comments -``` +```Shell go run HelloWorld.go ``` Print Hello World with comments (shebang version) -``` +```Shell ./HelloWorldShebang.go ``` Declare variables and print them -``` +```Shell go run var.go ``` Various ways (and styles) to print variables -``` +```Shell go run printf.go ``` If statement in golang -``` +```Shell go run if.go Hello ``` Declare array and print it's items -``` +```Shell go run array.go ``` Declare your own functions -``` +```Shell go run function.go ``` Do something multiple times -``` +```Shell go run for.go ``` Read via cli provided input data -``` +```Shell go run args.go string string2 ``` Read via cli provided input data -``` +```Shell go run input.go ``` Or scan for it -``` +```Shell go run scan.go ``` Read named argument input data -``` +```Shell go run flag.go ``` Return the *working directory* -``` +```Shell go run dir.go ``` Return the current time/date in various formats -``` +```Shell go run time.go ``` Return pseudo random integer values -``` +```Shell go run random.go ``` Concat strings in two different ways -``` +```Shell go run cat.go ``` Modulo operation finds the remainder of division -``` +```Shell go run modulo.go ``` Split a string by another string and make an array from the result -``` +```Shell go run split.go ``` An example implementation of the Ackermann function -``` +```Shell go run ackermann.go ``` An example implementation of the Euclidean algorithm -``` +```Shell go run euklid.go ``` Make pipeable unix applications with os.Stdin -``` +```Shell go run pipe.go ``` Submit a function as argument -``` +```Shell go run functioncallback.go ``` A function returned by a function -``` +```Shell go run functionclosure.go ``` A function with an unknown amount of inputs (variadic function) -``` +```Shell go run functionvariadic.go ``` Empty interface as argument (You Don't Know Type) -``` +```Shell go run interfaces.go ``` Make structs (objects) which have functions -``` +```Shell go run oop.go ``` @@ -217,13 +217,13 @@ Benchmarking example (using JSON marshal and unmarshal for the sample) From the root directory (`$GOPATH/github.com/SimonWaldherr/golang-examples`), run this command: -``` +```Shell go test -bench=. -benchmem advanced/json_bench/main_test.go ``` AES-GCM encryption example -``` +```Shell go run aesgcm.go ``` @@ -231,127 +231,127 @@ Bcrypt hashing example Please install package golang.org/x/crypto/bcrypt before run this file by running `go get golang.org/x/crypto/bcrypt` -``` +```Shell go run bcrypt.go ``` Search element is exist in arrays or not -``` +```Shell go run in_array.go ``` Calculate triangles -``` +```Shell go run pythagoras.go (float|?) (float|?) (float|?) ``` Read from stdin (but don't wait for the enter key) -``` +```Shell go run getchar.go ``` Wait and sleep -``` +```Shell go run wait.go ``` Last in - first out - example -``` +```Shell go run lifo.go ``` Split a string via regular expression and make an array from the result -``` +```Shell go run regex.go ``` More advanced regex (with time and dates) -``` +```Shell go run regex2.go ``` Use my [golibs regex package](https://github.com/SimonWaldherr/golibs#regex-----) -``` +```Shell go run regex3.go ``` Calculate and print the fibonacci numbers -``` +```Shell go run fibonacci.go ``` Calculate and print the requested (32th) prime number -``` +```Shell go run prime.go 32 ``` Do things with numbers, strings and switch-cases -``` +```Shell go run numbers.go ``` Pop and push in golang -``` +```Shell go run lifo.go ``` List files in working directory -``` +```Shell go run explorer.go ``` Start a ticker (do things periodically) -``` +```Shell go run ticker.go ``` Do something in case of a timeout -``` +```Shell go run timeout.go ``` Convert go object to json string -``` +```Shell go run json.go ``` Run unix/shell commands in go apps -``` +```Shell go run exec.go ``` Compress by pipe -``` +```Shell go run compress.go ``` Compress by file -``` +```Shell go run compress2.go ``` Run a self killing app -``` +```Shell go run suicide.go ``` @@ -359,49 +359,49 @@ go run suicide.go Calculate π with go (leibniz, euler and prime are running until you stop it via CTRL+C) -``` -go run pi2go.go leibniz -go run pi2go.go euler +```Shell +go Shellrun pi2go.go leibniz +go Shellrun pi2go.go euler go run pi2go.go prime ``` Convert from rgb to hsl -``` +```Shell go run color.go ``` Telnet with golang -``` +```Shell go run telnet.go ``` The smallest golang http server -``` +```Shell go run httpd.go ``` Secure golang http server -``` +```Shell go run httpsd.go ``` The smallest golang http proxy -``` +```Shell go run proxy.go ``` Read and write cookies -``` +```Shell go run cookies.go ``` -Demonstrate the power of multithreading / parallel computing +Demonstrate the power of multithreading / parallel computing you have to set GOMAXPROCS to something greater than 1 to see any effect ``` @@ -412,39 +412,39 @@ time go run parallel.go false A dynamic amount of channels -``` +```Shell time go run dynparallel.go 8 ``` Run the compiler and comment each line which contains an error -``` +```Shell go build gocomment.go ./gocomment go-app.go ``` Convert a image to a grayscale and to a color inverted image -``` +```Shell go run image.go ``` Sql (sqlite) golang example -``` -go run sqlite.go insert test +```Shell +go Shellrun sqlite.go insert test go run sqlite.go select ``` Public-key/asymmetric cryptography signing and validating -``` +```Shell go run ppk-crypto.go ``` Hashing (md5, sha) in go -``` +```Shell go run hashing.go ``` @@ -455,9 +455,8 @@ If you start fibonacci.go and the compiled version you will notice, that the las ## License -Copyright © 2018 Simon Waldherr -Dual-licensed. See the [LICENSE](https://github.com/SimonWaldherr/golang-examples/blob/master/LICENSE) file for details. - +Copyright © 2018 Simon Waldherr +Dual-licensed. See the [LICENSE](https://github.com/SimonWaldherr/golang-examples/blob/master/LICENSE) file for details. [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FSimonWaldherr%2Fgolang-examples.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FSimonWaldherr%2Fgolang-examples?ref=badge_large) From 675b222b2ae368d0e4b9386e5b679614b6633626 Mon Sep 17 00:00:00 2001 From: iampeterbanjo Date: Sat, 13 Oct 2018 19:30:10 +0100 Subject: [PATCH 2/6] add dependency injection example --- beginner/di/dependency_injection.go | 17 ++++++++++++++ beginner/di/dependency_injection_test.go | 30 ++++++++++++++++++++++++ go.mod | 7 ++++++ go.sum | 6 +++++ 4 files changed, 60 insertions(+) create mode 100644 beginner/di/dependency_injection.go create mode 100644 beginner/di/dependency_injection_test.go create mode 100644 go.mod create mode 100644 go.sum diff --git a/beginner/di/dependency_injection.go b/beginner/di/dependency_injection.go new file mode 100644 index 0000000..29a0f54 --- /dev/null +++ b/beginner/di/dependency_injection.go @@ -0,0 +1,17 @@ +package di + +import ( + "fmt" + "io" +) + +// PrintCheckList to show D.I. +// +// dependency Injection makes testing easier +// by creating functions that get all their +// dependencies are arguments +func PrintCheckList(writer io.Writer, list []string) { + for _, item := range list { + fmt.Fprintln(writer, item) + } +} diff --git a/beginner/di/dependency_injection_test.go b/beginner/di/dependency_injection_test.go new file mode 100644 index 0000000..08fd3e6 --- /dev/null +++ b/beginner/di/dependency_injection_test.go @@ -0,0 +1,30 @@ +package di + +import ( + "bytes" + "testing" + + . "github.com/smartystreets/goconvey/convey" +) + +func TestPrintCheckList(t *testing.T) { + Convey("Given a checklist", t, func() { + buffer := &bytes.Buffer{} + checklist := []string{ + "[✓] Get milk", + "[✓] Learn Go", + "[✗] Book holidays", + } + + PrintCheckList(buffer, checklist) + + got := buffer.String() + want := `[✓] Get milk +[✓] Learn Go +[✗] Book holidays +` + Convey("expect list items to be printed", func() { + So(got, ShouldEqual, want) + }) + }) +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..ed6ec88 --- /dev/null +++ b/go.mod @@ -0,0 +1,7 @@ +module github.com/iampeterbanjo/golang-examples + +require ( + github.com/jtolds/gls v4.2.1+incompatible // indirect + github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect + github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..30fe5ef --- /dev/null +++ b/go.sum @@ -0,0 +1,6 @@ +github.com/jtolds/gls v4.2.1+incompatible h1:fSuqC+Gmlu6l/ZYAoZzx2pyucC8Xza35fpRVWLVmUEE= +github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a h1:JSvGDIbmil4Ui/dDdFBExb7/cmkNjyX5F97oglmvCDo= +github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= From 003b3b02b1eb117c62fb7d2e7b8a9d14b08ad224 Mon Sep 17 00:00:00 2001 From: iampeterbanjo Date: Sun, 14 Oct 2018 15:19:54 +0100 Subject: [PATCH 3/6] update readme with di --- readme.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/readme.md b/readme.md index 20e29e7..fbc0dc3 100755 --- a/readme.md +++ b/readme.md @@ -211,6 +211,13 @@ Make structs (objects) which have functions go run oop.go ``` +Dependency injection for easier testing + +```Shell +cd beginner/di +go test +``` + ### Advanced Benchmarking example (using JSON marshal and unmarshal for the sample) From f80cebd91d367875a4fba0c560b3c0ab61f2ae19 Mon Sep 17 00:00:00 2001 From: iampeterbanjo Date: Sun, 14 Oct 2018 15:21:26 +0100 Subject: [PATCH 4/6] fix markdown code annotation --- readme.md | 130 +++++++++++++++++++++++++++--------------------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/readme.md b/readme.md index fbc0dc3..8d063e5 100755 --- a/readme.md +++ b/readme.md @@ -12,13 +12,13 @@ if you like, feel free to add more golang examples. Many thanks to all [contribu with [homebrew](http://mxcl.github.io/homebrew/): -```Shell +```go sudo brew install go ``` with [apt](http://packages.qa.debian.org/a/apt.html)-get: -```Shell +```go sudo apt-get install golang ``` @@ -57,157 +57,157 @@ If you know ```#!```, also known as [Shebang](https://en.wikipedia.org/wiki/Sheb Print Hello World with comments -```Shell +```go go run HelloWorld.go ``` Print Hello World with comments (shebang version) -```Shell +```go ./HelloWorldShebang.go ``` Declare variables and print them -```Shell +```go go run var.go ``` Various ways (and styles) to print variables -```Shell +```go go run printf.go ``` If statement in golang -```Shell +```go go run if.go Hello ``` Declare array and print it's items -```Shell +```go go run array.go ``` Declare your own functions -```Shell +```go go run function.go ``` Do something multiple times -```Shell +```go go run for.go ``` Read via cli provided input data -```Shell +```go go run args.go string string2 ``` Read via cli provided input data -```Shell +```go go run input.go ``` Or scan for it -```Shell +```go go run scan.go ``` Read named argument input data -```Shell +```go go run flag.go ``` Return the *working directory* -```Shell +```go go run dir.go ``` Return the current time/date in various formats -```Shell +```go go run time.go ``` Return pseudo random integer values -```Shell +```go go run random.go ``` Concat strings in two different ways -```Shell +```go go run cat.go ``` Modulo operation finds the remainder of division -```Shell +```go go run modulo.go ``` Split a string by another string and make an array from the result -```Shell +```go go run split.go ``` An example implementation of the Ackermann function -```Shell +```go go run ackermann.go ``` An example implementation of the Euclidean algorithm -```Shell +```go go run euklid.go ``` Make pipeable unix applications with os.Stdin -```Shell +```go go run pipe.go ``` Submit a function as argument -```Shell +```go go run functioncallback.go ``` A function returned by a function -```Shell +```go go run functionclosure.go ``` A function with an unknown amount of inputs (variadic function) -```Shell +```go go run functionvariadic.go ``` Empty interface as argument (You Don't Know Type) -```Shell +```go go run interfaces.go ``` Make structs (objects) which have functions -```Shell +```go go run oop.go ``` @@ -224,13 +224,13 @@ Benchmarking example (using JSON marshal and unmarshal for the sample) From the root directory (`$GOPATH/github.com/SimonWaldherr/golang-examples`), run this command: -```Shell +```go go test -bench=. -benchmem advanced/json_bench/main_test.go ``` AES-GCM encryption example -```Shell +```go go run aesgcm.go ``` @@ -238,127 +238,127 @@ Bcrypt hashing example Please install package golang.org/x/crypto/bcrypt before run this file by running `go get golang.org/x/crypto/bcrypt` -```Shell +```go go run bcrypt.go ``` Search element is exist in arrays or not -```Shell +```go go run in_array.go ``` Calculate triangles -```Shell +```go go run pythagoras.go (float|?) (float|?) (float|?) ``` Read from stdin (but don't wait for the enter key) -```Shell +```go go run getchar.go ``` Wait and sleep -```Shell +```go go run wait.go ``` Last in - first out - example -```Shell +```go go run lifo.go ``` Split a string via regular expression and make an array from the result -```Shell +```go go run regex.go ``` More advanced regex (with time and dates) -```Shell +```go go run regex2.go ``` Use my [golibs regex package](https://github.com/SimonWaldherr/golibs#regex-----) -```Shell +```go go run regex3.go ``` Calculate and print the fibonacci numbers -```Shell +```go go run fibonacci.go ``` Calculate and print the requested (32th) prime number -```Shell +```go go run prime.go 32 ``` Do things with numbers, strings and switch-cases -```Shell +```go go run numbers.go ``` Pop and push in golang -```Shell +```go go run lifo.go ``` List files in working directory -```Shell +```go go run explorer.go ``` Start a ticker (do things periodically) -```Shell +```go go run ticker.go ``` Do something in case of a timeout -```Shell +```go go run timeout.go ``` Convert go object to json string -```Shell +```go go run json.go ``` Run unix/shell commands in go apps -```Shell +```go go run exec.go ``` Compress by pipe -```Shell +```go go run compress.go ``` Compress by file -```Shell +```go go run compress2.go ``` Run a self killing app -```Shell +```go go run suicide.go ``` @@ -366,7 +366,7 @@ go run suicide.go Calculate π with go (leibniz, euler and prime are running until you stop it via CTRL+C) -```Shell +```go go Shellrun pi2go.go leibniz go Shellrun pi2go.go euler go run pi2go.go prime @@ -374,44 +374,44 @@ go run pi2go.go prime Convert from rgb to hsl -```Shell +```go go run color.go ``` Telnet with golang -```Shell +```go go run telnet.go ``` The smallest golang http server -```Shell +```go go run httpd.go ``` Secure golang http server -```Shell +```go go run httpsd.go ``` The smallest golang http proxy -```Shell +```go go run proxy.go ``` Read and write cookies -```Shell +```go go run cookies.go ``` Demonstrate the power of multithreading / parallel computing you have to set GOMAXPROCS to something greater than 1 to see any effect -``` +```Shell export GOMAXPROCS=8 time go run parallel.go true time go run parallel.go false @@ -419,39 +419,39 @@ time go run parallel.go false A dynamic amount of channels -```Shell +```go time go run dynparallel.go 8 ``` Run the compiler and comment each line which contains an error -```Shell +```go go build gocomment.go ./gocomment go-app.go ``` Convert a image to a grayscale and to a color inverted image -```Shell +```go go run image.go ``` Sql (sqlite) golang example -```Shell +```go go Shellrun sqlite.go insert test go run sqlite.go select ``` Public-key/asymmetric cryptography signing and validating -```Shell +```go go run ppk-crypto.go ``` Hashing (md5, sha) in go -```Shell +```go go run hashing.go ``` From 3ab40b584b789083feeb19dd7365e76622071498 Mon Sep 17 00:00:00 2001 From: iampeterbanjo Date: Mon, 15 Oct 2018 06:32:50 +0100 Subject: [PATCH 5/6] fix readme --- readme.md | 130 +++++++++++++++++++++++++++--------------------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/readme.md b/readme.md index 8d063e5..bda8ca7 100755 --- a/readme.md +++ b/readme.md @@ -12,13 +12,13 @@ if you like, feel free to add more golang examples. Many thanks to all [contribu with [homebrew](http://mxcl.github.io/homebrew/): -```go +```Shell sudo brew install go ``` with [apt](http://packages.qa.debian.org/a/apt.html)-get: -```go +```Shell sudo apt-get install golang ``` @@ -57,157 +57,157 @@ If you know ```#!```, also known as [Shebang](https://en.wikipedia.org/wiki/Sheb Print Hello World with comments -```go +```Shell go run HelloWorld.go ``` Print Hello World with comments (shebang version) -```go +```Shell ./HelloWorldShebang.go ``` Declare variables and print them -```go +```Shell go run var.go ``` Various ways (and styles) to print variables -```go +```Shell go run printf.go ``` If statement in golang -```go +```Shell go run if.go Hello ``` Declare array and print it's items -```go +```Shell go run array.go ``` Declare your own functions -```go +```Shell go run function.go ``` Do something multiple times -```go +```Shell go run for.go ``` Read via cli provided input data -```go +```Shell go run args.go string string2 ``` Read via cli provided input data -```go +```Shell go run input.go ``` Or scan for it -```go +```Shell go run scan.go ``` Read named argument input data -```go +```Shell go run flag.go ``` Return the *working directory* -```go +```Shell go run dir.go ``` Return the current time/date in various formats -```go +```Shell go run time.go ``` Return pseudo random integer values -```go +```Shell go run random.go ``` Concat strings in two different ways -```go +```Shell go run cat.go ``` Modulo operation finds the remainder of division -```go +```Shell go run modulo.go ``` Split a string by another string and make an array from the result -```go +```Shell go run split.go ``` An example implementation of the Ackermann function -```go +```Shell go run ackermann.go ``` An example implementation of the Euclidean algorithm -```go +```Shell go run euklid.go ``` Make pipeable unix applications with os.Stdin -```go +```Shell go run pipe.go ``` Submit a function as argument -```go +```Shell go run functioncallback.go ``` A function returned by a function -```go +```Shell go run functionclosure.go ``` A function with an unknown amount of inputs (variadic function) -```go +```Shell go run functionvariadic.go ``` Empty interface as argument (You Don't Know Type) -```go +```Shell go run interfaces.go ``` Make structs (objects) which have functions -```go +```Shell go run oop.go ``` @@ -224,13 +224,13 @@ Benchmarking example (using JSON marshal and unmarshal for the sample) From the root directory (`$GOPATH/github.com/SimonWaldherr/golang-examples`), run this command: -```go +```Shell go test -bench=. -benchmem advanced/json_bench/main_test.go ``` AES-GCM encryption example -```go +```Shell go run aesgcm.go ``` @@ -238,127 +238,127 @@ Bcrypt hashing example Please install package golang.org/x/crypto/bcrypt before run this file by running `go get golang.org/x/crypto/bcrypt` -```go +```Shell go run bcrypt.go ``` Search element is exist in arrays or not -```go +```Shell go run in_array.go ``` Calculate triangles -```go +```Shell go run pythagoras.go (float|?) (float|?) (float|?) ``` Read from stdin (but don't wait for the enter key) -```go +```Shell go run getchar.go ``` Wait and sleep -```go +```Shell go run wait.go ``` Last in - first out - example -```go +```Shell go run lifo.go ``` Split a string via regular expression and make an array from the result -```go +```Shell go run regex.go ``` More advanced regex (with time and dates) -```go +```Shell go run regex2.go ``` Use my [golibs regex package](https://github.com/SimonWaldherr/golibs#regex-----) -```go +```Shell go run regex3.go ``` Calculate and print the fibonacci numbers -```go +```Shell go run fibonacci.go ``` Calculate and print the requested (32th) prime number -```go +```Shell go run prime.go 32 ``` Do things with numbers, strings and switch-cases -```go +```Shell go run numbers.go ``` Pop and push in golang -```go +```Shell go run lifo.go ``` List files in working directory -```go +```Shell go run explorer.go ``` Start a ticker (do things periodically) -```go +```Shell go run ticker.go ``` Do something in case of a timeout -```go +```Shell go run timeout.go ``` Convert go object to json string -```go +```Shell go run json.go ``` Run unix/shell commands in go apps -```go +```Shell go run exec.go ``` Compress by pipe -```go +```Shell go run compress.go ``` Compress by file -```go +```Shell go run compress2.go ``` Run a self killing app -```go +```Shell go run suicide.go ``` @@ -366,45 +366,45 @@ go run suicide.go Calculate π with go (leibniz, euler and prime are running until you stop it via CTRL+C) -```go -go Shellrun pi2go.go leibniz -go Shellrun pi2go.go euler +```Shell +go run pi2go.go leibniz +go run pi2go.go euler go run pi2go.go prime ``` Convert from rgb to hsl -```go +```Shell go run color.go ``` Telnet with golang -```go +```Shell go run telnet.go ``` The smallest golang http server -```go +```Shell go run httpd.go ``` Secure golang http server -```go +```Shell go run httpsd.go ``` The smallest golang http proxy -```go +```Shell go run proxy.go ``` Read and write cookies -```go +```Shell go run cookies.go ``` @@ -425,33 +425,33 @@ time go run dynparallel.go 8 Run the compiler and comment each line which contains an error -```go +```Shell go build gocomment.go ./gocomment go-app.go ``` Convert a image to a grayscale and to a color inverted image -```go +```Shell go run image.go ``` Sql (sqlite) golang example -```go +```Shell go Shellrun sqlite.go insert test go run sqlite.go select ``` Public-key/asymmetric cryptography signing and validating -```go +```Shell go run ppk-crypto.go ``` Hashing (md5, sha) in go -```go +```Shell go run hashing.go ``` From d1a271cdd317d096949c4b84f8258249ecebba20 Mon Sep 17 00:00:00 2001 From: iampeterbanjo Date: Mon, 15 Oct 2018 20:48:56 +0100 Subject: [PATCH 6/6] one more readme fix --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index bda8ca7..0174df9 100755 --- a/readme.md +++ b/readme.md @@ -439,7 +439,7 @@ go run image.go Sql (sqlite) golang example ```Shell -go Shellrun sqlite.go insert test +go run sqlite.go insert test go run sqlite.go select ```