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
func main() { | |
server := Wire() | |
server.Run() | |
} | |
func Wire() *http.Server { | |
cfgProvider := config.NewProvider() | |
svc := usecase.NewService(cfgProvider) | |
return http.NewServer(cfgProvider, svc) | |
} |
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
GOBIN := $(shell go env GOPATH)/bin | |
inspect: $(GOBIN)/golangci-lint | |
$(GOBIN)/golangci-lint run | |
$(GOBIN)/golangci-lint: | |
$(MAKE) install-golangci-lint | |
install-golangci-lint: | |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.46.2 | |
rm -rf ./v1.46.2 |
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
type Hashable interface { | |
Hash() []byte | |
} | |
type BasicThingy string | |
type StructThingy struct{} | |
// Implementation checks: | |
var _ Hashable = (BasicThingy)("") | |
var _ Hashable = &StructThingy{} |
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
public sendSms(String cell) { | |
assert PhoneValidationUtil.ValidNumber(cell); | |
// ... | |
} |
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
// IsAvailable will return true if the inventory item may | |
// be checked out - false otherwise. | |
func (i *InventoryItemImpl) IsAvailable() bool { | |
return i.available | |
} | |
// Checkout will mark the inventory item as unavilable. | |
// If the inventory item is not available, | |
// then an error is returned. | |
func (i *InventoryItemImpl) Checkout() 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
// FromInventoryItemView converts a view to JSON | |
func (e *EncoderServiceImpl) FromInventoryItemView(view *inventory.ViewVO) ([]byte, error) { | |
intermediary := mapViewIntermediary(view) | |
bytes, err := json.Marshal(intermediary) | |
if err != nil { | |
return nil, fmt.Errorf("could not convert inventory item view to json - marshal error: %w", err) | |
} | |
return bytes, nil | |
} |
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
// CreateServerFactory injects all the dependencies needed to create | |
// http.ServerFactory | |
func CreateServerFactory(source goConfig.Source) (http.ServerFactory, error) { | |
// Each "tap" below indicates a level of dependency | |
configStore, err := config.NewStoreImpl( | |
source, | |
) | |
if err != nil { | |
return nil, err | |
} |
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
apt install make |