Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/Evertras/go-interface-examples
/ functions
Functions
51 in github.com/Evertras/go-interface-examples
⨍
Functions
51
◇
Types & classes
14
↓ 3 callers
Function
New
New creates a new Leaderboard ready to do leaderboard things Accept interfaces, return implementations!
local-interfaces/leaderboard/leaderboard.go:43
↓ 3 callers
Function
NewGSLDataStore
NewGSLDataStore returns a GSLDataStore ready to tell us about the GSL
outside-world/less-velociraptors/data.go:14
↓ 3 callers
Method
NotifyTopPlayers
NotifyTopPlayers will send a notification to the top X players
local-interfaces/leaderboard/leaderboard.go:51
↓ 3 callers
Function
gslCurrentChampionHandler
Creates a handler that writes the current champion to the client. Now we're creating a handler and 'injecting' the data store that it will use to get
outside-world/less-velociraptors/server.go:15
↓ 3 callers
Function
gslCurrentChampionHandler
Creates a handler that writes the current champion to the client. Now our handler is saying something very powerful. It's saying "I need something t
outside-world/no-velociraptors/server.go:23
↓ 2 callers
Function
DeleteUserHandler
DeleteUserHandler creates an HTTP handler that deletes a user from the store
local-interfaces/handlers/user.go:40
↓ 2 callers
Method
GetCurrentChampion
()
outside-world/no-velociraptors/server.go:15
↓ 1 callers
Method
DeleteUser
(ctx context.Context, id string)
local-interfaces/handlers/user.go:19
↓ 1 callers
Method
GetTopUsers
(ctx context.Context, count int)
local-interfaces/leaderboard/leaderboard.go:23
↓ 1 callers
Method
GetUserScore
(ctx context.Context, id string)
local-interfaces/handlers/user.go:18
↓ 1 callers
Function
GetUserScoreHandler
GetUserScoreHandler creates an HTTP handler that can get a user's score
local-interfaces/handlers/user.go:23
↓ 1 callers
Function
New
New returns a new Notifier ready to send notifications Doesn't actually do anything, but real code will do stuff here...
local-interfaces/notifications/notifier.go:18
↓ 1 callers
Function
New
New returns a new Db ready to do Db things. Notice we don't provide an interface here! We only provide the concrete implementation. Accept interfac
local-interfaces/db/db.go:17
↓ 1 callers
Function
NewGSLDataStore
NewGSLDataStore returns a GSLDataStore ready to tell us about the GSL
outside-world/no-velociraptors/data.go:14
↓ 1 callers
Method
NotifyTopScore
(ctx context.Context, id string, score int)
local-interfaces/leaderboard/leaderboard.go:31
↓ 1 callers
Function
gslCurrentChampionHandler
(res http.ResponseWriter, req *http.Request)
outside-world/simple/server.go:7
↓ 1 callers
Function
gslCurrentChampionHandler
(res http.ResponseWriter, req *http.Request)
outside-world/velociraptors/server.go:9
↓ 1 callers
Function
runServer
Runs the server on the specified address with the given data store Notice we added the data store here as a parameter. To run our server, we must ha
outside-world/less-velociraptors/server.go:34
↓ 1 callers
Function
runServer
Runs a server that lets us see GSL info
outside-world/simple/server.go:13
↓ 1 callers
Function
runServer
(address string)
outside-world/velociraptors/server.go:23
↓ 1 callers
Function
runServer
Runs the server on the specified address with the given data store Our server is
outside-world/no-velociraptors/server.go:40
Method
AwardPoints
AwardPoints gives points to all the users in the ids array
local-interfaces/db/db.go:75
Method
CreateUser
CreateUser creates a user starting with a score of 0
local-interfaces/db/db.go:53
Method
DeleteUser
(ctx context.Context, id string)
local-interfaces/handlers/user_test.go:22
Method
DeleteUser
DeleteUser deletes a user with the given ID
local-interfaces/db/db.go:59
Method
GetCurrentChampion
GetCurrentChampion returns the name of the current GSL champion
outside-world/less-velociraptors/data.go:21
Method
GetCurrentChampion
We match the interface that our handler requires, so we can pass it in to the handler
outside-world/no-velociraptors/server_test.go:18
Method
GetCurrentChampion
GetCurrentChampion returns the name of the current GSL champion
outside-world/no-velociraptors/data.go:21
Method
GetTopUsers
(ctx context.Context, count int)
local-interfaces/leaderboard/leaderboard_test.go:18
Method
GetTopUsers
GetTopUsers returns the top X users ranked by score Note that it makes sense here to return full user information, or at least some struct that conta
local-interfaces/db/db.go:69
Method
GetUser
GetUser returns a user's full information from the database Notice this returns a User, which is part of this package. This means that any interface
local-interfaces/db/db.go:33
Method
GetUserScore
(ctx context.Context, id string)
local-interfaces/handlers/user_test.go:18
Method
GetUserScore
GetUserScore returns a user's score from their ID Notice this function signature doesn't contain any package-specific types, which means any interfac
local-interfaces/db/db.go:47
Method
NotifyPasswordUpdate
NotifyPasswordUpdate notifies a user that their password has been updated
local-interfaces/notifications/notifier.go:32
Method
NotifyTopScore
NotifyTopScore sends a notification to a user about their top score
local-interfaces/notifications/notifier.go:23
Method
NotifyTopScore
(ctx context.Context, id string, count int)
local-interfaces/leaderboard/leaderboard_test.go:27
Function
TestDeleteUserDeletesUserIDFromBody
(t *testing.T)
local-interfaces/handlers/user_test.go:56
Function
TestGSLCurrentChampionIsTY
(t *testing.T)
outside-world/less-velociraptors/server_test.go:9
Function
TestGSLCurrentChampionIsTY
(t *testing.T)
outside-world/simple/server_test.go:8
Function
TestGSLCurrentChampionIsTY
(t *testing.T)
outside-world/velociraptors/server_test.go:9
Function
TestGSLCurrentChampionReturned
(t *testing.T)
outside-world/no-velociraptors/server_test.go:26
Function
TestGSLCurrentChampionReturns500WhenFileDoesntExist
On the bright side, we can add this test now!
outside-world/less-velociraptors/server_test.go:41
Function
TestGSLCurrentChampionReturns500WhenGetterFails
This test is even more sensible now
outside-world/no-velociraptors/server_test.go:54
Function
TestGetUserScoreHandlerReturnsScore
(t *testing.T)
local-interfaces/handlers/user_test.go:32
Function
TestNotifyTopPlayersErrorsWhenGetterFails
(t *testing.T)
local-interfaces/leaderboard/leaderboard_test.go:37
Function
TestNotifyTopPlayersSendsNotificationsToSpecifiedNumberOfPlayers
(t *testing.T)
local-interfaces/leaderboard/leaderboard_test.go:59
Function
main
()
outside-world/less-velociraptors/main.go:7
Function
main
()
outside-world/simple/main.go:7
Function
main
()
outside-world/velociraptors/main.go:7
Function
main
()
outside-world/no-velociraptors/main.go:7
Function
main
()
local-interfaces/cmd/main.go:12