- stage 1: You believe you can make Go do object oriented programming. You want to do this by using clever struct embedding.
- stage 2: You believe goroutines will solve all of your problems. You want to use goroutines for anything and everything that you can, who cares if the code becomes a bit more complicated
- stage 3: You believe that instead of object oriented programming, interfaces will solve all of your problems. You want to define everything in terms of interfaces
- stage 4: You believe channels will solve all of your problems. You want to do everything from synchronization, returning values, and flow control using channels.
- stage 5: You now believe Go is not as powerful as people claim it to be. You feel like you're stripped of all of the nice tools and constructs that other languages provide.
- stage 6: You realize that stages 1~5 were all just your imagination. You just didn't want to accept the Go way. Everything starts to make sense.
- stage 7: You are now at peace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Go parameters | |
| GOCMD=go | |
| GOBUILD=$(GOCMD) build | |
| GOCLEAN=$(GOCMD) clean | |
| GOTEST=$(GOCMD) test | |
| GOGET=$(GOCMD) get | |
| BINARY_NAME=mybinary | |
| BINARY_UNIX=$(BINARY_NAME)_unix |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ref: https://play.golang.org/p/OeEmT_CXyO | |
| package main | |
| import ( | |
| "fmt" | |
| "runtime" | |
| "strconv" | |
| "strings" | |
| "sync" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "net" | |
| "io" | |
| ) | |
| func main() { | |
| //http.HandleFunc("/", handler) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "net/http" | |
| "log" | |
| ) | |
| func redirect(w http.ResponseWriter, req *http.Request) { | |
| // remove/add not default ports from req.Host | |
| target := "https://" + req.Host + req.URL.Path | |
| if len(req.URL.RawQuery) > 0 { |
Moved to git repository: https://github.com/denji/golang-tls
# Key considerations for algorithm "RSA" ≥ 2048-bit
openssl genrsa -out server.key 2048
# Key considerations for algorithm "ECDSA" ≥ secp384r1
# List ECDSA the supported curves (openssl ecparam -list_curves)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ( | |
| "net/http" | |
| "net/http/httputil" | |
| "net/url" | |
| "fmt" | |
| ) | |
| func main() { | |
| // New functionality written in Go | |
| http.HandleFunc("/new", func(w http.ResponseWriter, r *http.Request) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using System.Collections; | |
| public class CameraShake : MonoBehaviour | |
| { | |
| // Transform of the camera to shake. Grabs the gameObject's transform | |
| // if null. | |
| public Transform camTransform; | |
| // How long the object should shake for. |