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 user | |
import ( | |
"bytes" | |
"errors" | |
"fmt" | |
"time" | |
"github.com/google/uuid" | |
) |
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 entity | |
type Entity struct { | |
fieldOne string | |
} | |
type Option func(e *Entity) | |
func FieldOne(fieldOne string) Option { | |
return func(e *Entity) { |
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
//Build uses config and its factory functions to build a new App. | |
//If err is nil, the returned App is ready to Run. | |
func (ab *AppBuilder) Build(config *config.Config) (app *App, err error) { | |
var sqlRepo *sqlrepo.Repo | |
var dbCloser io.Closer | |
defer func() { | |
if err != nil && dbCloser != nil { | |
dbCloser.Close() | |
} |
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
//getClient retrieves and sends a single Client. | |
func (a *API) getClient(w http.ResponseWriter, r *http.Request) { | |
client, ok := a.getClientEntity(w, r) | |
if !ok { | |
return | |
} | |
a.sendData(w, client, http.StatusOK) | |
} |
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
//Handler is a handler type that understands how to work with Client commands. | |
type Handler struct { | |
//Clients is the Client repository to use within Command handling. | |
Clients client.Repo | |
} | |
//CreateClient attempts to create a new Client and add it to h.Clients. | |
//Cmd must be of type *CreateClientCommand. | |
//The result, if not nil and without error, will be a *client.Client. | |
func (h *Handler) CreateClient(ctx context.Context, cmd cbus.Command) (interface{}, error) { |
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
//QueryRepo provides methods for retrieving Users. | |
type QueryRepo interface { | |
//Get should return the User whose Id equals id. | |
// | |
//An error should be returned if the User does not exist or there was an error | |
//attempting to load the User. | |
Get(ctx context.Context, id data.Id) (*User, error) | |
//GetEmail should return the User whose Email equals email. | |
// |
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
import React, { Component, PropTypes } from 'react'; | |
export default class ClientDashboard extends Component { | |
static propTypes = { | |
clientId: PropTypes.string.isRequired, | |
client: PropTypes.object, | |
fetchClient: PropTypes.func.isRequired, | |
} | |
componentWillMount() { |
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" | |
) | |
func main() { | |
for i := 1; i <= 9; i++ { | |
for count := 0; count < i; count++ { | |
fmt.Print(i) |