Skip to content

Instantly share code, notes, and snippets.

View arriqaaq's full-sized avatar
🎯
Focusing

Farhan arriqaaq

🎯
Focusing
View GitHub Profile
type FileSystem interface {
Open() (io.ReadCloser, error)
List() ([]string, error)
}
type File struct {
name string
path string
}
type Logger interface {
Println(v ...interface{})
Fatalln(v ...interface{})
}
type Logrus struct {
*logrus.Logger
}
func (l *Logrus) Println(v ...interface{}) {
type Database interface {
Insert(data interface{}) error
Retrieve(id string) (interface{}, error)
}
type MySQL struct {
connection *sql.DB
}
func (m *MySQL) Insert(data interface{}) error {
package main
import (
"fmt"
"sync"
)
type LegacyService struct {
}
package main
import "fmt"
type LegacyPrinter struct {
}
func (l *LegacyPrinter) Print(s string) {
fmt.Println(s)
}
type Database interface {
SaveData(data string) error
}
type MySQL struct {
// fields and methods
}
func (m *MySQL) SaveData(data string) error {
// code to save data to MySQL
type Singleton struct {
count int
}
var instance *Singleton
func GetInstance() *Singleton {
if instance == nil {
instance = &Singleton{}
}
type Config struct {
// fields and methods
}
var config *Config
func GetConfig() *Config {
if config == nil {
config = &Config{}
}
type Database struct {
// fields and methods
}
var db *Database
func GetDatabase() *Database {
if db == nil {
db = &Database{}
}
type Logger struct {
file *os.File
}
func (l *Logger) Log(message string) {
_, _ = l.file.WriteString(message + "\n")
}
var logger *Logger