MCPcopy Create free account

hub / github.com/Evertras/go-interface-examples / types & classes

Types & classes14 in github.com/Evertras/go-interface-examples

InterfaceCurrentChampionGetter
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
StructDb
Db does some IO with a database, mocked here for simplicity
local-interfaces/db/db.go:9
StructGSLDataStore
GSLDataStore knows how to get GSL data
outside-world/less-velociraptors/data.go:9
StructGSLDataStore
GSLDataStore knows how to get GSL data
outside-world/no-velociraptors/data.go:9
StructLeaderboard
Leaderboard knows how to interact with top users
local-interfaces/leaderboard/leaderboard.go:35
StructNotifier
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
InterfaceTopScoreNotifier
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
InterfaceTopUserGetter
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
StructUser
User represents a user as it's stored in the database
local-interfaces/db/db.go:22
InterfaceUserDataStore
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
StructmockCurrentChampionGetter
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
StructmockTopScoreNotifier
local-interfaces/leaderboard/leaderboard_test.go:22
StructmockTopUserGetter
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
StructmockUserDataStore
local-interfaces/handlers/user_test.go:11