diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index a3a3b41..025db87 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -3,21 +3,22 @@ # # Created: 18th August 2025 -# Updated: 3rd August 2026 +# Updated: 20th August 2026 # name: Go env: + GO_MIN_VERSION: '1.25' VERBOSITY: 1 on: push: branches: - - boilerplate + - master - dev + - boilerplate - idiomatic - - master - rc1 - rc2 - rc3 @@ -38,10 +39,6 @@ jobs: go-version: - '1.26' - '1.25' - - '1.24' - - '1.23' - - '1.22' - - '1.21' os: - macos-latest - ubuntu-latest @@ -65,3 +62,20 @@ jobs: - name: "Run all unit-tests" run: ./run_all_unit_tests.sh --verbosity ${{ env.VERBOSITY }} + + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: "Set up Go ${{ env.GO_MIN_VERSION }}" + uses: actions/setup-go@v5 + with: + go-version: '${{ env.GO_MIN_VERSION }}' + + - name: "Run golangci-lint" + uses: golangci/golangci-lint-action@v7 + with: + verify: false + version: v2.4.0 diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..72f8962 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,70 @@ +formatters: + enable: + - gci + exclusions: + paths: + - examples/ + settings: + gci: + custom-order: true + no-inline-comments: false + no-prefix-comments: false + sections: + - prefix(github.com/synesissoftware/Diagnosticism.Go) + - default + - standard + +linters: + default: fast + disable: + - whitespace + - wsl + exclusions: + rules: + - linters: + - dupl + - funlen + - testpackage + path: _test\.go + - linters: + - cyclop + - funcorder + - funlen + - gocognit + - mnd + - nestif + path: doomgram\.go + - linters: + - lll + - mnd + path: examples/ + - linters: + - mnd + path: itoa_thousands\.go + - linters: + - gochecknoinits + path: severity/severity\.go + - linters: + - lll + - mnd + path: version\.go + settings: + cyclop: + max-complexity: 10 + depguard: + rules: + main: + allow: + - $gostd + - github.com/stretchr/testify + - github.com/synesissoftware/Diagnosticism.Go + - github.com/synesissoftware/STEGoL + - github.com/synesissoftware/ver2go + - go.yaml.in/yaml/v3 + - golang.org/x/ + list-mode: lax + +run: + timeout: 5m + +version: "2" diff --git a/AUTHORS.md b/AUTHORS.md index e69de29..1f97604 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -0,0 +1,22 @@ +# Diagnosticism.Go - Authors + + +## Major Contributors + +| Name | Email | GitHub | +| ------------ | ------------------------------------ | --------------------------------- | +| Matt Wilson | matthew.wilson.synesis@gmail.com | [mwsis](https://github.com/mwsis) | +| Harry Wilson | harold.wilson.synesis@gmail.com | [Hazzoz](https://github.com/Hazzoz) | + + +## Defect reports, fixes and suggestions (for which we are very grateful) + +| Name | GitHub | +| ------- | ------ | +| \ | | + + +Contributions are welcomed. + + + diff --git a/CHANGES.md b/CHANGES.md index 3ec9c64..48c606d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,13 @@ -# Diagnosticism.Go - CHANGES +# Diagnosticism.Go - Changes +## 0.13.5 - 20th August 2026 + +* CI modernisation (matrix + lint); +* CI reliability fixes (macOS test linking; golangci-lint config verification disabled in CI); +* **`go.mod`** floor raised to **1.25** (dependency-driven; `golang.org/x/term` / `golang.org/x/sys`); +* boilerplate additions (scripts, markdown docs, project identity); +* removed retired Go Report Card badge from README; +* version string updated for the 0.13.5 release; ## 0.13.4 - 29th March 2026 @@ -151,7 +159,7 @@ * ~ wholesale rename of ``diagnosticism`` => ``Diagnosticism`` -## 0.4.0 (unchanged) - 8th July 2019 +## 0.4.0 - 8th July 2019 * + added several examples diff --git a/EXAMPLES.md b/EXAMPLES.md index aa139b2..f5be56f 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -1,14 +1,17 @@ # Diagnosticism.Go - Examples -|Name|Source & Description|Summary| -|---|---|---| -|**conrep**|[examples/conrep/main.go](/examples/conrep/main.go)
[examples/conrep.md](/examples/conrep.md)|Example illustrating use of **Contingent Report API**| -|**conrep_with_log_mirroring**|[examples/conrep_with_log_mirroring/main.go](/examples/conrep_with_log_mirroring/main.go)
[examples/conrep_with_log_mirroring.md](/examples/conrep_with_log_mirroring.md)|Example illustrating use of **Contingent Report API** with log mirroring| -|**debugging**|[examples/debugging/main.go](/examples/debugging/main.go)
[examples/debugging.md](/examples/debugging.md)|Example illustrating use of **Debugging API**.| -|**doomgram**|[examples/doomgram/main.go](/examples/doomgram/main.go)
[examples/doomgram.md](/examples/doomgram.md)|Example illustrating use of `DOOMGram` structure and its timing strips| -|**logf_fail**|[examples/logf_fail/main.go](/examples/logf_fail/main.go)
[examples/logf_fail.md](/examples/logf_fail.md)|Example illustrating use of **Log API** with ``Logf()`` errors (in arguments)| -|**tracing**|[examples/tracing/main.go](/examples/tracing/main.go)
[examples/tracing.md](/examples/tracing.md)|Example illustrating use of **Trace API**| +| Name | Source & Description | Summary | +| ----------------------------- | ---------------------------------------- | --------------------------------------------------------------------------- | +| **conrep** | [examples/conrep/main.go](./examples/conrep/main.go)
[examples/conrep.md](./examples/conrep.md) | Example illustrating use of **Contingent Report API** | +| **conrep_with_log_mirroring** | [examples/conrep_with_log_mirroring/main.go](./examples/conrep_with_log_mirroring/main.go)
[examples/conrep_with_log_mirroring.md](./examples/conrep_with_log_mirroring.md) | Example illustrating use of **Contingent Report API** with log mirroring | +| **debugging** | [examples/debugging/main.go](./examples/debugging/main.go)
[examples/debugging.md](./examples/debugging.md) | Example illustrating use of **Debugging API** | +| **doomgram** | [examples/doomgram/main.go](./examples/doomgram/main.go)
[examples/doomgram.md](./examples/doomgram.md) | Example illustrating use of `DOOMGram` structure and its timing strips | +| **libver** | [examples/libver/main.go](./examples/libver/main.go)
[examples/libver.md](./examples/libver.md) | Displays the **Diagnosticism.Go** library version and terminates | +| **log_with_custom_backend** | [examples/log_with_custom_backend/main.go](./examples/log_with_custom_backend/main.go)
[examples/log_with_custom_backend.md](./examples/log_with_custom_backend.md) | Example illustrating use of **Log API** with a custom back-end | +| **logf_fail** | [examples/logf_fail/main.go](./examples/logf_fail/main.go)
[examples/logf_fail.md](./examples/logf_fail.md) | Example illustrating use of **Log API** with `Logf()` errors (in arguments) | +| **tracing** | [examples/tracing/main.go](./examples/tracing/main.go)
[examples/tracing.md](./examples/tracing.md) | Example illustrating use of **Trace API** | +| **version** | [examples/version/main.go](./examples/version/main.go)
[examples/version.md](./examples/version.md) | Example illustrating how to obtain the library version string | - + diff --git a/NEWS.md b/NEWS.md index e69de29..8f0a62d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -0,0 +1,41 @@ +# Diagnosticism.Go - News + + +| Date | News Item | +| ------------------- | ----------------------------------------------------------------------------------------------------------------- | +| 20th August 2026 | Release of [**Diagnosticism.Go** 0.13.5](https://github.com/synesissoftware/Diagnosticism.Go/releases/tag/0.13.5) | +| 29th March 2026 | Release of [**Diagnosticism.Go** 0.13.4](https://github.com/synesissoftware/Diagnosticism.Go/releases/tag/0.13.4) | +| 18th March 2026 | Release of **Diagnosticism.Go** 0.13.3 | +| 18th March 2026 | Release of **Diagnosticism.Go** 0.13.2 | +| 18th March 2026 | Release of **Diagnosticism.Go** 0.13.1 | +| 1st March 2026 | Release of **Diagnosticism.Go** 0.13.0 | +| 1st March 2026 | Release of **Diagnosticism.Go** 0.12.1 | +| 20th December 2025 | Release of **Diagnosticism.Go** 0.12.0 | +| 20th December 2025 | Release of **Diagnosticism.Go** 0.12.0-alpha2 | +| 11th October 2025 | Release of **Diagnosticism.Go** 0.12.0-alpha1 | +| 28th September 2025 | Release of **Diagnosticism.Go** 0.11.0 | +| 3rd September 2025 | Release of **Diagnosticism.Go** 0.10.0 | +| 27th August 2025 | Release of **Diagnosticism.Go** 0.10.0-beta1 | +| 27th August 2025 | Release of **Diagnosticism.Go** 0.9.1-beta4 | +| 26th August 2025 | Release of **Diagnosticism.Go** 0.9.1-beta3 | +| 18th August 2025 | Release of **Diagnosticism.Go** 0.9.1-beta2 | +| 18th August 2025 | Release of **Diagnosticism.Go** 0.9.1-beta1 | +| 15th August 2025 | Release of **Diagnosticism.Go** 0.9.0 | +| 27th March 2025 | Release of **Diagnosticism.Go** 0.8.0 | +| 26th March 2025 | Release of **Diagnosticism.Go** 0.8.0-alpha1 | +| 25th March 2025 | Release of **Diagnosticism.Go** 0.7.0 | +| 22nd February 2025 | Release of **Diagnosticism.Go** 0.7.0-alpha1 | +| 22nd February 2025 | Release of **Diagnosticism.Go** 0.6.1 | +| 23rd July 2020 | Release of **Diagnosticism.Go** 0.6.0 | +| 22nd July 2020 | Release of **Diagnosticism.Go** 0.5.0.1 | +| 20th July 2020 | Release of **Diagnosticism.Go** 0.5.0 | +| 8th July 2019 | Release of **Diagnosticism.Go** 0.4.0 | +| 8th July 2019 | Release of **Diagnosticism.Go** 0.4.0 | +| 4th June 2019 | Release of **Diagnosticism.Go** 0.3.2 | +| 1st June 2019 | Release of **Diagnosticism.Go** 0.3.1 | +| 1st June 2019 | Release of **Diagnosticism.Go** 0.3.0 | +| 30th May 2019 | Release of **Diagnosticism.Go** 0.2.0 | +| 28th March 2019 | Release of **Diagnosticism.Go** 0.1.0 | + + + diff --git a/README.md b/README.md index e828bb4..2eb11ea 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ Basic diagnostic facilities, for Go [![GitHub release](https://img.shields.io/github/v/release/synesissoftware/Diagnosticism.Go.svg)](https://github.com/synesissoftware/Diagnosticism.Go/releases/latest) [![Last Commit](https://img.shields.io/github/last-commit/synesissoftware/Diagnosticism.Go)](https://github.com/synesissoftware/Diagnosticism.Go/commits/master) [![Go](https://github.com/synesissoftware/Diagnosticism.Go/actions/workflows/go.yml/badge.svg)](https://github.com/synesissoftware/Diagnosticism.Go/actions/workflows/go.yml) -[![Go Report Card](https://goreportcard.com/badge/github.com/synesissoftware/Diagnosticism.Go)](https://goreportcard.com/report/github.com/synesissoftware/Diagnosticism.Go) [![Go Reference](https://pkg.go.dev/badge/github.com/synesissoftware/Diagnosticism.Go.svg)](https://pkg.go.dev/github.com/synesissoftware/Diagnosticism.Go) diff --git a/TODO.md b/TODO.md index 659b0cc..6a5b3f4 100644 --- a/TODO.md +++ b/TODO.md @@ -1,8 +1,28 @@ # Diagnosticism.Go - TODO -\ +## Table of Contents - +- [Functional improvements](#functional-improvements) +- [Performance improvements](#performance-improvements) +- [Packaging improvements](#packaging-improvements) + + +## Functional improvements + +* \ + + +## Performance improvements +* \ + +## Packaging improvements + +* [ ] Before the next official release: confirm **`go.mod`** (`go 1.25.0`) and the CI Go-version matrix, bump Synesis `require`s to newly published tags, then run **`go mod tidy`** (not against currently published tags). Prior Synesis Go releases, in order: + * **ver2go**; + * **STEGoL**; + + + diff --git a/calc_doom_bench_test.go b/calc_doom_bench_test.go index ffef515..805f84b 100644 --- a/calc_doom_bench_test.go +++ b/calc_doom_bench_test.go @@ -12,169 +12,37 @@ import ( func Test_calc_doom(t *testing.T) { - { - v := calc_doom(0) + stegol.CheckIntegerEqual(t, 0, calc_doom(0)) - stegol.CheckIntegerEqual(t, 0, v) - } - - { - for i := uint64(1); i != 10; i++ { - v := calc_doom(i) - - stegol.CheckIntegerEqual(t, 1, v) - } - } - - { - for i := uint64(10); i != 100; i++ { - v := calc_doom(i) - - stegol.CheckIntegerEqual(t, 2, v) - } - } - - { - for i := uint64(100); i != 1_000; i++ { - v := calc_doom(i) - - stegol.CheckIntegerEqual(t, 3, v) - } - } - - { - for i := uint64(1_000); i != 10_000; i++ { - v := calc_doom(i) - - stegol.CheckIntegerEqual(t, 4, v) - } - } - - { - for i := uint64(10_000); i != 100_000; i++ { - v := calc_doom(i) - - stegol.CheckIntegerEqual(t, 5, v) - } - } - - { - for i := uint64(100_000); i != 1_000_000; i++ { - v := calc_doom(i) - - stegol.CheckIntegerEqual(t, 6, v) - } - } - - { - for i := uint64(1_000_000); i != 10_000_000; i += 1_000_000 { - v := calc_doom(i) - - stegol.CheckIntegerEqual(t, 7, v) - } - } - - { - for i := uint64(10_000_000); i != 100_000_000; i += 10_000_000 { - v := calc_doom(i) - - stegol.CheckIntegerEqual(t, 8, v) - } - } - - { - for i := uint64(100_000_000); i != 1_000_000_000; i += 100_000_000 { - v := calc_doom(i) - - stegol.CheckIntegerEqual(t, 9, v) - } - } - - { - for i := uint64(1_000_000_000); i != 10_000_000_000; i += 1_000_000_000 { - v := calc_doom(i) - - stegol.CheckIntegerEqual(t, 10, v) - } - } - - { - for i := uint64(10_000_000_000); i != 100_000_000_000; i += 10_000_000_000 { - v := calc_doom(i) - - stegol.CheckIntegerEqual(t, 11, v) - } - } - - { - for i := uint64(100_000_000_000); i != 1_000_000_000_000; i += 100_000_000_000 { - v := calc_doom(i) - - stegol.CheckIntegerEqual(t, 12, v) - } - } - - { - for i := uint64(1_000_000_000_000); i != 10_000_000_000_000; i += 1_000_000_000_000 { - v := calc_doom(i) - - stegol.CheckIntegerEqual(t, 13, v) - } - } - - { - for i := uint64(10_000_000_000_000); i != 100_000_000_000_000; i += 10_000_000_000_000 { - v := calc_doom(i) - - stegol.CheckIntegerEqual(t, 14, v) - } - } - - { - for i := uint64(100_000_000_000_000); i != 1_000_000_000_000_000; i += 100_000_000_000_000 { - v := calc_doom(i) - - stegol.CheckIntegerEqual(t, 15, v) - } - } - - { - for i := uint64(1_000_000_000_000_000); i != 10_000_000_000_000_000; i += 1_000_000_000_000_000 { - v := calc_doom(i) - - stegol.CheckIntegerEqual(t, 16, v) - } - } - - { - for i := uint64(10_000_000_000_000_000); i != 100_000_000_000_000_000; i += 10_000_000_000_000_000 { - v := calc_doom(i) - - stegol.CheckIntegerEqual(t, 17, v) - } - } - - { - for i := uint64(100_000_000_000_000_000); i != 1_000_000_000_000_000_000; i += 100_000_000_000_000_000 { - v := calc_doom(i) - - stegol.CheckIntegerEqual(t, 18, v) - } - } - - { - for i := uint64(1_000_000_000_000_000_000); i != 10_000_000_000_000_000_000; i += 1_000_000_000_000_000_000 { - v := calc_doom(i) - - stegol.CheckIntegerEqual(t, 19, v) - } - } - - { - for i := uint64(10_000_000_000_000_000_000); i != 18_000_000_000_000_000_000; i += 1_000_000_000_000_000_000 { - v := calc_doom(i) - - stegol.CheckIntegerEqual(t, 20, v) + cases := []struct { + from, to, step uint64 + want uint32 + }{ + {1, 10, 1, 1}, + {10, 100, 1, 2}, + {100, 1_000, 1, 3}, + {1_000, 10_000, 1, 4}, + {10_000, 100_000, 1, 5}, + {100_000, 1_000_000, 1, 6}, + {1_000_000, 10_000_000, 1_000_000, 7}, + {10_000_000, 100_000_000, 10_000_000, 8}, + {100_000_000, 1_000_000_000, 100_000_000, 9}, + {1_000_000_000, 10_000_000_000, 1_000_000_000, 10}, + {10_000_000_000, 100_000_000_000, 10_000_000_000, 11}, + {100_000_000_000, 1_000_000_000_000, 100_000_000_000, 12}, + {1_000_000_000_000, 10_000_000_000_000, 1_000_000_000_000, 13}, + {10_000_000_000_000, 100_000_000_000_000, 10_000_000_000_000, 14}, + {100_000_000_000_000, 1_000_000_000_000_000, 100_000_000_000_000, 15}, + {1_000_000_000_000_000, 10_000_000_000_000_000, 1_000_000_000_000_000, 16}, + {10_000_000_000_000_000, 100_000_000_000_000_000, 10_000_000_000_000_000, 17}, + {100_000_000_000_000_000, 1_000_000_000_000_000_000, 100_000_000_000_000_000, 18}, + {1_000_000_000_000_000_000, 10_000_000_000_000_000_000, 1_000_000_000_000_000_000, 19}, + {10_000_000_000_000_000_000, 18_000_000_000_000_000_000, 1_000_000_000_000_000_000, 20}, + } + + for _, tc := range cases { + for i := tc.from; i != tc.to; i += tc.step { + stegol.CheckIntegerEqual(t, tc.want, calc_doom(i)) } } } diff --git a/conrep.go b/conrep.go index 350ae29..10a61fa 100644 --- a/conrep.go +++ b/conrep.go @@ -4,11 +4,11 @@ * Purpose: Contingent report API for Diagnosticism.Go * * Created: 31st May 2019 - * Updated: 26th August 2025 + * Updated: 20th August 2026 * * Home: https://github.com/synesissoftware/Diagnosticism.Go * - * Copyright (c) 2019-2025, Matthew Wilson and Synesis Information Systems + * Copyright (c) 2019-2026, Matthew Wilson and Synesis Information Systems * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -63,7 +63,7 @@ var contingentReportWriter io.Writer = os.Stderr * helper functions */ -// TODO: separate this out using proper build constraints +// Future: separate this out using proper build constraints. func osIsWindows() bool { if ';' != os.PathListSeparator { diff --git a/debug.go b/debug.go index 22be0e3..9179832 100644 --- a/debug.go +++ b/debug.go @@ -10,9 +10,9 @@ package diagnosticism import ( - "errors" - "github.com/synesissoftware/Diagnosticism.Go/internal" + + "errors" ) var ( diff --git a/doomgram.go b/doomgram.go index 4c22ca1..3d7f696 100644 --- a/doomgram.go +++ b/doomgram.go @@ -4,7 +4,7 @@ /* * Created: 25th March 2025 - * Updated: 18th March 2026 + * Updated: 20th August 2026 */ package diagnosticism @@ -316,7 +316,7 @@ func (d *DOOMGram) tryAddNsToTotalAndUpdateMinmaxAndCount(time_in_ns uint64) boo } } -// NOTE: taken directly from Diagnosticism.Rust +// NOTE: taken directly from Diagnosticism.Rust. func calc_doom(v uint64) uint32 { if v >= 100_000_000 { @@ -409,7 +409,7 @@ func calc_doom(v uint64) uint32 { } } -// NOTE: taken directly from Diagnosticism.Rust +// NOTE: taken directly from Diagnosticism.Rust. func gram_doom_to_char( doom uint32, ch_0 byte, diff --git a/examples/.golangci.yml b/examples/.golangci.yml new file mode 100644 index 0000000..3a28ebe --- /dev/null +++ b/examples/.golangci.yml @@ -0,0 +1,16 @@ +formatters: + enable: + - gci + settings: + gci: + custom-order: true + no-inline-comments: false + no-prefix-comments: false + sections: + - default + - standard + +run: + timeout: 5m + +version: "2" diff --git a/examples/conrep.md b/examples/conrep.md index 8719ac7..81bd190 100644 --- a/examples/conrep.md +++ b/examples/conrep.md @@ -1,4 +1,4 @@ -# Diagnosticism.Go Example - **conrep** +# Diagnosticism.Go - Example - **conrep** ## Summary diff --git a/examples/conrep_with_log_mirroring.md b/examples/conrep_with_log_mirroring.md index 91d09c6..96706b8 100644 --- a/examples/conrep_with_log_mirroring.md +++ b/examples/conrep_with_log_mirroring.md @@ -1,4 +1,4 @@ -# Diagnosticism.Go Example - **conrep_with_log_mirroring** +# Diagnosticism.Go - Example - **conrep_with_log_mirroring** ## Summary diff --git a/examples/debugging.md b/examples/debugging.md index 4606b0d..fdea1f6 100644 --- a/examples/debugging.md +++ b/examples/debugging.md @@ -1,4 +1,4 @@ -# Diagnosticism.Go Example - **debugging** +# Diagnosticism.Go - Example - **debugging** ## Summary diff --git a/examples/doomgram.md b/examples/doomgram.md index 9895c49..827cb48 100644 --- a/examples/doomgram.md +++ b/examples/doomgram.md @@ -1,4 +1,4 @@ -# Diagnosticism.Go Example - **doomgram** +# Diagnosticism.Go - Example - **doomgram** ## Summary diff --git a/examples/libver.md b/examples/libver.md new file mode 100644 index 0000000..90fb6bc --- /dev/null +++ b/examples/libver.md @@ -0,0 +1,21 @@ +# Diagnosticism.Go - Example - **libver** + + +## Summary + +Displays the **Diagnosticism.Go** library version and terminates. + + +## Source + +See [examples/libver/main.go](./examples/libver/main.go). + + +## Execution + +```bash +go run ./examples/libver +``` + + + diff --git a/examples/log_with_custom_backend.md b/examples/log_with_custom_backend.md index 1210c8a..97fe314 100644 --- a/examples/log_with_custom_backend.md +++ b/examples/log_with_custom_backend.md @@ -1,4 +1,4 @@ -# Diagnosticism.Go Example - **conrep_with_custom_backend** +# Diagnosticism.Go - Example - **log_with_custom_backend** ## Summary diff --git a/examples/logf_fail.md b/examples/logf_fail.md index 9547a1d..2dfcb71 100644 --- a/examples/logf_fail.md +++ b/examples/logf_fail.md @@ -1,4 +1,4 @@ -# Diagnosticism.Go Example - **flog_fail** +# Diagnosticism.Go - Example - **logf_fail** ## Summary diff --git a/examples/tracing.md b/examples/tracing.md index 3d5a56d..24083d8 100644 --- a/examples/tracing.md +++ b/examples/tracing.md @@ -1,4 +1,4 @@ -# Diagnosticism.Go Example - **tracing** +# Diagnosticism.Go - Example - **tracing** ## Summary diff --git a/examples/version.md b/examples/version.md index f18e501..e1771a8 100644 --- a/examples/version.md +++ b/examples/version.md @@ -1,4 +1,4 @@ -# Diagnosticism.Go Example - **tracing** +# Diagnosticism.Go - Example - **version** ## Summary diff --git a/go.mod b/go.mod index 041dd3e..7d036de 100644 --- a/go.mod +++ b/go.mod @@ -1,17 +1,15 @@ module github.com/synesissoftware/Diagnosticism.Go -go 1.23.6 +go 1.25.0 require ( - github.com/stretchr/testify v1.11.1 - github.com/synesissoftware/STEGoL v0.3.0 - github.com/synesissoftware/ver2go v0.1.3 - golang.org/x/term v0.34.0 + github.com/stretchr/testify v1.12.1 + github.com/synesissoftware/STEGoL v0.3.1 + github.com/synesissoftware/ver2go v0.1.4 + golang.org/x/term v0.45.0 ) require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/sys v0.35.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect + go.yaml.in/yaml/v3 v3.0.5 // indirect + golang.org/x/sys v0.47.0 // indirect ) diff --git a/go.sum b/go.sum index 74a9064..9e19cd9 100644 --- a/go.sum +++ b/go.sum @@ -1,18 +1,12 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= -github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= -github.com/synesissoftware/STEGoL v0.3.0 h1:3Q1x7S472seaMlxBD1WR+Ax5qxDSFBb7jZ/EAUKQQTc= -github.com/synesissoftware/STEGoL v0.3.0/go.mod h1:TWWL9GPgKTuO2u3xGhCqYp7nvQbkxKq2vnjUJ2O8gSQ= -github.com/synesissoftware/ver2go v0.1.3 h1:5zE+ymD+R0WlgsvtdU0lWYlODXXTiEQuQ6vZj/fO0+o= -github.com/synesissoftware/ver2go v0.1.3/go.mod h1:wpsHnw22T2n4QG6fK1SwBakk+EbMxDt6NLVclU1MvLo= -golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= -golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4= -golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE= +github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg= +github.com/synesissoftware/STEGoL v0.3.1 h1:00VzAJX5WPt5BpJAffZ33qHeC2g6xjXM0uCgg5KjxbI= +github.com/synesissoftware/STEGoL v0.3.1/go.mod h1:rAfqnX1UANIy4/CSsXvyiodid68yHlUgo7i7atexrzE= +github.com/synesissoftware/ver2go v0.1.4 h1:IA0lzR+Wzv5WiwOj6XZJYZYQMq1xn75d6+PIAqqyapM= +github.com/synesissoftware/ver2go v0.1.4/go.mod h1:JlZS4ms4D4cCaYuRh+fbBaNv7BwqrAP4m4/hZzGJ8hU= +go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw= +go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg= +golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= +golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/term v0.45.0 h1:NwWyBmoJCbfTHpxrWoZ9C6/VxOf7ic219I8xZZFdrf0= +golang.org/x/term v0.45.0/go.mod h1:9aqxs0blBcrm/n0L9QW0aRVD+ktan8ssZromtqJC43w= diff --git a/internal/debug.go b/internal/debug.go index 8329065..6df19f2 100644 --- a/internal/debug.go +++ b/internal/debug.go @@ -1,10 +1,10 @@ -// Copyright 2019-2025 Matthew Wilson and Synesis Information Systems. All +// Copyright 2019-2026 Matthew Wilson and Synesis Information Systems. All // rights reserved. Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. /* * Created: 22nd February 2025 - * Updated: 20th December 2025 + * Updated: 20th August 2026 */ package internal @@ -15,20 +15,16 @@ import ( ) func getFileLineFunction(depth int, wantFunction bool) (string, int, string, bool) { - - // TODO: refactor in terms of `CallersFrames()` + // Future: refactor in terms of `CallersFrames()`. pc, file, line, ok := runtime.Caller(depth + 1) if ok { - if wantFunction { - function := runtime.FuncForPC(pc).Name() return file, line, function, true } else { - return file, line, "", true } } else { @@ -38,15 +34,13 @@ func getFileLineFunction(depth int, wantFunction bool) (string, int, string, boo // Obtains the file information for the calling function. func File(depth int) string { - - file, _, _, _ := getFileLineFunction(depth+1, false) + file, _, _, _ := getFileLineFunction(depth+1, false) //nolint:dogsled return file } // Obtains the file and line information for the calling function. func FileLine(depth int) string { - file, line, _, ok := getFileLineFunction(depth+1, false) if ok { @@ -59,7 +53,6 @@ func FileLine(depth int) string { // Obtains the file, line, and function information for the calling // function. func FileLineFunction(depth int) string { - file, line, function, ok := getFileLineFunction(depth+1, true) if ok { @@ -72,15 +65,13 @@ func FileLineFunction(depth int) string { // Obtains the file, line, and function information for the calling // function. func Function(depth int) string { - - _, _, function, _ := getFileLineFunction(depth+1, true) + _, _, function, _ := getFileLineFunction(depth+1, true) //nolint:dogsled return function } // Obtains the line function information for the calling function. func Line(depth int) int { - _, line, _, ok := getFileLineFunction(depth+1, false) if ok { @@ -92,7 +83,6 @@ func Line(depth int) int { // Obtains the line and function information for the calling function. func LineFunction(depth int) string { - _, line, function, ok := getFileLineFunction(depth+1, true) if ok { diff --git a/itoa_thousands.go b/itoa_thousands.go index 660dfe1..5792d55 100644 --- a/itoa_thousands.go +++ b/itoa_thousands.go @@ -9,7 +9,7 @@ func itoaThousands_int64(v int64) string { s := strconv.FormatInt(v, 10) - r := make([]byte, 0, len(s) * 4 / 3) + r := make([]byte, 0, len(s)*4/3) if neg { s = s[1:] @@ -43,7 +43,7 @@ func itoaThousands_int64(v int64) string { func itoaThousands_uint64(v uint64) string { s := strconv.FormatUint(v, 10) - r := make([]byte, 0, len(s) * 4 / 3) + r := make([]byte, 0, len(s)*4/3) var n int switch len(s) % 3 { @@ -70,7 +70,9 @@ func itoaThousands_uint64(v uint64) string { } // Returns the string form of v in base 10, with thousands separators. -func ItoaThousands[T int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | uintptr](v T) string { +func ItoaThousands[T int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | uintptr]( + v T, +) string { switch any(v).(type) { case int, int8, int16, int32, int64: diff --git a/itoa_thousands_test.go b/itoa_thousands_test.go index 2ccd486..c4852fd 100644 --- a/itoa_thousands_test.go +++ b/itoa_thousands_test.go @@ -3,9 +3,9 @@ package diagnosticism_test import ( d "github.com/synesissoftware/Diagnosticism.Go" - "testing" - "github.com/stretchr/testify/assert" + + "testing" ) func Test_ItoaThousands_int(t *testing.T) { diff --git a/loghandler.go b/loghandler.go index 2473d35..79ba7ef 100644 --- a/loghandler.go +++ b/loghandler.go @@ -4,7 +4,7 @@ * Purpose: LogHandler for Diagnosticism.Go * * Created: 1st June 2019 - * Updated: 1st March 2026 + * Updated: 20th August 2026 * * Home: https://github.com/synesissoftware/Diagnosticism.Go * @@ -53,18 +53,18 @@ type LogRequestFlags int const ( - // Do not log before the request + // Do not log before the request. LogRequest_NotBefore LogRequestFlags = 1 << iota - // Do not log after the request + // Do not log after the request. LogRequest_NotAfter LogRequestFlags = 1 << iota - // Do not include a BEFORE/AFTER prefix + // Do not include a BEFORE/AFTER prefix. LogRequest_NoWhenLabel LogRequestFlags = 1 << iota - // Do not include the method + // Do not include the method. LogRequest_NotMethod LogRequestFlags = 1 << iota - // Do not include the URL + // Do not include the URL. LogRequest_NotURL LogRequestFlags = 1 << iota - // Include the protocol + // Include the protocol. LogRequest_Protocol LogRequestFlags = 1 << iota ) @@ -164,7 +164,8 @@ func parseSeverityFromArgs(options ...any) severity.Severity { // - +options+ Optional arguments (see below) // // Options: -// - * (severity.Severity) The first option of this type is used for before and/or after logging; if none specified, before and/or after logging is done using severity.Informational +// - * (severity.Severity) The first option of this type is used for before and/or after logging; +// if none specified, before and/or after logging is done using severity.Informational. func LogRequest(flags LogRequestFlags, options ...any) func(http.Handler) http.Handler { sev := parseSeverityFromArgs(options) diff --git a/run_all_unit_tests.sh b/run_all_unit_tests.sh index 3bf9cfb..b7ec8b5 100755 --- a/run_all_unit_tests.sh +++ b/run_all_unit_tests.sh @@ -94,12 +94,24 @@ if [ $Verbosity -ge 2 ]; then echo "Running all ${ProjectName} unit-test packages" fi +# +# Mitigate rare macOS `dyld` aborts caused by corrupted cached `*.test` binaries. +# +go clean -cache -testcache + +LD_FLAGS="" +if [ "$(uname -s)" = "Darwin" ]; then + # Older Go toolchains can produce Mach-O binaries without LC_UUID on newer macOS + # versions, triggering `dyld: missing LC_UUID load command ...` at test start. + LD_FLAGS="-ldflags=-linkmode=external" +fi + if [ $Verbosity -ge 2 ]; then - go test -v $Packages + go test -v $LD_FLAGS $Packages else - go test $Packages + go test $LD_FLAGS $Packages fi diff --git a/severity/severity.go b/severity/severity.go index c4f50a2..b96ea61 100644 --- a/severity/severity.go +++ b/severity/severity.go @@ -1,19 +1,19 @@ -// Copyright 2019-2025 Matthew Wilson and Synesis Information Systems. All +// Copyright 2019-2026 Matthew Wilson and Synesis Information Systems. All // rights reserved. Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. /* * Created: 30th May 2019 - * Updated: 3rd September 2025 + * Updated: 20th August 2026 */ package severity import ( + "golang.org/x/term" + "fmt" "os" - - "golang.org/x/term" ) /* ///////////////////////////////////////////////////////////////////////// @@ -25,7 +25,6 @@ type Severity int // Default string form of the stock severity levels. func (severity Severity) String() string { - return severityTranslator.SeverityToString(severity) } @@ -81,14 +80,12 @@ var severityTranslator SeverityTranslator type colouredSeverityTranslator struct{} func (dt colouredSeverityTranslator) SeverityToString(severity Severity) string { - return ColouredSeverityToString(severity) } type defaultSeverityTranslator struct{} func (dt defaultSeverityTranslator) SeverityToString(severity Severity) string { - return TranslateStockSeverity(severity) } @@ -97,6 +94,8 @@ func (dt defaultSeverityTranslator) SeverityToString(severity Severity) string { */ // Obtains the coloured stock string form of a given [Severity]. +// +//nolint:cyclop func ColouredSeverityToString(severity Severity) string { switch severity { @@ -150,6 +149,8 @@ func ColouredSeverityToString(severity Severity) string { } // Obtains the stock string form of a given [Severity]. +// +//nolint:cyclop func TranslateStockSeverity(severity Severity) string { switch severity { diff --git a/trace.go b/trace.go index a74776f..23a160c 100644 --- a/trace.go +++ b/trace.go @@ -4,7 +4,7 @@ /* * Created: 5th March 2019 - * Updated: 14th March 2026 + * Updated: 20th August 2026 */ package diagnosticism @@ -39,7 +39,7 @@ type TraceArgumentFlags int64 const ( None TraceArgumentFlags = 0 // No flags specified NameOnly TraceArgumentFlags = 0x0000_0000_0000_0001 // Does not trace the value of a function parameter. - NameTypeOnly TraceArgumentFlags = 0x0000_0000_0000_0002 // Does not trace the type or the value of a function parameter. + NameTypeOnly TraceArgumentFlags = 0x0000_0000_0000_0002 // Does not trace type or value of a parameter. TruncateValue TraceArgumentFlags = 0x0000_0000_0000_0004 // Causes the value to be truncated to 20 runes. ) @@ -136,7 +136,7 @@ func TrargTrunc(name string, value any) TraceArgument { // // The first parameter `function_name` is a string, and the remaining // parameters are a variable length list of TraceArgument instances, which -// may be created using the `Trarg()` and `TrargNameOnly()` functions +// may be created using the `Trarg()` and `TrargNameOnly()` functions. func Trace(function_name string, args ...TraceArgument) { if !enableTracing { diff --git a/trace_test.go b/trace_test.go index c05ee37..522d49b 100644 --- a/trace_test.go +++ b/trace_test.go @@ -10,14 +10,14 @@ import ( func Test_EnableTracing(t *testing.T) { - go func() { + func() { current := d.EnableTracing(false) defer d.EnableTracing(current) require.False(t, current, "`EnableTracing()` should return `false` when first called") }() - go func() { + func() { current := d.EnableTracing(true) defer d.EnableTracing(current) diff --git a/version.go b/version.go index 73c713a..527ba2a 100644 --- a/version.go +++ b/version.go @@ -4,7 +4,7 @@ /* * Created: 5th March 2019 - * Updated: 29th March 2026 + * Updated: 20th August 2026 */ package diagnosticism @@ -14,7 +14,7 @@ import "github.com/synesissoftware/ver2go" const ( VersionMajor uint16 = 0 VersionMinor uint16 = 13 - VersionPatch uint16 = 4 + VersionPatch uint16 = 5 VersionAB uint16 = 0xFFFF Version uint64 = (uint64(VersionMajor) << 48) + (uint64(VersionMinor) << 32) + (uint64(VersionPatch) << 16) + (uint64(VersionAB) << 0) ) diff --git a/version_test.go b/version_test.go index a0a3b3f..fd1d9d3 100644 --- a/version_test.go +++ b/version_test.go @@ -11,7 +11,7 @@ import ( const ( Expected_VersionMajor uint16 = 0 Expected_VersionMinor uint16 = 13 - Expected_VersionPatch uint16 = 4 + Expected_VersionPatch uint16 = 5 Expected_VersionAB uint16 = 0xFFFF ) @@ -23,9 +23,9 @@ func Test_Version_Elements(t *testing.T) { } func Test_Version(t *testing.T) { - require.Equal(t, uint64(0x0000_000D_0004_FFFF), Version) + require.Equal(t, uint64(0x0000_000D_0005_FFFF), Version) } func Test_Version_String(t *testing.T) { - require.Equal(t, "0.13.4", VersionString()) + require.Equal(t, "0.13.5", VersionString()) }