Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
The content of this repo was copied from github.com/BooleanCat/go-functional
  • Loading branch information
BooleanCat committed May 16, 2024
0 parents commit e718140
Show file tree
Hide file tree
Showing 18 changed files with 890 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
name: Bug report
about: Create a report to help us improve
title: "[Bug 🐛]: "
labels: "bug"
assignees: ""
---

**What happened?**

_Provide a description of the issue._

**What did you expect to happen?**

_Explain what you would have expected to happen instead._

**Which version of go-functional were you using?**

_Provide the version number (such as `v1.0.0`)._

**To Reproduce**

_Provide a code snippet or steps to reproduce the issue._

**Do you intend to fix this issue yourself?**

_Yes or no. This is so that the maintainers know to leave you time to make a
contribution rather than just fixing it themselves._

**Additional context**

_Add any other context about the problem here._
33 changes: 33 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[Feature 🔨]: "
labels: "enhancement"
assignees: ""
---

**Is your feature request related to a problem? Please describe.**

A clear and concise description of what the problem is. Ex. I'm always
frustrated when [...].

**Describe the solution you'd like**

A clear and concise description of what you want to happen.

**Provide code snippets to show how this new feature might be used.**

Ideally, provide an [`Example`](https://go.dev/blog/examples) test that
demonstrates the feature's usage.

**Does this incur a breaking change?**

Yes / no.

**Do you intend to build this feature yourself?**

Yes / no (so that it's clear that maintainers should allow you to make a
contribution).

**Additional context**
Add any other context or screenshots about the feature request here.
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule: { interval: weekly }
24 changes: 24 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
**Please provide a brief description of the change.**

A sentence or two is fine, the rest should be clear from the code change and related issue.

**Which issue does this change relate to?**

Please provide a link to the issue that this change resolved.

If there is no such issue, consider creating one first. Discussions concerning proposed changes ought to take place in an issue and not in pull requests. Pull requests not associated with an issue are less likely to be merged and more likely to ask for changes.

**Contribution checklist.**

_Replace the space in each box with "X" to check it off._

- [ ] I have read and understood the CONTRIBUTING guidelines
- [ ] My code is formatted (`make check`)
- [ ] I have run tests (`make test`)
- [ ] All commits in my PR conform to the commit hygiene section
- [ ] I have added relevant tests
- [ ] I have not added any dependencies

**Additional context**

_Add any other context about the problem here._
30 changes: 30 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: test
on:
push: { branches: [main] }
pull_request: {}
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22"
cache: false
- run: make check
env: { SKIP_LINT: true }
- uses: golangci/golangci-lint-action@v6
with: { version: "latest" }
- run: make cov
- uses: codecov/codecov-action@v4
env: { CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}" }
test:
strategy: { matrix: { go-version: ["1.21", "1.22"] } }
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "${{ matrix.go-version }}"
cache: false
- run: make test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
coverage.txt
.vscode/
128 changes: 128 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# 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, 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 behaviour 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 behaviour 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 behaviour and will take appropriate and fair corrective action in
response to any behaviour 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 e-mail 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 behaviour may be
reported to the community leaders responsible for enforcement at
[email protected].
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 behaviour 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
behaviour 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 behaviour. 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 behaviour.

**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 behaviour, 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.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
72 changes: 72 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Contributing to BooleanCat/option

Contributions to this project are very welcome! This guide should help with
instructions on how to submit changes. Contributions can be made in the form of
GitHub [issues](https://github.com/BooleanCat/option/issues) or [pull
requests](https://github.com/BooleanCat/option/pulls).

When submitting an issue, please choose the relevant template or choose a blank
issue if your query doesn't naturally fit into an existing template.

## TL;DR contribution checklist

- [ ] My code is formatted (`make check`)
- [ ] I have run tests (`make test`)
- [ ] My code has no lint errors (`make lint`)
- [ ] All commits in my PR conform to the commit hygiene section
- [ ] I have added relevant tests
- [ ] I have not added any dependencies

## Zero-dependency

This project is a zero-dependency project - which means that consumers using
this project's packages must only incur one dependency: `option`.

Development dependencies are OK as they will not be included as dependencies to
end-users (such as `golangci-lint`).

## Commit hygiene

- Commits should contain only a single change
- Commit messages must use imperative language (e.g. `Add iter.Fold collection
function`)
- Commit messages must explain what is changed, not how it is changed
- The first line of a commit message should be a terse description of the change
containing 72 characters or fewer

## Running tests

Run tests with `make test` from the project root directory.

Tests are written using Go's `testing` package and helpers are available in
`internal/assert`.

Code is linted using `golangci-lint`. The linter may be run using
`make lint`.

## Different types of changes

### Bug fixes

Bug reports are appreciated ahead of bug fixes as early reporting allows the
community to be aware of any issues ahead of a fix being submitted. If you
intend to fix a bug after reporting, that is greatly appreciated - just make
sure to mention you intend to work on it on the issue report so the maintainers
are aware and leave you the chance to make a contribution.

When submitting a bug fix PR, a test must be added (or an existing test
modified) that exposes the bug and your change must make that test pass.

### New features

Issues should be opened ahead of submitting a PR to added a new feature. This is
to prevent you wasting your time should a feature not be desirable and allows
others to have input into the conversation.

All new functionality must be fully tested and new public functions must include
an [`Example` test](https://go.dev/blog/examples) that will be used by the
reference docs to demonstrate its use.

Mark pull requests as "Draft" if you intend to use the pull request as a
workspace but are not yet ready to receive unsolicited feedback on specifics
like commit messages or failing tests.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Tom Godkin

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 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.
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.phony: test check lint cov

check: lint
@go vet ./...
@gofmt -l .
@test -z "$$( gofmt -l . )"

lint:
ifndef SKIP_LINT
@golangci-lint run ./...
endif

test:
go test -race -v ./...

cov: SHELL:=/bin/bash
cov:
go test -race -coverprofile=coverage.txt -covermode=atomic $$( go list ./... | grep -v internal )
Loading

0 comments on commit e718140

Please sign in to comment.