Skip to content

Instantly share code, notes, and snippets.

@BWbwchen
Created August 8, 2021 10:45
Show Gist options
  • Save BWbwchen/8488fa5ff67c9927c8154e857bc4c12c to your computer and use it in GitHub Desktop.
Save BWbwchen/8488fa5ff67c9927c8154e857bc4c12c to your computer and use it in GitHub Desktop.
package main
import "fmt"
type SQL struct {
table string
}
func (s SQL) Create () {
fmt.Println("Create")
}
func (s SQL) Read () {
fmt.Println("Read")
}
func (s SQL) Update (criteria string) {
fmt.Println("Update", criteria)
}
func (s SQL) Delete (criteria string) {
fmt.Println("Delete", criteria)
}
type ORM interface{
Create()
Read()
Update(string)
Delete(string)
}
func main() {
sqldb := SQL{"table"}
var db ORM = sqldb
db.Create()
db.Read()
db.Update("record")
db.Delete("table")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment