Skip to content

Commit

Permalink
Initial project with a simple hello world
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Bragg committed Dec 25, 2024
1 parent a4b5bc1 commit 58a6e92
Show file tree
Hide file tree
Showing 10 changed files with 208 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[{*.go,Makefile,.gitmodules,go.mod,go.sum}]
indent_style = tab

[*.md]
indent_style = tab
trim_trailing_whitespace = false

[*.{yml,yaml,json}]
indent_style = space
indent_size = 2

[*.{js,jsx,ts,tsx,css,less,sass,scss,vue,py}]
indent_style = space
indent_size = 4
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* -text
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ go.work.sum

# env file
.env

bin/
30 changes: 30 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
run:
timeout: 5m
tests: true

output:
# Use the updated format configuration
formats:
- format: colored-line-number
path: stdout

linters-settings:
errcheck:
exclude-functions:
- fmt.Printf

revive:
config: ./revive.toml

linters:
enable:
- revive
- unused
- staticcheck
- gosimple
- govet
- errcheck
enable-all: false

issues:
exclude-use-default: false
89 changes: 89 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Variables
APP_NAME=nap-and-go
DOCKER_IMAGE=$(APP_NAME):latest
DOCKER_COMPOSE_FILE=docker-compose.yaml

# Go build parameters
GO_BUILD_CMD=go build
GO_FILES=./...

# Targets
.PHONY: all build bot web run lint test clean docker docker-compose up down info

# Default target
all: build

# Build both bot and web binaries
build: bot

# Build the Discord bot binary
bot:
$(GO_BUILD_CMD) -o bin/bot ./cmd/bot

# Build the web interface binary
web:
$(GO_BUILD_CMD) -o bin/web ./cmd/web

# Run both bot and web
run: build
@echo "Starting bot and web interface..."
./bin/bot & ./bin/web

# Lint the code
lint:
golangci-lint run ./...

# Test the code
test:
go test -v $(GO_FILES)

# Clean up binaries and other artifacts
clean:
@echo "Cleaning up..."
rm -rf bin/

# Build Docker image
docker:
@echo "Building Docker image..."
docker build -t $(DOCKER_IMAGE) .

# Run using Docker Compose
docker-compose:
@echo "Running Docker Compose..."
docker-compose -f $(DOCKER_COMPOSE_FILE) up --build

# Start Docker Compose
up:
@echo "Starting services..."
docker-compose -f $(DOCKER_COMPOSE_FILE) up

# Stop Docker Compose
down:
@echo "Stopping services..."
docker-compose -f $(DOCKER_COMPOSE_FILE) down


# ------------------------------------------------------------------------------
GIT_COMMIT = $(shell git rev-parse HEAD)
GIT_SHA = $(shell git rev-parse --short HEAD)
GIT_TAG = $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null)
GIT_DIRTY = $(shell test -n "`git status --porcelain`" && echo "dirty" || echo "clean")

ifdef VERSION
BINARY_VERSION = $(VERSION)
endif
BINARY_VERSION ?= ${GIT_TAG}

VERSION_METADATA = unreleased

# Clear the "unreleased" string in BuildMetadata
ifneq ($(GIT_TAG),)
VERSION_METADATA =
endif

info:
@echo "Version: ${VERSION}"
@echo "Git Tag: ${GIT_TAG}"
@echo "Git Commit: ${GIT_COMMIT}"
@echo "Git Tree State: ${GIT_DIRTY}"

10 changes: 10 additions & 0 deletions cmd/bot/bot.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Initializes and runs the Discord bot
package main

import "fmt"

import "rsc.io/quote"

func main() {
fmt.Println(quote.Go())
}
19 changes: 19 additions & 0 deletions config/revive.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Output format
format = "friendly"

# Rules configuration
[rule]
name = "indent-error-flow"
enabled = true
severity = "warning"

[rule]
name = "error-strings"
enabled = true
severity = "warning"
arguments = ["lowercase"]

# Exclusions
[exclude]
files = ["**/*.pb.go"]
directories = ["vendor"]
10 changes: 10 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/faulteh/nap-and-go

go 1.23.4

require rsc.io/quote v1.5.2

require (
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c // indirect
rsc.io/sampler v1.3.0 // indirect
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:qgOY6WgZOaTkIIMiVjBQcw93ERBE4m30iBm00nkL0i8=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
rsc.io/quote v1.5.2 h1:w5fcysjrx7yqtD/aO+QwRjYZOKnaM9Uh2b40tElTs3Y=
rsc.io/quote v1.5.2/go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0=
rsc.io/sampler v1.3.0 h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
19 changes: 19 additions & 0 deletions revive.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Output format
format = "friendly"

# Rules configuration
[rule]
name = "indent-error-flow"
enabled = true
severity = "warning"

[rule]
name = "error-strings"
enabled = true
severity = "warning"
arguments = ["lowercase"]

# Exclusions
[exclude]
files = ["**/*.pb.go"]
directories = ["vendor"]

0 comments on commit 58a6e92

Please sign in to comment.