mirror of
https://github.com/onyx-and-iris/q3rcon.git
synced 2026-04-19 16:23:31 +00:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3be7ddb36b | |||
| c22b07808f | |||
| c015770c2c | |||
| cd15e89837 | |||
| c3e8013c4f | |||
| 89dd2d2eb1 | |||
| c04301562e | |||
| e25104091d | |||
| c478598112 | |||
|
|
b224f2dc43 | ||
|
|
c4b587ee65 | ||
|
|
8f252951ff |
30
.github/workflows/golang-ci.yml
vendored
Normal file
30
.github/workflows/golang-ci.yml
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: ['main']
|
||||||
|
paths:
|
||||||
|
- '**.go'
|
||||||
|
pull_request:
|
||||||
|
branches: ['main']
|
||||||
|
paths:
|
||||||
|
- '**.go'
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
name: Lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name == 'pull_request'
|
||||||
|
timeout-minutes: 3
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.24'
|
||||||
|
- name: golangci-lint
|
||||||
|
uses: golangci/golangci-lint-action@v9
|
||||||
|
with:
|
||||||
|
version: v2.6.0
|
||||||
|
args: --config .golangci.yml
|
||||||
142
.golangci.yml
Normal file
142
.golangci.yml
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
version: '2'
|
||||||
|
|
||||||
|
run:
|
||||||
|
timeout: 3m
|
||||||
|
tests: true
|
||||||
|
go: '1.24'
|
||||||
|
|
||||||
|
linters:
|
||||||
|
disable: [errcheck, errorlint, godot, revive, staticcheck]
|
||||||
|
enable:
|
||||||
|
# Default enabled linters
|
||||||
|
- errcheck # Check for unchecked errors
|
||||||
|
- govet # Go's built-in vetting tool
|
||||||
|
- ineffassign # Detect ineffectual assignments
|
||||||
|
- staticcheck # Advanced static analysis
|
||||||
|
- unused # Check for unused code
|
||||||
|
# Additional useful linters
|
||||||
|
- misspell # Detect common misspellings
|
||||||
|
- unparam # Check for unused function parameters
|
||||||
|
- gosec # Security checks
|
||||||
|
- asciicheck # Check for non-ASCII characters
|
||||||
|
- errname # Check error variable names
|
||||||
|
- godot # Check for missing periods in comments
|
||||||
|
- revive # Highly configurable linter for style and correctness
|
||||||
|
- gocritic # Detect code issues and suggest improvements
|
||||||
|
- gocyclo # Check for cyclomatic complexity
|
||||||
|
- dupl # Check for code duplication
|
||||||
|
- predeclared # Check for shadowing of predeclared identifiers
|
||||||
|
- copyloopvar # Check for loop variable capture in goroutines
|
||||||
|
- errorlint # Check for common mistakes in error handling
|
||||||
|
- goconst # Check for repeated strings that could be constants
|
||||||
|
- gosmopolitan # Check for non-portable code
|
||||||
|
|
||||||
|
settings:
|
||||||
|
misspell:
|
||||||
|
locale: UK
|
||||||
|
|
||||||
|
errcheck:
|
||||||
|
check-type-assertions: true
|
||||||
|
check-blank: true
|
||||||
|
exclude-functions:
|
||||||
|
- fmt.Fprintf
|
||||||
|
- fmt.Fprintln
|
||||||
|
- fmt.Printf
|
||||||
|
- fmt.Println
|
||||||
|
- fmt.Errorf
|
||||||
|
|
||||||
|
revive:
|
||||||
|
severity: warning
|
||||||
|
rules:
|
||||||
|
# Code quality and style
|
||||||
|
- name: exported
|
||||||
|
arguments:
|
||||||
|
- 'checkPrivateReceivers'
|
||||||
|
- 'sayRepetitiveInsteadOfStutters'
|
||||||
|
- name: var-naming
|
||||||
|
- name: package-comments
|
||||||
|
- name: range-val-in-closure
|
||||||
|
- name: time-naming
|
||||||
|
- name: context-as-argument
|
||||||
|
- name: context-keys-type
|
||||||
|
- name: dot-imports
|
||||||
|
- name: empty-block
|
||||||
|
- name: error-return
|
||||||
|
- name: error-strings
|
||||||
|
- name: error-naming
|
||||||
|
- name: if-return
|
||||||
|
- name: increment-decrement
|
||||||
|
- name: indent-error-flow
|
||||||
|
- name: receiver-naming
|
||||||
|
- name: redefines-builtin-id
|
||||||
|
- name: superfluous-else
|
||||||
|
- name: unexported-return
|
||||||
|
- name: unreachable-code
|
||||||
|
- name: unused-parameter
|
||||||
|
- name: var-declaration
|
||||||
|
- name: blank-imports
|
||||||
|
- name: range
|
||||||
|
|
||||||
|
# Disabled rules (can be enabled if needed)
|
||||||
|
# - name: line-length-limit
|
||||||
|
# arguments: [120]
|
||||||
|
# - name: function-length
|
||||||
|
# arguments: [50, 0]
|
||||||
|
# - name: cyclomatic
|
||||||
|
# arguments: [10]
|
||||||
|
|
||||||
|
gosec:
|
||||||
|
excludes:
|
||||||
|
- G104 # Duplicated errcheck checks
|
||||||
|
- G115 # integer overflow conversion int -> uint32
|
||||||
|
|
||||||
|
exclusions:
|
||||||
|
warn-unused: false
|
||||||
|
rules:
|
||||||
|
# Exclude some linters from running on tests files.
|
||||||
|
- path: _test\.go
|
||||||
|
linters:
|
||||||
|
- gocyclo
|
||||||
|
- errcheck
|
||||||
|
- dupl
|
||||||
|
- gosec
|
||||||
|
|
||||||
|
paths:
|
||||||
|
- vendor
|
||||||
|
|
||||||
|
# Formatters configuration
|
||||||
|
formatters:
|
||||||
|
# Enable specific formatters
|
||||||
|
enable:
|
||||||
|
- gofumpt # Stricter gofmt alternative
|
||||||
|
- goimports # Organizes imports
|
||||||
|
- gci # Controls import order/grouping
|
||||||
|
- golines # Enforces line length
|
||||||
|
|
||||||
|
# Formatter-specific settings
|
||||||
|
settings:
|
||||||
|
goimports:
|
||||||
|
local-prefixes: [github.com/onyx-and-iris/q3rcon]
|
||||||
|
|
||||||
|
gci:
|
||||||
|
# Define import sections order
|
||||||
|
sections:
|
||||||
|
- standard # Standard library
|
||||||
|
- default # Everything else
|
||||||
|
- prefix(github.com/onyx-and-iris/q3rcon) # Current module
|
||||||
|
|
||||||
|
gofumpt:
|
||||||
|
extra-rules: true # Enable additional formatting rules
|
||||||
|
|
||||||
|
exclusions:
|
||||||
|
warn-unused: true
|
||||||
|
|
||||||
|
paths:
|
||||||
|
- vendor
|
||||||
|
|
||||||
|
issues:
|
||||||
|
# Limit the number of same issues reported to avoid spam
|
||||||
|
max-same-issues: 50
|
||||||
|
|
||||||
|
# Limit the number of issues per linter to keep output manageable
|
||||||
|
max-issues-per-linter: 100
|
||||||
@@ -22,6 +22,7 @@ builds:
|
|||||||
goos:
|
goos:
|
||||||
- linux
|
- linux
|
||||||
- windows
|
- windows
|
||||||
|
- darwin
|
||||||
goarch:
|
goarch:
|
||||||
- amd64
|
- amd64
|
||||||
|
|
||||||
@@ -46,6 +47,7 @@ changelog:
|
|||||||
exclude:
|
exclude:
|
||||||
- '^docs:'
|
- '^docs:'
|
||||||
- '^test:'
|
- '^test:'
|
||||||
|
- '^chore:'
|
||||||
|
|
||||||
release:
|
release:
|
||||||
footer: >-
|
footer: >-
|
||||||
|
|||||||
12
CHANGELOG.md
12
CHANGELOG.md
@@ -11,6 +11,18 @@ Before any major/minor/patch bump all unit tests will be run to verify they pass
|
|||||||
|
|
||||||
- [x]
|
- [x]
|
||||||
|
|
||||||
|
# [0.4.0] - 2026-02-15
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- macos build to releases
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- exitOnError() removed in favour of a [deferred exit function](https://github.com/onyx-and-iris/q3rcon/blob/cd15e8983726177d6edd985a8bf3d7f4e0d7f346/cmd/q3rcon/main.go#L21), this ensures the closer() cleanup function is always called.
|
||||||
|
- the included CLI now uses a [timeouts map](https://github.com/onyx-and-iris/q3rcon/blob/cd15e8983726177d6edd985a8bf3d7f4e0d7f346/cmd/q3rcon/main.go#L109).
|
||||||
|
- even though this is only an example implementation it should still be basically usable.
|
||||||
|
|
||||||
# [0.3.0] - 2025-04-05
|
# [0.3.0] - 2025-04-05
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|||||||
10
Taskfile.yml
10
Taskfile.yml
@@ -7,6 +7,7 @@ vars:
|
|||||||
|
|
||||||
WINDOWS: '{{.BIN_DIR}}/{{.PROGRAM}}_windows_amd64.exe'
|
WINDOWS: '{{.BIN_DIR}}/{{.PROGRAM}}_windows_amd64.exe'
|
||||||
LINUX: '{{.BIN_DIR}}/{{.PROGRAM}}_linux_amd64'
|
LINUX: '{{.BIN_DIR}}/{{.PROGRAM}}_linux_amd64'
|
||||||
|
MACOS: '{{.BIN_DIR}}/{{.PROGRAM}}_darwin_amd64'
|
||||||
GIT_COMMIT:
|
GIT_COMMIT:
|
||||||
sh: git log -n 1 --format=%h
|
sh: git log -n 1 --format=%h
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ tasks:
|
|||||||
cmds:
|
cmds:
|
||||||
- task: build-windows
|
- task: build-windows
|
||||||
- task: build-linux
|
- task: build-linux
|
||||||
|
- task: build-macos
|
||||||
|
|
||||||
vet:
|
vet:
|
||||||
desc: Vet the code
|
desc: Vet the code
|
||||||
@@ -38,11 +40,19 @@ tasks:
|
|||||||
desc: Build the q3rcon project for Windows
|
desc: Build the q3rcon project for Windows
|
||||||
cmds:
|
cmds:
|
||||||
- GOOS=windows GOARCH=amd64 go build -o {{.WINDOWS}} -ldflags="-X main.Version={{.GIT_COMMIT}}" ./cmd/{{.PROGRAM}}/
|
- GOOS=windows GOARCH=amd64 go build -o {{.WINDOWS}} -ldflags="-X main.Version={{.GIT_COMMIT}}" ./cmd/{{.PROGRAM}}/
|
||||||
|
internal: true
|
||||||
|
|
||||||
build-linux:
|
build-linux:
|
||||||
desc: Build the q3rcon project for Linux
|
desc: Build the q3rcon project for Linux
|
||||||
cmds:
|
cmds:
|
||||||
- GOOS=linux GOARCH=amd64 go build -o {{.LINUX}} -ldflags="-X main.Version={{.GIT_COMMIT}}" ./cmd/{{.PROGRAM}}/
|
- GOOS=linux GOARCH=amd64 go build -o {{.LINUX}} -ldflags="-X main.Version={{.GIT_COMMIT}}" ./cmd/{{.PROGRAM}}/
|
||||||
|
internal: true
|
||||||
|
|
||||||
|
build-macos:
|
||||||
|
desc: Build the q3rcon project for macOS
|
||||||
|
cmds:
|
||||||
|
- GOOS=darwin GOARCH=amd64 go build -o {{.MACOS}} -ldflags="-X main.Version={{.GIT_COMMIT}}" ./cmd/{{.PROGRAM}}/
|
||||||
|
internal: true
|
||||||
|
|
||||||
test:
|
test:
|
||||||
desc: Run tests
|
desc: Run tests
|
||||||
|
|||||||
@@ -7,18 +7,35 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
"github.com/onyx-and-iris/q3rcon"
|
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/onyx-and-iris/q3rcon"
|
||||||
)
|
)
|
||||||
|
|
||||||
func exitOnError(err error) {
|
func main() {
|
||||||
_, _ = fmt.Fprintf(os.Stderr, "Error: %s\n", err)
|
var exitCode int
|
||||||
os.Exit(1)
|
|
||||||
|
// Defer exit with the final exit code
|
||||||
|
defer func() {
|
||||||
|
if exitCode != 0 {
|
||||||
|
os.Exit(exitCode)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
closer, err := run()
|
||||||
|
if closer != nil {
|
||||||
|
defer closer()
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
exitCode = 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
// run executes the main logic of the application and returns a cleanup function and an error if any.
|
||||||
|
func run() (func(), error) {
|
||||||
var (
|
var (
|
||||||
host string
|
host string
|
||||||
port int
|
port int
|
||||||
@@ -30,9 +47,19 @@ func main() {
|
|||||||
flag.StringVar(&host, "host", "localhost", "hostname of the gameserver")
|
flag.StringVar(&host, "host", "localhost", "hostname of the gameserver")
|
||||||
flag.StringVar(&host, "h", "localhost", "hostname of the gameserver (shorthand)")
|
flag.StringVar(&host, "h", "localhost", "hostname of the gameserver (shorthand)")
|
||||||
flag.IntVar(&port, "port", 28960, "port on which the gameserver resides, default is 28960")
|
flag.IntVar(&port, "port", 28960, "port on which the gameserver resides, default is 28960")
|
||||||
flag.IntVar(&port, "p", 28960, "port on which the gameserver resides, default is 28960 (shorthand)")
|
flag.IntVar(
|
||||||
|
&port,
|
||||||
|
"p",
|
||||||
|
28960,
|
||||||
|
"port on which the gameserver resides, default is 28960 (shorthand)",
|
||||||
|
)
|
||||||
flag.StringVar(&rconpass, "rconpass", os.Getenv("RCON_PASS"), "rcon password of the gameserver")
|
flag.StringVar(&rconpass, "rconpass", os.Getenv("RCON_PASS"), "rcon password of the gameserver")
|
||||||
flag.StringVar(&rconpass, "r", os.Getenv("RCON_PASS"), "rcon password of the gameserver (shorthand)")
|
flag.StringVar(
|
||||||
|
&rconpass,
|
||||||
|
"r",
|
||||||
|
os.Getenv("RCON_PASS"),
|
||||||
|
"rcon password of the gameserver (shorthand)",
|
||||||
|
)
|
||||||
|
|
||||||
flag.BoolVar(&interactive, "interactive", false, "run in interactive mode")
|
flag.BoolVar(&interactive, "interactive", false, "run in interactive mode")
|
||||||
flag.BoolVar(&interactive, "i", false, "run in interactive mode")
|
flag.BoolVar(&interactive, "i", false, "run in interactive mode")
|
||||||
@@ -44,53 +71,69 @@ func main() {
|
|||||||
|
|
||||||
level, err := log.ParseLevel(loglevel)
|
level, err := log.ParseLevel(loglevel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exitOnError(fmt.Errorf("invalid log level: %s", loglevel))
|
return nil, fmt.Errorf("invalid log level: %s", loglevel)
|
||||||
}
|
}
|
||||||
log.SetLevel(level)
|
log.SetLevel(level)
|
||||||
|
|
||||||
if port < 1024 || port > 65535 {
|
if port < 1024 || port > 65535 {
|
||||||
exitOnError(fmt.Errorf("invalid port value, got: (%d) expected: in range 1024-65535", port))
|
return nil, fmt.Errorf("invalid port value, got: (%d) expected: in range 1024-65535", port)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(rconpass) < 8 {
|
if len(rconpass) < 8 {
|
||||||
exitOnError(fmt.Errorf("invalid rcon password, got: (%s) expected: at least 8 characters", rconpass))
|
return nil, fmt.Errorf(
|
||||||
|
"invalid rcon password, got: (%s) expected: at least 8 characters",
|
||||||
|
rconpass,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
rcon, err := connectRcon(host, port, rconpass)
|
client, closer, err := connectRcon(host, port, rconpass)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exitOnError(err)
|
return nil, fmt.Errorf("failed to connect to rcon: %w", err)
|
||||||
}
|
|
||||||
defer rcon.Close()
|
|
||||||
|
|
||||||
if !interactive {
|
|
||||||
runCommands(flag.Args(), rcon)
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Enter 'Q' to exit.\n>> ")
|
if interactive {
|
||||||
err = interactiveMode(rcon, os.Stdin)
|
fmt.Printf("Enter 'Q' to exit.\n>> ")
|
||||||
if err != nil {
|
err := interactiveMode(client, os.Stdin)
|
||||||
exitOnError(err)
|
if err != nil {
|
||||||
|
return closer, fmt.Errorf("interactive mode error: %w", err)
|
||||||
|
}
|
||||||
|
return closer, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
commands := flag.Args()
|
||||||
|
if len(commands) == 0 {
|
||||||
|
log.Debug("no commands provided, defaulting to 'status'")
|
||||||
|
commands = append(commands, "status")
|
||||||
|
}
|
||||||
|
runCommands(client, commands)
|
||||||
|
|
||||||
|
return closer, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func connectRcon(host string, port int, password string) (*q3rcon.Rcon, error) {
|
func connectRcon(host string, port int, password string) (*q3rcon.Rcon, func(), error) {
|
||||||
rcon, err := q3rcon.New(host, port, password)
|
client, err := q3rcon.New(host, port, password, q3rcon.WithTimeouts(map[string]time.Duration{
|
||||||
|
"map": time.Second,
|
||||||
|
"map_rotate": time.Second,
|
||||||
|
"map_restart": time.Second,
|
||||||
|
}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
return rcon, nil
|
|
||||||
|
closer := func() {
|
||||||
|
if err := client.Close(); err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return client, closer, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// runCommands runs the commands given in the flag.Args slice.
|
// runCommands runs the commands given in the flag.Args slice.
|
||||||
// If no commands are given, it defaults to running the "status" command.
|
// If no commands are given, it defaults to running the "status" command.
|
||||||
func runCommands(commands []string, rcon *q3rcon.Rcon) {
|
func runCommands(client *q3rcon.Rcon, commands []string) {
|
||||||
if len(commands) == 0 {
|
|
||||||
commands = append(commands, "status")
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, cmd := range commands {
|
for _, cmd := range commands {
|
||||||
resp, err := rcon.Send(cmd)
|
resp, err := client.Send(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
continue
|
continue
|
||||||
@@ -100,7 +143,7 @@ func runCommands(commands []string, rcon *q3rcon.Rcon) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// interactiveMode continuously reads from input until a quit signal is given.
|
// interactiveMode continuously reads from input until a quit signal is given.
|
||||||
func interactiveMode(rcon *q3rcon.Rcon, input io.Reader) error {
|
func interactiveMode(client *q3rcon.Rcon, input io.Reader) error {
|
||||||
scanner := bufio.NewScanner(input)
|
scanner := bufio.NewScanner(input)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
cmd := scanner.Text()
|
cmd := scanner.Text()
|
||||||
@@ -108,7 +151,7 @@ func interactiveMode(rcon *q3rcon.Rcon, input io.Reader) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := rcon.Send(cmd)
|
resp, err := client.Send(cmd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
continue
|
continue
|
||||||
|
|||||||
2
go.mod
2
go.mod
@@ -4,4 +4,4 @@ go 1.23.0
|
|||||||
|
|
||||||
require github.com/sirupsen/logrus v1.9.3
|
require github.com/sirupsen/logrus v1.9.3
|
||||||
|
|
||||||
require golang.org/x/sys v0.31.0 // indirect
|
require golang.org/x/sys v0.34.0 // indirect
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -9,8 +9,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
|
|||||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
|
||||||
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|||||||
BIN
img/mapname.png
BIN
img/mapname.png
Binary file not shown.
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 4.2 KiB |
BIN
img/status.png
BIN
img/status.png
Binary file not shown.
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 10 KiB |
9
makefile
9
makefile
@@ -5,24 +5,26 @@ BIN_DIR := bin
|
|||||||
|
|
||||||
WINDOWS=$(BIN_DIR)/$(PROGRAM)_windows_amd64.exe
|
WINDOWS=$(BIN_DIR)/$(PROGRAM)_windows_amd64.exe
|
||||||
LINUX=$(BIN_DIR)/$(PROGRAM)_linux_amd64
|
LINUX=$(BIN_DIR)/$(PROGRAM)_linux_amd64
|
||||||
|
MACOS=$(BIN_DIR)/$(PROGRAM)_darwin_amd64
|
||||||
VERSION=$(shell git log -n 1 --format=%h)
|
VERSION=$(shell git log -n 1 --format=%h)
|
||||||
|
|
||||||
.DEFAULT_GOAL := build
|
.DEFAULT_GOAL := build
|
||||||
|
|
||||||
.PHONY: fmt vet build windows linux test clean
|
.PHONY: fmt vet build windows linux macos test clean
|
||||||
fmt:
|
fmt:
|
||||||
$(GO) fmt ./...
|
$(GO) fmt ./...
|
||||||
|
|
||||||
vet: fmt
|
vet: fmt
|
||||||
$(GO) vet ./...
|
$(GO) vet ./...
|
||||||
|
|
||||||
build: vet windows linux | $(BIN_DIR)
|
build: vet windows linux macos | $(BIN_DIR)
|
||||||
@echo version: $(VERSION)
|
@echo version: $(VERSION)
|
||||||
|
|
||||||
windows: $(WINDOWS)
|
windows: $(WINDOWS)
|
||||||
|
|
||||||
linux: $(LINUX)
|
linux: $(LINUX)
|
||||||
|
|
||||||
|
macos: $(MACOS)
|
||||||
|
|
||||||
$(WINDOWS):
|
$(WINDOWS):
|
||||||
env GOOS=windows GOARCH=amd64 go build -v -o $(WINDOWS) -ldflags="-s -w -X main.version=$(VERSION)" ./cmd/$(PROGRAM)/
|
env GOOS=windows GOARCH=amd64 go build -v -o $(WINDOWS) -ldflags="-s -w -X main.version=$(VERSION)" ./cmd/$(PROGRAM)/
|
||||||
@@ -30,6 +32,9 @@ $(WINDOWS):
|
|||||||
$(LINUX):
|
$(LINUX):
|
||||||
env GOOS=linux GOARCH=amd64 go build -v -o $(LINUX) -ldflags="-s -w -X main.version=$(VERSION)" ./cmd/$(PROGRAM)/
|
env GOOS=linux GOARCH=amd64 go build -v -o $(LINUX) -ldflags="-s -w -X main.version=$(VERSION)" ./cmd/$(PROGRAM)/
|
||||||
|
|
||||||
|
$(MACOS):
|
||||||
|
env GOOS=darwin GOARCH=amd64 go build -v -o $(MACOS) -ldflags="-s -w -X main.version=$(VERSION)" ./cmd/$(PROGRAM)/
|
||||||
|
|
||||||
test:
|
test:
|
||||||
$(GO) test ./...
|
$(GO) test ./...
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user