Skip to content

Commit 906cc54

Browse files
Merge pull request #49 from valentin-kaiser/service
Major refactor: Add service management, logging abstraction, and enhanced version support
2 parents 2b50f7a + 1f2edde commit 906cc54

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+8181
-1079
lines changed

.github/workflows/test.yaml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ jobs:
3434
run: go build -v ./...
3535

3636
- name: Run tests
37-
run: go test -race -coverprofile=coverage.out -covermode=atomic ./...
37+
run: |
38+
# Exclude machine package on Linux as it requires hardware access not available in CI
39+
packages=$(go list ./... | grep -v '/machine$')
40+
go test -race -coverprofile=coverage.out -covermode=atomic $packages
3841
3942
- name: Run go vet
4043
run: go vet ./...
@@ -63,7 +66,10 @@ jobs:
6366
run: go mod download
6467

6568
- name: Run tests
66-
run: go test -v ./...
69+
run: |
70+
# Exclude machine package on Windows as it requires hardware access not available in CI
71+
$packages = go list ./... | Where-Object { $_ -notmatch '/machine$' }
72+
go test -v $packages
6773
6874
test-macos:
6975
name: Test on macOS
@@ -81,4 +87,7 @@ jobs:
8187
run: go mod download
8288

8389
- name: Run tests
84-
run: go test -v ./...
90+
run: |
91+
# Exclude machine package on macOS as it requires hardware access not available in CI
92+
packages=$(go list ./... | grep -v '/machine$')
93+
go test -v $packages

CODE_OF_CONDUCT.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, religion, or sexual identity
10+
and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
* Demonstrating empathy and kindness toward other people
21+
* Being respectful of differing opinions, viewpoints, and experiences
22+
* Giving and gracefully accepting constructive feedback
23+
* Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
* Focusing on what is best not just for us as individuals, but for the
26+
overall community
27+
28+
Examples of unacceptable behavior include:
29+
30+
* The use of sexualized language or imagery, and sexual attention or
31+
advances of any kind
32+
* Trolling, insulting or derogatory comments, and personal or political attacks
33+
* Public or private harassment
34+
* Publishing others' private information, such as a physical or email
35+
address, without their explicit permission
36+
* Other conduct which could reasonably be considered inappropriate in a
37+
professional setting
38+
39+
## Enforcement Responsibilities
40+
41+
Community leaders are responsible for clarifying and enforcing our standards of
42+
acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
45+
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
50+
51+
## Scope
52+
53+
This Code of Conduct applies within all community spaces, and also applies when
54+
an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official email address,
56+
posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported to the community leaders responsible for enforcement at
63+
[info@kaiser-bielefeld.de](mailto:info@kaiser-bielefeld.de).
64+
All complaints will be reviewed and investigated promptly and fairly.
65+
66+
All community leaders are obligated to respect the privacy and security of the
67+
reporter of any incident.
68+
69+
## Enforcement Guidelines
70+
71+
Community leaders will follow these Community Impact Guidelines in determining
72+
the consequences for any action they deem in violation of this Code of Conduct:
73+
74+
### 1. Correction
75+
76+
**Community Impact**: Use of inappropriate language or other behavior deemed
77+
unprofessional or unwelcome in the community.
78+
79+
**Consequence**: A private, written warning from community leaders, providing
80+
clarity around the nature of the violation and an explanation of why the
81+
behavior was inappropriate. A public apology may be requested.
82+
83+
### 2. Warning
84+
85+
**Community Impact**: A violation through a single incident or series
86+
of actions.
87+
88+
**Consequence**: A warning with consequences for continued behavior. No
89+
interaction with the people involved, including unsolicited interaction with
90+
those enforcing the Code of Conduct, for a specified period of time. This
91+
includes avoiding interactions in community spaces as well as external channels
92+
like social media. Violating these terms may lead to a temporary or
93+
permanent ban.
94+
95+
### 3. Temporary Ban
96+
97+
**Community Impact**: A serious violation of community standards, including
98+
sustained inappropriate behavior.
99+
100+
**Consequence**: A temporary ban from any sort of interaction or public
101+
communication with the community for a specified period of time. No public or
102+
private interaction with the people involved, including unsolicited interaction
103+
with those enforcing the Code of Conduct, is allowed during this period.
104+
Violating these terms may lead to a permanent ban.
105+
106+
### 4. Permanent Ban
107+
108+
**Community Impact**: Demonstrating a pattern of violation of community
109+
standards, including sustained inappropriate behavior, harassment of an
110+
individual, or aggression toward or disparagement of classes of individuals.
111+
112+
**Consequence**: A permanent ban from any sort of public interaction within
113+
the community.
114+
115+
## Attribution
116+
117+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118+
version 2.0, available at
119+
[contributor-covenant.org](https://www.contributor-covenant.org/version/2/0/code_of_conduct.html).
120+
121+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
122+
enforcement ladder](https://github.com/mozilla/diversity).
123+
124+
For answers to common questions about this code of conduct, see the FAQ at
125+
[https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are available at
126+
[https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations).

CONTRIBUTING.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Contributing to go-core
2+
3+
Welcome to the go-core project! Your contributions are highly appreciated. We've designed the process to be straightforward and transparent, whether you're:
4+
5+
- Reporting a bug
6+
- Discussing code-related matters
7+
- Submitting fixes
8+
- Proposing exciting new features
9+
- Expressing interest in becoming a maintainer
10+
11+
## Embracing GitHub for Development
12+
13+
GitHub is our platform of choice for hosting code, tracking issues and feature requests, and accepting pull requests.
14+
We follow the [GitHub Flow](https://docs.github.com/de/get-started/quickstart/github-flow) for code changes.
15+
Pull requests serve as the vehicle for proposing modifications to the codebase.
16+
We enthusiastically welcome your pull requests using the following steps:
17+
18+
- Fork the repository and create a new branch based on main.
19+
- If your changes involve new code, incorporate corresponding tests.
20+
- When altering APIs, remember to update the accompanying documentation.
21+
- Validate that the test suite passes successfully.
22+
- Ensure your code aligns with our coding standards.
23+
- Now you can submit your pull request!
24+
25+
## Reporting Issues via GitHub's Issues Section
26+
27+
We utilize GitHub's issues section to track public bugs.
28+
Creating a bug report is as easy as opening a new issue using our templates.
29+
30+
## Your Contributions Under the BSD 3-Clause License
31+
32+
By submitting your code changes, you implicitly agree to License your contributions under the same BSD 3-Clause license that governs the project.
33+
If you have any concerns, don't hesitate to reach out to the maintainers.

README.md

Lines changed: 100 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,103 @@
11
# go-core
22

3+
[![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](http://godoc.org/github.com/valentin-kaiser/go-core)
4+
[![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://github.com/valentin-kaiser/go-core/blob/main/LICENSE)
35

4-
[![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](http://godoc.org/github.com/Valentin-Kaiser/go-core)
5-
[![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg)](https://github.com/Valentin-Kaiser/go-core/blob/main/LICENSE)
6-
7-
🛠️ go-core is a modular collection of Go libraries designed to accelerate application development by providing essential utilities for common tasks.
8-
9-
It includes:
10-
- advanced error handling with stack traces
11-
- secure encryption and cryptography helpers
12-
- flexible configuration management
13-
- structured logging
14-
- robust database connection handling with migrations
15-
- flag parsing
16-
- panic recovery
17-
- memory size calculation
18-
- embedding build information
19-
- and an advanced HTTP server with middleware support
6+
**go-core** is a comprehensive, modular collection of Go libraries designed to accelerate professional application development. It provides robust, production-grade utilities for error handling, configuration, logging, caching, database management, security, service orchestration, and more. Each package is crafted for extensibility, reliability, and seamless integration.
7+
8+
## Key Features
9+
10+
### Error Handling
11+
- Custom error types with stack traces and context
12+
- Utility functions for error propagation and recovery
13+
14+
### Caching
15+
- In-memory, Redis, and distributed caching
16+
- TTL, LRU eviction, serialization, and advanced cache configuration
17+
18+
### Configuration Management
19+
- Structured config loading from files, flags, and environment
20+
- Dynamic watching, validation, and default value registration
21+
22+
### Logging
23+
- Flexible logging framework with adapters for zerolog, standard log, and no-op
24+
- Global logger registry, structured logging, and zero-allocation logger
25+
- Log rotation and custom output targets
26+
27+
### Database
28+
- Abstraction over GORM with automatic connection handling
29+
- Schema migrations, transaction management, and multi-database support
30+
31+
### Flags & Interruption
32+
- Simple API for command-line flag parsing
33+
- Graceful shutdown and panic recovery utilities
34+
35+
### Memory & Machine Utilities
36+
- Estimate memory footprint of Go values
37+
- Unique machine ID generation and hardware info (CPU, features)
38+
39+
### Mail
40+
- Comprehensive email sending and SMTP server functionality
41+
- Security features: HELO validation, IP filtering, rate limiting
42+
- Delivery tracking, retry logic, and template management
43+
44+
### Queue & Task Processing
45+
- Background job processing system
46+
- In-memory, Redis, and RabbitMQ support
47+
- Scheduling, middleware, job context, and distributed execution
48+
49+
### Security
50+
- Cryptographic utilities: PGP, AES encryption/decryption
51+
- Secure operations for sensitive data and communication
52+
53+
### Service Management
54+
- Service lifecycle management and deployment
55+
- Integration with kardianos/service, shutdown handling, and cross-platform support
56+
57+
### Web & RPC
58+
- Configurable HTTP server with middleware support
59+
- JSON-RPC over HTTP and WebSocket (requires Protocol Buffer definitions for server generation)
60+
- Rate limiting, request metadata, and automatic method dispatch
61+
62+
### Versioning
63+
- Build/version info embedding and management
64+
- Precise control over application metadata
65+
66+
## Installation
67+
68+
```bash
69+
go get github.com/valentin-kaiser/go-core
70+
```
71+
72+
## Package Overview
73+
74+
- `apperror`: Advanced error handling
75+
- `cache`: Multi-backend caching (memory, Redis)
76+
- `config`: Structured configuration management
77+
- `database`: Database abstraction and migrations
78+
- `flag`: Command-line flag parsing
79+
- `interruption`: Panic recovery and graceful shutdown
80+
- `logging`: Flexible logging adapters and registry
81+
- `machine`: Machine identification and hardware info
82+
- `mail`: Email sending, SMTP server, and security
83+
- `memsize`: Memory size estimation
84+
- `queue`: Job/task queues and distributed processing
85+
- `security`: Cryptography and secure operations
86+
- `service`: Service lifecycle and deployment
87+
- `version`: Build/version info management
88+
- `web`: HTTP server and middleware
89+
- `web/jrpc`: JSON-RPC over HTTP/WebSocket
90+
- `zlog`: Zero-allocation logger
91+
92+
## Documentation
93+
94+
See [GoDoc](http://godoc.org/github.com/valentin-kaiser/go-core) for full API documentation and usage details.
95+
96+
97+
## Contributing
98+
99+
Contributions, issues, and feature requests are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
100+
101+
## License
102+
103+
This project is licensed under the BSD 3-Clause License. See [LICENSE](LICENSE) for details.

SECURITY.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
I am dedicated to ensure the security of go-core. To achieve this, I follow the Semantic Versioning (SemVer) scheme, where revisions are in the format "major.minor.patch".
6+
I will release patches for any security vulnerabilities that are discovered in the latest major or minor release.
7+
8+
| Version | Supported |
9+
| ------- | ------------------ |
10+
| 5.1.x | :white_check_mark: |
11+
| 5.0.x | :x: |
12+
| 4.0.x | :white_check_mark: |
13+
| < 4.0 | :x: |
14+
15+
## Reporting a Vulnerability
16+
17+
I take the security of this project very seriously. If you discover a security vulnerability, I appreciate your responsible disclosure. To report a vulnerability, please follow these steps:
18+
19+
1. **Email**: Send an email to [info@kaiser-bielefeld.de](mailto:info@kaiser-bielefeld.de) with all the details regarding the vulnerability.
20+
2. **Subject**: Use "[go-core Vulnerability Report]" as the subject line to help me prioritize and identify your report.
21+
3. **Vulnerability Details**: Please provide a clear and detailed description of the vulnerability, along with the potential impact it may have.
22+
4. **Reproducibility**: If possible, include step-by-step instructions to reproduce the vulnerability.
23+
5. **Versions Affected**: Specify which versions of the project are affected by the vulnerability.
24+
6. **Your Contact**: Include your name, email address, and any other contact information you wish to share.
25+
26+
## Response and Resolution
27+
28+
Once I receive the vulnerability report, I will acknowledge its receipt within 72 hours. I will conduct an initial review to validate the vulnerability and determine its severity.
29+
30+
If the vulnerability is accepted:
31+
32+
- **Fixing Process**: I will prioritize developing a patch for the vulnerability.
33+
- **Release Timeline**: The patch will be included in the next available release within a reasonable timeframe. Please note that the release cycle might vary, but I will prioritize security fixes.
34+
- **Credit**: If you desire, I will acknowledge your contribution and give you credit for responsibly reporting the vulnerability.
35+
36+
If the vulnerability is declined:
37+
38+
- **Reasoning**: I will provide a reason for the rejection and explain why the reported issue does not qualify as a security vulnerability.
39+
40+
## Security Updates
41+
42+
To ensure the security of go-core, it is crucial that all users update to the latest supported version promptly. Users of older versions that are no longer supported are strongly recommended to upgrade to a supported version to stay protected against potential security threats.
43+
44+
Thank you for helping me make go-core more secure. Your cooperation and responsible disclosure are essential to maintaining the integrity and trustworthiness of this project.
45+
46+
Please note that this security policy is subject to change over time, so it is advisable to check this document periodically for any updates.
47+
48+
Last Updated: August 1, 2023.

0 commit comments

Comments
 (0)