Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Commit

Permalink
First version
Browse files Browse the repository at this point in the history
  • Loading branch information
eminetto committed May 17, 2018
1 parent 9febec9 commit abbdabe
Show file tree
Hide file tree
Showing 26 changed files with 1,134 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bin/
vendor/
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: go

go:
- "1.10.x"
- master
script: make ci
197 changes: 197 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true


[[constraint]]
branch = "master"
name = "github.com/juju/mgosession"

[[constraint]]
name = "github.com/stretchr/testify"
version = "1.2.1"

[[constraint]]
branch = "v2"
name = "gopkg.in/mgo.v2"

[prune]
go-tests = true
unused-packages = true
38 changes: 38 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.PHONY: all
all: build
FORCE: ;

SHELL := env BOOKMARK_ENV=$(BOOKMARK_ENV) $(SHELL)
BOOKMARK_ENV ?= dev

include config/$(BOOKMARK_ENV).env
export $(shell sed 's/=.*//' config/$(BOOKMARK_ENV).env)
BIN_DIR = $(PWD)/bin

.PHONY: build

clean:
rm -rf bin/*

dependencies:
dep ensure

build: dependencies build-api build-cmd

build-api:
go build -o ./bin/api api/main.go

build-cmd:
go build -o ./bin/search cmd/main.go

linux-binaries:
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -tags netgo -installsuffix netgo -o $(BIN_DIR)/api api/main.go
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -tags netgo -installsuffix netgo -o $(BIN_DIR)/search cmd/main.go

ci: dependencies test

test:
export BOOKMARK_ENV=$(BOOKMARK_ENV); go test ./...

fmt: ## gofmt and goimports all go files
find . -name '*.go' -not -wholename './vendor/*' | while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done
58 changes: 57 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,58 @@
# clean-architecture-go
# Clean Architecture in Go

Clean Architecture sample

## Post

[https://medium.com/@eminetto/clean-architecture-using-golang-b63587aa5e3f](https://medium.com/@eminetto/clean-architecture-using-golang-b63587aa5e3f)


## Build

make

## Run tests

make test

## API requests

### Add a bookmark

```
curl -X "POST" "http://localhost:8080/v1/bookmark" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d $'{
"tags": [
"git",
"social"
],
"name": "Github",
"description": "Github site",
"link": "http://github.com"
}'
```
### Search a bookmark

```
curl "http://localhost:8080/v1/bookmark?name=github" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json'
```

### Show all bookmarks

```
curl "http://localhost:8080/v1/bookmark" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json'
```

## CMD

### Search for a bookmark

```
./bin/search github
```
Loading

0 comments on commit abbdabe

Please sign in to comment.