Skip to content

Instantly share code, notes, and snippets.

Mr Morake tevin-morake

  • Rapidtrade
  • Johannesburg South
Block or report user

Report or block tevin-morake

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View customsort.go
package main
import (
"fmt"
"sort"
)
type Person struct {
First string
Age int
@tevin-morake
tevin-morake / closure_explained.go
Created Apr 10, 2019
Just explaining closure in go
View closure_explained.go
package main
import (
"fmt"
)
/*
* What is Closure in go ?
* Closure is basically one scope enclosing other scopes .
* What does that mean ?
@tevin-morake
tevin-morake / reduce.go
Created Apr 8, 2019
Sometimes we need a simple way to reduce values in go, but we know that go isn't JS. This gist aims at mimicking the js reduce method
View reduce.go
package main
import (
"fmt"
)
// This is my way of reducing in go
func main() {
reportMarks := []int{20, 45, 78, 3, 59, 95, 6}
totalMarks := sum(reportMarks...)
@tevin-morake
tevin-morake / embedded_structs.go
Created Apr 7, 2019
Illustrates how to use embedded structs and access fields within embedded structs
View embedded_structs.go
package main
import (
"fmt"
)
/*
* With Embedded structs,the embedded fields are promoted to the parent struct
* For Example, the programmer struct is embedded within the staffMembers struct.
@tevin-morake
tevin-morake / createindex.go
Created Apr 7, 2019
How to create an elastic search index with default mappings
View createindex.go
mapping := `{"settings":{"number_of_shards":1,"number_of_replicas":0},"mappings":{"cities":{"properties":{"CompanyName":{"type":"text"},"Addresses":{"type":"text"},"PostCode":{"type":"text"}}}}}`
elasticSURL := "https://xxxxxx"
client, err := elastic.NewClient(elastic.SetSniff(false), elastic.SetURL(elasticSURL))
if err != nil {
// handle error
}
info, code, err := client.Ping(elasticSURL).Do(context.Background())
if err != nil {
// handle error
@tevin-morake
tevin-morake / update-golang.md
Created Apr 3, 2018 — forked from nikhita/update-golang.md
How to update the Go version
View update-golang.md

How to update the Go version

System: Ubuntu 14.04 (Trusty Tahr)

1. Uninstall the exisiting version

As mentioned here, to update a go version you will first need to uninstall the original version.

To uninstall, delete the /usr/local/go directory by:

You can’t perform that action at this time.