Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Go CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v6

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.26'
cache: true

- name: Install dependencies
run: go mod download

- name: Run tests with coverage
run: go test -v -coverprofile=coverage.out ./... -tags unit

- name: Show coverage
run: go tool cover -func=coverage.out
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
compiled
main
api
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
SHELL := /bin/bash
DOCKER := /usr/bin/docker

run:
run-main:
go run ./cmd/main;

build:
go build -o ./compiled ./cmd/main
go build -o ./main ./cmd/main
go build -o ./api ./cmd/api

test:
go test -v ./...
go test -v ./... -tags=unit -failfast

docker-build:
docker build .
docker-build-api:
docker build . -t api

docker-run:
docker run --rm -it -p 8080:8080 api
docker run --rm -itd -p 8080:8080 api
41 changes: 26 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,75 @@

This repository provides a clean and organized starter structure for building scalable Go applications.

## Requirements
With examples for API and a simple binary, you can take them and expand as you need and adding internal app logic into internal folder (because of this is empty, depends on you mate)

## Requirements on your machine

- docker
- go
- go (>=1.26)
- make

## Features

- Organized into `cmd` directory, as entrypoint and example for a basic hello world example.
- Make file with basic go commands to compile.
- Organized into `cmd` directory, as entrypoint and example for a basic hello world or api.
- Makefile with basic go commands to compile.
- Clean and minimal baseline for Go development.

## Project Structure

```
cmd/main # Entry point as a basic program
cmd/api # Entry point as a basic api
Makefile # Common development commands
```

# Getting Started

1. Clone this repo
1. Clone this repo run:

```
git clone https://github.com/carlRondoni/go-basic-env.git
git clone {url/ssh repo}
cd go-basic-env
```

2. Initilize the module:
2. Initialize the module in case you don't want to have same module name. Remove `go.mod` and `go.sum` and run:

```
go mod init {your-project-here}
go mod init {your-project-name/url-here}
go mod tidy
```

3. Do your go code. Check example on `cmd/main`.
3. Do your code. Check examples on `cmd/main` or `cmd/api` for the entrypoints and extend it to internal.

4. Run the go code locally:
4. Run the `cmd/main` locally:

```
make run
make run-main
```

5. For compile the file from the code:
5. To compile the binaries from the cmd:

```
make build
```

6. To run tests`:
6. To run unit tests:

```
make test
````
```

7. To run api server:

```
make docker-run
```

# Next Steps

- [ ] cmd/command as an example for cli code
- [ ] logs in grafana api -> alloy -> loki -> grafana (docker compose + makefile commands)
- [ ] traces in grafana api (docker compose updates)
- [ ] cmd/command as an example for cli code.

# License

Expand Down
2 changes: 2 additions & 0 deletions cmd/main/main_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build unit

package main

import (
Expand Down
Empty file removed tests/integration/.gitkeep
Empty file.