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
49 changes: 49 additions & 0 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: 1.26
- run: go build ./...

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: 1.26
- uses: golangci/golangci-lint-action@v9
with:
version: v2.12

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: 1.26
- run: go test ./... -race -cover

cli-scaffold:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-go@v7
with:
go-version: 1.26
- name: CLI scaffolds a buildable project
run: |
go build -o /tmp/summer ./cmd/summer
cd $(mktemp -d)
/tmp/summer -b main init <<< "testproject"
go mod tidy
go build -o /tmp/build/ ./...
7 changes: 7 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: "2"
linters:
default: standard

formatters:
enable:
- gofmt
15 changes: 12 additions & 3 deletions cmd/summer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package main
import (
"bufio"
"fmt"
"github.com/spf13/cobra"
"io"
"os"
"os/exec"
"path/filepath"
"strings"

"github.com/spf13/cobra"
)

const (
Expand Down Expand Up @@ -347,7 +348,12 @@ func copyFileContents(srcFile, dstFile string) (err error) {
if err != nil {
return
}
defer in.Close()
defer func(in *os.File) {
err := in.Close()
if err != nil {
return
}
}(in)

info, err := in.Stat()
if err != nil {
Expand All @@ -363,7 +369,10 @@ func copyFileContents(srcFile, dstFile string) (err error) {
if err != nil {
_ = os.Remove(dstFile)
}
out.Close()
err := out.Close()
if err != nil {
return
}
}()

_, err = io.Copy(out, in)
Expand Down
11 changes: 0 additions & 11 deletions pkg/log/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,6 @@ func WithContext(ctx context.Context, logger *zap.Logger) *zap.Logger {
return logger
}

// prettyEncodeCaller add padding to the caller string
func prettyEncodeCaller(caller zapcore.EntryCaller, enc zapcore.PrimitiveArrayEncoder) {
const fixedWidth = 25
callerStr := caller.TrimmedPath()
if len(callerStr) < fixedWidth {
callerStr += strings.Repeat(" ", fixedWidth-len(callerStr))
}
callerStr += "\t"
enc.AppendString(callerStr)
}

// relativePrettyCallerEncoder returns a zapcore.CallerEncoder that formats the caller path relative to the root directory
// it enables clickable links in the GoLand console output
func relativePrettyCallerEncoder(rootDir string) zapcore.CallerEncoder {
Expand Down