Skip to content

Instantly share code, notes, and snippets.

View arriqaaq's full-sized avatar
🎯
Focusing

Farhan arriqaaq

🎯
Focusing
View GitHub Profile
package main
import "fmt"
func main() {
s1 := "hello"
s2 := "hello"
fmt.Println(&s1 == &s2) // true
}
package main
import (
"encoding/json"
"fmt"
)
type Person struct {
Name string
Age int
package main
import (
"fmt"
"net/http"
)
func main() {
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://www.example.com", nil)
package main
import (
"fmt"
"io/ioutil"
)
// FileSystem is the facade interface
type FileSystem interface {
ReadFile(string) ([]byte, error)
type Middleware func(http.HandlerFunc) http.HandlerFunc
func LoggingMiddleware(next http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
log.Println("Before request")
next.ServeHTTP(w, r)
log.Println("After request")
}
}
import (
"io"
"strings"
)
func main() {
r1 := strings.NewReader("first reader ")
r2 := strings.NewReader("second reader ")
r3 := strings.NewReader("third reader")
r := io.MultiReader(r1, r2, r3)
package pizza
type Pizza interface {
GetPrice() float64
GetDescription() string
}
type Margherita struct{}
func (m *Margherita) GetPrice() float64 {
package network
type NetworkElement interface {
// methods to interact with the element
GetName() string
GetType() string
}
type Router struct {
name string
package main
import "fmt"
// Shape is the interface that all shapes must implement
type Shape interface {
Area() float64
}
// Rectangle represents a rectangle shape
type GUI interface {
Draw()
HandleEvent(event interface{})
}
type Button struct {
x, y, width, height int
label string
}