Skip to content

Commit

Permalink
fixed lint and improved readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
burkaydurdu committed Mar 6, 2022
1 parent 9347633 commit 6baeb65
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.idea
.mem/*.json
unit_coverage.out
shortly
dist/
*.out
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ lint:

.PHONY: unit-test
unit-test:
go test -v ./... -coverprofile=unit_coverage.out -short -tags=unit
go test -v ./... -coverprofile=unit_coverage.out -short -tags=unit

.PHONY: run
run:
go run .
52 changes: 46 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Shortly
___

Shortly is a URL shortener service.

## Required
Go version ``1.17.2``

Expand All @@ -17,12 +19,26 @@ go build .
```shell
go run .
```
```shell
make run
```

## Test
```shell
go test -v ./... -tags=unit
```
```shell
make unit-test
```

## Code Quality
#### Run lint
```shell
golangci-lint run -c .golangci.yml -v
```
```shell
make lint
```

## Dockerize
#### Build
Expand All @@ -34,24 +50,48 @@ docker build -t shortly .
docker run -p 6161:6161 shortly
```

## Kubernetes
Apply development file to k8s

```shell
kubectl apply -f k8s/deployment.yaml
```
📌 This service can run with 5 different pods. All pods use common data.

## Used Libraries

[Swagger](https://github.com/swaggo) For API Documentation </br>
[Testify](https://github.com/stretchr/testify) For Test

## Inception
[excalidraw](https://excalidraw.com/#json=gww-IAkHNXslZjEIwC4US,YrQX5EU2s--dIM9eeOrIBA)

## API DOC

### Swagger

Install swagger
```shell
go install github.com/swaggo/swag/cmd/swag@latest
```

Swagger Initialize
```shell
swag init
```
#### API DOC

**Dev**

First of all you must run the project.
http://localhost:6161/api/swagger/index.html

### Inception
[excalidraw](https://excalidraw.com/#json=gww-IAkHNXslZjEIwC4US,YrQX5EU2s--dIM9eeOrIBA)
**Production [Heroku]**

### Used Libraries
📃 [Shortly swagger API doc in live](https://sleepy-harbor-07771.herokuapp.com/api/swagger/index.html)

[Swagger](https://github.com/swaggo) For API Documentation </br>
[Testify](https://github.com/stretchr/testify) For Test
## It is Live in HEROKU

❗️️Heroku may remove project data for it is free that's why you don't may see your data.

📺 [Shortly Base URL](https://sleepy-harbor-07771.herokuapp.com) </br>
[Service Health](https://sleepy-harbor-07771.herokuapp.com/api/v1/health)
6 changes: 4 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (c *Config) Print() {
func shortlyViberString(envKey, defaultKey string) string {
envValue := os.Getenv(envKey)

if len(envValue) == 0 {
if envValue == "" {
return defaultKey
}

Expand All @@ -66,7 +66,9 @@ func shortlyViberString(envKey, defaultKey string) string {
func shortlyViberInt(envKey string, defaultValue int) int {
envValue := os.Getenv(envKey)

envIntegerValue, err := strconv.ParseInt(envValue, 10, 64)
base, bit := 10, 64

envIntegerValue, err := strconv.ParseInt(envValue, base, bit)

if err != nil {
return defaultValue
Expand Down

0 comments on commit 6baeb65

Please sign in to comment.