Created
October 31, 2020 08:10
-
-
Save zzerjae/0e8feaefc86a5b38ea0d9c238bf63df2 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 | |
type User struct { | |
id int64 | |
name string | |
} | |
type DB interface { | |
GetUser(id int64) (*User, error) | |
} | |
type MemDB struct {} | |
func (m *MemDB) GetUser(id int64) (*User, error) { | |
... | |
} | |
type PostgreDB struct {} | |
func (p *PostgresDB) GetUser(id int64) (*User, error) { | |
... | |
} | |
func (p *PostgresDB) ListUsers(ids []int64) ([]*User, error) { | |
... | |
} | |
type Service struct { | |
db DB | |
} | |
fuc main() { | |
memDB := MemDB{} | |
postgreDB := PostgreDB{} | |
svc := Service{ | |
db := &memDB // postgreDB로 대체 가능 | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
32번째 줄에 typo가 있네요~ fuc -> func