Created
August 8, 2021 10:45
-
-
Save BWbwchen/8488fa5ff67c9927c8154e857bc4c12c to your computer and use it in GitHub Desktop.
This file contains 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" | |
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