Skip to content

Instantly share code, notes, and snippets.

View cyantarek's full-sized avatar
🏠
Working from home

Cyan Tarek cyantarek

🏠
Working from home
View GitHub Profile
package main
import (
"fmt"
"time"
)
func main() {
countFruit("Apple")
countFruit("Orange")
package main
import (
"fmt"
"time"
)
func main() {
go countFruit("Apple")
go countFruit("Orange")
package main
import (
"fmt"
"time"
)
func main() {
var ch = make(chan string)
package main
import "fmt"
const maxWeight = 5
var currentWeight int
var currentValue int
var totalItemsTaken int
@cyantarek
cyantarek / client.go
Created October 5, 2018 16:42
Golang AES-CFB encrypted TCP stream
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"fmt"
"io"
"net"
)
@cyantarek
cyantarek / go-stdlib-interface-selected.md
Created October 11, 2018 12:22 — forked from asukakenji/go-stdlib-interface-selected.md
Go (Golang) Standard Library Interfaces (Selected)

Go (Golang) Standard Library Interfaces (Selected)

This is not an exhaustive list of all interfaces in Go's standard library. I only list those I think are important. Interfaces defined in frequently used packages (like io, fmt) are included. Interfaces that have significant importance are also included.

All of the following information is based on go version go1.8.3 darwin/amd64.

package main
import "gopkg.in/macaron.v1"
func main() {
http.HandleFunc("GET", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello, I'm protected"))
})
log.Fatal(http.ListenAndServe(":9096", nil))
package main
import (
"encoding/json"
"fmt"
"github.com/google/uuid"
"gopkg.in/oauth2.v3/models"
"log"
"net/http"
"time"
http.HandleFunc("/credentials", func(w http.ResponseWriter, r *http.Request) {
clientId := uuid.New().String()[:8]
clientSecret := uuid.New().String()[:8]
err := clientStore.Set(clientId, &models.Client{
ID: clientId,
Secret: clientSecret,
Domain: "http://localhost:9094",
})
if err != nil {
fmt.Println(err.Error())
http.HandleFunc("/token", func(w http.ResponseWriter, r *http.Request) {
srv.HandleTokenRequest(w, r)
})