Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/Evertras/go-interface-examples
/ types & classes
Types & classes
14 in github.com/Evertras/go-interface-examples
⨍
Functions
51
◇
Types & classes
14
Interface
CurrentChampionGetter
CurrentChampionGetter can get the current champion somehow This is a declaration of intent. Whoever asks for this interface is going to ask for "som
outside-world/no-velociraptors/server.go:14
Struct
Db
Db does some IO with a database, mocked here for simplicity
local-interfaces/db/db.go:9
Struct
GSLDataStore
GSLDataStore knows how to get GSL data
outside-world/less-velociraptors/data.go:9
Struct
GSLDataStore
GSLDataStore knows how to get GSL data
outside-world/no-velociraptors/data.go:9
Struct
Leaderboard
Leaderboard knows how to interact with top users
local-interfaces/leaderboard/leaderboard.go:35
Struct
Notifier
Notifier sends notifications to the user Actual implementation doesn't matter here, we're just including this to have something other than a database
local-interfaces/notifications/notifier.go:13
Interface
TopScoreNotifier
TopScoreNotifier notifies users they have a high score As above, focus on how this feels to read in terms of understanding the code in this package.
local-interfaces/leaderboard/leaderboard.go:30
Interface
TopUserGetter
TopUserGetter gets top users from somewhere Notice that we're tying ourselves to the database package here, but we'll live with it. The important pa
local-interfaces/leaderboard/leaderboard.go:22
Struct
User
User represents a user as it's stored in the database
local-interfaces/db/db.go:22
Interface
UserDataStore
UserDataStore can access and modify user data This is a little more broad and we're assuming the same type will have all these methods, but that's a
local-interfaces/handlers/user.go:17
Struct
mockCurrentChampionGetter
A simple mock that lets us specify who the current champion is, or even what error to return to test our error handling!
outside-world/no-velociraptors/server_test.go:11
Struct
mockTopScoreNotifier
local-interfaces/leaderboard/leaderboard_test.go:22
Struct
mockTopUserGetter
We mock our interface here; notice how simple and self-contained this can be when we don't have to worry about the full database functionality!
local-interfaces/leaderboard/leaderboard_test.go:13
Struct
mockUserDataStore
local-interfaces/handlers/user_test.go:11