Skip to content

Commit

Permalink
initial commit wip
Browse files Browse the repository at this point in the history
  • Loading branch information
patinthehat committed Oct 18, 2024
1 parent 4398ca1 commit 577fde0
Show file tree
Hide file tree
Showing 18 changed files with 228 additions and 727 deletions.
2 changes: 2 additions & 0 deletions .custom-hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ if [ ! -z "$GO_FILES_STAGED" ] && [ "$GO_FILES_STAGED" != "0" ]; then
SRC_PATHS="./**"
fi

SRC_PATHS="."

echo "[pre-commit] $GOLINT_BIN run -c ./.golangci.yaml --new-from-rev $LAST_COMMIT $SRC_PATHS"

$GOLINT_BIN run -c ./.golangci.yaml --new-from-rev $LAST_COMMIT $SRC_PATHS
Expand Down
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github: {{project.vendor.github}}
github: permafrost-dev
2 changes: 1 addition & 1 deletion .github/SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Security Policy

If you discover any security related issues, please email {{project.author.email}} instead of using the issue tracker.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.

4 changes: 2 additions & 2 deletions .github/workflows/run-goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
with:
distribution: goreleaser
version: v2
args: release --clean --skip-docker
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} # goreleaser-pro key
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} # goreleaser-pro key
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.env
.env.*
!.env.example
*.bak

### Git ###
# Created by git for backups. To disable backups in Git:
Expand Down
24 changes: 1 addition & 23 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,6 @@ run:
# Include test files or not. Default: true
tests: true

skip-dirs:
- .custom-hooks
- .github
- .task
- .trunk
- .vscode
- assets
- build
- dist
- templates
- tools

# Which files to skip: they will be analyzed, but issues from them won't be reported.
# Default value is empty list,
# but there is no need to include all autogenerated files,
# we confidently recognize autogenerated files.
# If it's not please let us know.
# "/" will be replaced by current OS file path separator to properly work on Windows.
# skip-files:
# - tools/**/*.go

allow-parallel-runners: true
concurrency: 8

Expand All @@ -46,7 +25,7 @@ severity:

linters-settings:
gocyclo:
min-complexity: 20
min-complexity: 30

funlen:
lines: 100
Expand All @@ -70,5 +49,4 @@ linters-settings:
locale: US

nestif:
max-nesting: 3
min-complexity: 4 # Minimal complexity of if statements to report. - Default: 5
15 changes: 3 additions & 12 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ archives:

builds:
- main: './main.go'
binary: '{{project.name}}'
binary: 'pg-log-analyzer'
mod_timestamp: '{{ .CommitTimestamp }}'
flags:
- -trimpath
Expand All @@ -30,23 +30,14 @@ builds:
- linux_amd64
- darwin_arm64
- darwin_amd64

# brews:
# - name: '{{project.name}}'
# homepage: 'https://github.com/{{project.vendor.github}}/{{project.name}}'
# description: '{{project.description}}'
# license: "MIT"
# repository:
# owner: '{{project.vendor.github}}'
# name: homebrew-{{project.name}}
# branch: main
- windows_amd64

checksum:
name_template: "checksums.txt"
algorithm: sha256

snapshot:
name_template: "{{ incpatch .Version }}-next"
version_template: "{{ incpatch .Version }}-next"

changelog:
sort: asc
Expand Down
23 changes: 18 additions & 5 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
The MIT License (MIT)
Copyright © {{date.year}} {{project.vendor.name}}
MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Copyright (c) 2024 Permafrost Software <[email protected]>

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
38 changes: 3 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,10 @@
# {{project.name.full}}
# pg-log-analyzer

---

<!-- ==START TEMPLATE README== -->

<p align="center">
<img style="width: 80%;" src="assets/social-card.png" alt="go project template" />
</p>

## Description

This repository is a starter template for Golang projects using the latest version of Go.
Use it to create command-line applications, web apps, and more.

It includes:

- configuration and workflow for `goreleaser`, a tool for building and publishing Go binaries.
- configuration for `golangci-lint`, a tool for Go that runs many linters in parallel.
- configuration for `task`, a tool similar to `make`. To download `task`, see the [task project page](https://github.com/go-task/task/).

Also included is a configuration and workflow for Dependabot, a tool for keeping dependencies up to date.
Dependencies are updated automatically and pull requests are created to merge the changes; minor and patch version updates are automatically merged.

## Template Setup

To configure, run:

```bash
go run tools/configure-project.go
```

The configure script will ask you a series of questions that will customize the template with values such as your name, GitHub username, email address, use of optional packages, and more.

Some of the default values are automatically determined based on your git configuration, but you may change any of the values when prompted.

<!-- ==END TEMPLATE README== -->

{{project.description}}
analyze postgres server logs

## Setup

Expand Down Expand Up @@ -67,7 +35,7 @@ Please review [our security policy](../../security/policy) on how to report secu

## Credits

- [{{project.author.name}}](https://github.com/{{project.author.github}})
- [Patrick Organ](https://github.com/patinthehat)
- [All Contributors](../../contributors)

## License
Expand Down
18 changes: 9 additions & 9 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ tasks:
deps:
- task: update-version-file
cmds:
- task: build-{{project.name}}
- task: build-pg-log-analyzer

clean:
desc: Cleans up build artifacts
preconditions:
- test -d ./dist
- test -f ./dist/{{project.name}}
- test -f ./dist/pg-log-analyzer
cmds:
- rm -f ./dist/{{project.name}}
- rm -f ./dist/pg-log-analyzer

lint:
cmds:
- task: lint-dotenv
- task: lint-{{project.name}}
- task: lint-pg-log-analyzer

update-version-file:
vars:
Expand All @@ -48,7 +48,7 @@ tasks:
cmds:
- dotenv-linter {{.DOTENV_FILES}}

lint-{{project.name}}:
lint-pg-log-analyzer:
internal: true
vars:
GO_SRC_DIRS:
Expand All @@ -59,8 +59,8 @@ tasks:
cmds:
- golangci-lint run {{.GO_SRC_DIRS}}

build-{{project.name}}:
desc: Builds {{project.name}} binary
build-pg-log-analyzer:
desc: Builds pg-log-analyzer binary
vars:
GIT_COMMIT:
sh: git log -n 1 --format=%h
Expand All @@ -70,10 +70,10 @@ tasks:
- './internal/**/*.go'
- './main.go'
generates:
- ./dist/{{project.name}}
- ./dist/pg-log-analyzer
cmds:
- mkdir -p ./dist
- go build -trimpath -ldflags="-s -w -X main.Version={{.VERSION}}-{{.GIT_COMMIT}}" -o dist/{{project.name}} .
- go build -trimpath -ldflags="-s -w -X main.Version={{.VERSION}}-{{.GIT_COMMIT}}" -o dist/pg-log-analyzer .

release:
desc: Creates a new snapshot release
Expand Down
2 changes: 1 addition & 1 deletion app/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package app
package main

var Version = "0.0.0"
Binary file removed assets/social-card.png
Binary file not shown.
Binary file removed assets/social-card.xcf
Binary file not shown.
51 changes: 51 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
"os"

"github.com/spf13/cobra"
)



// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "pg-log-analyzer",
Short: "A brief description of your application",
Long: `A longer description that spans multiple lines and likely contains
examples and usage of using your application. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
// Uncomment the following line if your bare application
// has an action associated with it:
// Run: func(cmd *cobra.Command, args []string) { },
}

// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}

func init() {
// Here you will define your flags and configuration settings.
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.

// rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.pg-log-analyzer.yaml)")

// Cobra also supports local flags, which will only run
// when this action is called directly.
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}


10 changes: 8 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
module github.com/vendor-name/project-name
module github.com/permafrost-dev/pg-log-analyzer

go 1.20
go 1.23

require github.com/blang/semver v3.5.1+incompatible

require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
)
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading

0 comments on commit 577fde0

Please sign in to comment.