Skip to content

Commit

Permalink
FEATURE: Optimized implementation. (#4)
Browse files Browse the repository at this point in the history
* Updated README

* Optimized to reduce all allocs/op to 2

* Added test for Generate()
  • Loading branch information
mprimeaux authored Oct 28, 2024
1 parent 8b8b4b6 commit 73a60fa
Show file tree
Hide file tree
Showing 8 changed files with 1,001 additions and 441 deletions.
48 changes: 6 additions & 42 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ run:
# Default: [].
build-tags: []

# Exclude certain directories from linting
exclude-dirs:
- "vendor"
- "third_party"
- "generated"

# Which dirs to skip: issues from them won't be reported.
# Can use regexp here: `generated.*`, regexp is applied on full path,
# including the path prefix if one is set.
Expand Down Expand Up @@ -49,48 +55,6 @@ run:
# If false (default) - golangci-lint acquires file lock on start.
allow-parallel-runners: false

linters:
enable:
- asciicheck
- bodyclose
- cyclop
- dogsled
- dupl
- durationcheck
- errname
- errorlint
- exhaustive
- exportloopref
- forbidigo
- forcetypeassert
- funlen
- gochecknoinits
- goconst
- gocritic
- godot
- godox
- gofmt
- goimports
- gomnd
- gosec
- lll
- makezero
- misspell
- nakedret
- nestif
- nilerr
- nlreturn
- noctx
- nolintlint
- predeclared
- revive
- stylecheck
- tagliatelle
- unconvert
- unparam
- wastedassign
- whitespace

output:
sort-results: true

Expand Down
17 changes: 16 additions & 1 deletion CHANGELOG/CHANGELOG-1.x.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
Expand All @@ -14,6 +15,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
### Security

---
## [1.5.0] - 2024-OCT-28

### Added
- **FEATURE**: Added Code of Conduct
- **FEATURE**: Added Contribution Guidelines
### Changed
- **DEBT:** Optimized overall implementation to reduce the allocations per operation to 2.
### Deprecated
### Removed
### Fixed
### Security

---
## [1.4.0] - 2024-OCT-26

Expand Down Expand Up @@ -65,7 +79,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
### Security

[Unreleased]: https://github.com/scriptures-social/platform/compare/v1.4.0...HEAD
[Unreleased]: https://github.com/scriptures-social/platform/compare/v1.5.0...HEAD
[1.5.0]: https://github.com/sixafter/nanoid/compare/v1.4.0...v1.5.0
[1.4.0]: https://github.com/sixafter/nanoid/compare/v1.3.0...v1.4.0
[1.3.0]: https://github.com/sixafter/nanoid/compare/v1.2.0...v1.3.0
[1.2.0]: https://github.com/sixafter/nanoid/compare/v1.0.0...v1.2.0
Expand Down
133 changes: 133 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@

# Contributor Covenant Code of Conduct

## Our Pledge

We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or advances of
any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email address,
without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official email address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[INSERT CONTACT METHOD].
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.

## Enforcement Guidelines

Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:

### 1. Correction

**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.

**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.

### 2. Warning

**Community Impact**: A violation through a single incident or series of
actions.

**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or permanent
ban.

### 3. Temporary Ban

**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.

**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.

### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within the
community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.1, available at
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].

Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].

For answers to common questions about this code of conduct, see the FAQ at
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
[https://www.contributor-covenant.org/translations][translations].

[homepage]: https://www.contributor-covenant.org
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
[Mozilla CoC]: https://github.com/mozilla/diversity
[FAQ]: https://www.contributor-covenant.org/faq
[translations]: https://www.contributor-covenant.org/translations
146 changes: 146 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Contributing

Thank you for your interest in contributing to **NanoID for Go**! Your contributions help make this project better for everyone. This guide outlines the process for contributing to the project, including reporting issues, submitting pull requests, and adhering to the project's code of conduct.

## 📜 Table of Contents

- [Code of Conduct](#code-of-conduct)
- [How to Contribute](#how-to-contribute)
- [Reporting Bugs](#reporting-bugs)
- [Requesting Features](#requesting-features)
- [Submitting Changes](#submitting-changes)
- [Coding Guidelines](#coding-guidelines)
- [Style Guidelines](#style-guidelines)
- [Security Considerations](#-security-considerations)
- [Pull Request Process](#pull-request-process)
---

## 🛡️ Code of Conduct

This project adheres to the [Contributor Covenant Code of Conduct](https://github.com/sixafter/nanoid/blob/main/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [osint@sixafter.com](mailto:osint@sixafter.com).

---

## 🤝 How to Contribute

There are several ways you can contribute to NanoID for Go:

### 🐛 Reporting Bugs

If you encounter a bug or unexpected behavior:

1. **Search Existing Issues**: Check if the issue has already been reported [here](https://github.com/sixafter/nanoid/issues).
2. **Open a New Issue**: If not, open a new issue describing the bug in detail.
- **Provide a Clear Title**: Summarize the problem.
- **Describe the Behavior**: Explain what you expected to happen versus what actually happened.
- **Steps to Reproduce**: Include code snippets or commands that can help reproduce the issue.
- **Environment Details**: Mention your Go version, operating system, and any other relevant information.

### 🌟 Requesting Features

To suggest new features or improvements:

1. **Search Existing Features**: Ensure your idea hasn't been discussed [here](https://github.com/sixafter/nanoid/issues?q=is%3Aissue+is%3Aopen+label%3Afeature).
2. **Open a New Feature Request**: Provide a detailed description of the feature.
- **Describe the Feature**: Explain what the feature is and why it's needed.
- **Use Cases**: Provide examples of how the feature would be used.
- **Potential Implementation**: If possible, suggest how it could be implemented.

### ✨ Submitting Changes

Contributions in the form of bug fixes, improvements, or new features are welcome!

#### 1. Fork the Repository

Fork the repository to your GitHub account by clicking the **Fork** button at the top right of the repository page.

#### 2. Clone Your Fork

Clone the forked repository to your local machine:

```bash
git clone https://github.com/sixafter/nanoid.git
cd nanoid
```

#### 3. Create a New Branch

Create a new branch for your changes:

```bash
git checkout -b feature/your-feature-name
```

#### 4. Make Your Changes

#### 5. Run Tests and Linters

Ensure all tests pass and the code adheres to the style guidelines:

```bash
make lint
make test
```

#### 6. Commit Your Changes

Commit your changes with a clear and descriptive message:

```bash
git add .
git commit -m "Add descriptive commit message"
```

#### 7. Push to Your Fork

Push your changes to your forked repository:

```bash
git push origin feature/your-feature-name
```

#### 8. Open a Pull Request

Navigate to the original repository and click New Pull Request. Provide a clear description of your changes and link any related issues.

## 🎨 Coding Guidelines

Adhering to consistent coding standards ensures the codebase remains clean, readable, and maintainable.

### 🖋️ Style Guidelines

* **Formatting**: Use `make fmt` to format your code.
* **Linting**: Follow the linting rules defined in `.golangci.yaml`. Ensure that your code passes all linters before submitting.
* **Documentation**: Document public functions, types, and methods using Go's standard documentation conventions.
* **Error Handling**: Handle errors gracefully and consistently. Use the predefined error types where applicable.

## 🔒 Security Considerations

* **Randomness**: Ensure that all randomness sources use cryptographically secure methods (crypto/rand).
* **Data Sanitization**: Avoid exposing sensitive data through IDs or logs.

## 🚀 Pull Request Process

Follow these steps to create a successful pull request (PR):

1. Ensure Your Branch is Up-to-Date
* Before opening a PR, make sure your branch is based on the latest main branch.
2. Create a Pull Request
3. Address Feedback
* **Respond Promptly**: Engage with reviewers by responding to comments and making necessary changes.
* **Update Your PR**: Push additional commits to your branch to address feedback.
4. Merge the PR
* Once approved and all checks pass, your PR will be merged by a maintainer.

## 📝 Additional Resources

* [Go Documentation](https://go.dev/doc/)
* [GolangCI-Lint Documentation](https://golangci-lint.run)
* [GitHub Flow](https://docs.github.com/en/get-started/using-github/github-flow)
* [Contributor Covenant Code of Conduct](https://github.com/sixafter/nanoid/blob/main/CODE_OF_CONDUCT.md)

## 🙏 Thank You!

We appreciate your interest in contributing to NanoID for Go! Your efforts help improve the project and support the community. If you have any questions or need assistance, feel free to reach out by opening an issue or contacting the maintainers.

Happy coding! 🎉
Loading

0 comments on commit 73a60fa

Please sign in to comment.