Skip to content

Commit

Permalink
Change filenames based on TheAlgorithms#319 (TheAlgorithms#320)
Browse files Browse the repository at this point in the history
* docs: based on TheAlgorithms#319, all files changed to lowercase without '_' except for '_test.go' files

* update go.mod version to go 1.17

* update golangci-lint version to v1.42.0

* update go-version to 1.17

* update contributing guidelines

* add list from directory.md into readme.md

* Delete DIRECTORY.md

Co-authored-by: Christian Clauss <[email protected]>
Co-authored-by: Andrii Siriak <[email protected]>
  • Loading branch information
3 people authored Aug 25, 2021
1 parent 3da34f8 commit 1ee70c1
Show file tree
Hide file tree
Showing 85 changed files with 182 additions and 303 deletions.
67 changes: 0 additions & 67 deletions .github/workflows/update_directory_md.yml

This file was deleted.

48 changes: 30 additions & 18 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ Welcome to [TheAlgorithms/Go](https://github.com/TheAlgorithms/Go)! Before submi
Being a contributor at The Algorithms, we request you to follow the points mentioned below:

- You did your own work.
- No plagiarism allowed. Any plagiarized work will not be merged.
- No plagiarism is allowed. Any plagiarized work will not be merged.
- Your work will be distributed under the [MIT License](https://github.com/TheAlgoritms/Go/blob/master/LICENSE) once your pull request has been merged.
- Please follow the repository guidelines and standards mentioned below.

**New implementation** New implementations are welcome!

You can add new algorithms or data structures which are **not present in the repository** or that can **improve** the old implementations (**documentation**, **improving test cases**, removing bugs or in any other resonable sense)
You can add new algorithms or data structures that are **not present in the repository** or that can **improve** the old implementations (**documentation**, **improving test cases**, removing bugs, or in any other reasonable sense)

**Issues** Please avoid opening issues asking to be "assigned” to a particular algorithm. This merely creates unnecessary noise for maintainers. Instead, please submit your implementation in a pull request, and it will be evaluated by project maintainers.

Expand All @@ -33,7 +33,7 @@ You can add new algorithms or data structures which are **not present in the rep
- Make sure the file extensions should be `*.go`.
- Use meaning variable names.
- Use standard library inside your code and avoid to import packages from other repositories
- If an implementation of the algorithm already exists, please refer to the [file-name section below](#new-file-name-guidelines).
- If an implementation of the algorithm already exists, please refer to the [filename section below](#new-file-name-guidelines).
- You can suggest reasonable changes to existing algorithms.
- Strictly use snake_case (underscore_separated) in filenames.
- If you have added or modified code, please make sure the code compiles before submitting.
Expand All @@ -55,6 +55,13 @@ You can add new algorithms or data structures which are **not present in the rep
- If you find an algorithm or document without tests, please feel free to create a pull request or issue describing suggested changes.
- Please try to add one or more `Test` functions that will invoke the algorithm implementation on random test data with the expected output.

### Benchmark

- Make sure to add examples and benchmark cases in your `filename_test.go` or `filename_bench.go` if you want separated test and benchmark files.
- If you find an algorithm or document without benchmarks, please feel free to create a pull request or issue describing suggested changes.
- Please try to add one or more `Benchmark` functions that will invoke the algorithm implementation.
- For running the benchmark, you could use this command `go test -bench=.` for more details, read this article [Using Subtests and Sub-benchmarks](https://go.dev/blog/subtests)

#### Typical structure of a program

```go
Expand All @@ -66,8 +73,9 @@ You can add new algorithms or data structures which are **not present in the rep
// description containing links, references,
// math equations, etc.
// author(s) [Name](https://github.com/handle), [Name](https://github.com/handle)
// see related_file.go, another_file.go, file_test.go
// see relatedfile.go, anotherfile.go, file_test.go

// ** Is just an example of how to write description for package and function and other stuff ... **

// Package sort provides primitives for sorting slices and user-defined
// collections.
Expand All @@ -78,13 +86,13 @@ package sort
// name2 package : Add one line description here
// ...
import (
...
...
)


// Fprint formats using the default formats for its operands and writes to w.
// Spaces are added between operands when neither is a string.
// It returns the number of bytes written and any write error encountered.
// It returns the number of bytes written, and any write error encountered.
func Fprint(w io.Writer, a ...interface{}) (n int, err error) {
...
}
Expand All @@ -94,17 +102,21 @@ func Fprint(w io.Writer, a ...interface{}) (n int, err error) {

#### New File Name guidelines

- Use lowercase words with ``"_"`` as a separator
- Use lowercase words without ``"_"`` for the file name
- Use ``"_"`` as a separator only for `_test.go` or `_bench.go`
- For instance

```markdown
MyNewGoFile.GO is incorrect
my_new_go_file.go is correct format
my_new_go_file.go is incorrect
mynewgofile.go is the correct format
mynewgofile_test.go is the correct format
```

- It will be used to dynamically create a directory of files and implementation.
- File name validation will run on Docker to ensure validity.
- If an implementation of the algorithm already exists and your version is different from that implemented, please use incremental numeric digit as a suffix. For example: if `binary_search.go` already exists in the `search` folder, and you are contributing a new implementation, the filename should be `binary_search2.go` and for a third implementation, `binary_search3.go`.
- If an implementation of the algorithm already exists and your version is different from that implemented, please use incremental numeric digit as a suffix. For example: if `binarysearch.go` already exists in the `search` folder, and you are contributing a new implementation, the filename should be `binarysearch2.go` and for a third implementation, `binarysearch3.go`.
- Check out `Go` [Package names](https://go.dev/blog/package-names) roles

#### New Directory guidelines

Expand All @@ -125,17 +137,17 @@ some_new_fancy_category is correct
- It is recommended to keep your changes grouped logically within individual commits. Maintainers find it easier to understand changes that are logically spilled across multiple commits. Try to modify just one or two files in the same directory. Pull requests that span multiple directories are often rejected.

```bash
git add file_xyz.go
git add filexyz.go
git commit -m "your message"
```

Examples of commit messages with semantic prefixes:

```markdown
fix: xyz algorithm bug
feat: add xyx algorithm
test: add test for xyz algorithm
docs: add comments and explanation to xyz algorithm
fix: XYZ algorithm bug
feat: add XYZ algorithm
test: add test for XYZ algorithm
docs: add comments and explanation to XYZ algorithm
```

Common prefixes:
Expand All @@ -147,7 +159,7 @@ Common prefixes:

### Pull Requests

- Checkout our [pull request template](https://github.com/TheAlgorithms/Go/blob/master/.github/PULL_REQUEST_TEMPLATE/pull_request.md
- Check out our [pull request template](https://github.com/TheAlgorithms/Go/blob/master/.github/PULL_REQUEST_TEMPLATE/pull_request.md
)

#### Building Locally
Expand All @@ -162,9 +174,9 @@ go build .
#### Code Formatter

- Installation (only needs to be installed once.)
- Mac (using home-brew): `brew install go`
- Windows (MSYS2 64-bit): `choco install golang` [Chocolatey Package Manager](https://chocolatey.org/)
- Linux (Debian): `sudo apt-get install golang`
- Mac (using home-brew): `brew install go`
- Windows (MSYS2 64-bit): `choco install golang` [Chocolatey Package Manager](https://chocolatey.org/)
- Linux (Debian): `sudo apt-get install golang`
- Running (all platforms): `go run main.go` or `go build main.go`

#### GitHub Actions
Expand Down
Loading

0 comments on commit 1ee70c1

Please sign in to comment.