Skip to content

Commit 1ee70c1

Browse files
Miraddocclausssiriak
authored
Change filenames based on #319 (#320)
* docs: based on #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]>
1 parent 3da34f8 commit 1ee70c1

File tree

85 files changed

+182
-303
lines changed

Some content is hidden

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

85 files changed

+182
-303
lines changed

.github/workflows/update_directory_md.yml

Lines changed: 0 additions & 67 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ Welcome to [TheAlgorithms/Go](https://github.com/TheAlgorithms/Go)! Before submi
1515
Being a contributor at The Algorithms, we request you to follow the points mentioned below:
1616

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

2222
**New implementation** New implementations are welcome!
2323

24-
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)
24+
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)
2525

2626
**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.
2727

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

58+
### Benchmark
59+
60+
- 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.
61+
- If you find an algorithm or document without benchmarks, please feel free to create a pull request or issue describing suggested changes.
62+
- Please try to add one or more `Benchmark` functions that will invoke the algorithm implementation.
63+
- 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)
64+
5865
#### Typical structure of a program
5966

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

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

7280
// Package sort provides primitives for sorting slices and user-defined
7381
// collections.
@@ -78,13 +86,13 @@ package sort
7886
// name2 package : Add one line description here
7987
// ...
8088
import (
81-
...
89+
...
8290
)
8391

8492

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

95103
#### New File Name guidelines
96104

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

100109
```markdown
101110
MyNewGoFile.GO is incorrect
102-
my_new_go_file.go is correct format
111+
my_new_go_file.go is incorrect
112+
mynewgofile.go is the correct format
113+
mynewgofile_test.go is the correct format
103114
```
104115

105116
- It will be used to dynamically create a directory of files and implementation.
106117
- File name validation will run on Docker to ensure validity.
107-
- 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`.
118+
- 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`.
119+
- Check out `Go` [Package names](https://go.dev/blog/package-names) roles
108120

109121
#### New Directory guidelines
110122

@@ -125,17 +137,17 @@ some_new_fancy_category is correct
125137
- 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.
126138

127139
```bash
128-
git add file_xyz.go
140+
git add filexyz.go
129141
git commit -m "your message"
130142
```
131143

132144
Examples of commit messages with semantic prefixes:
133145

134146
```markdown
135-
fix: xyz algorithm bug
136-
feat: add xyx algorithm
137-
test: add test for xyz algorithm
138-
docs: add comments and explanation to xyz algorithm
147+
fix: XYZ algorithm bug
148+
feat: add XYZ algorithm
149+
test: add test for XYZ algorithm
150+
docs: add comments and explanation to XYZ algorithm
139151
```
140152

141153
Common prefixes:
@@ -147,7 +159,7 @@ Common prefixes:
147159

148160
### Pull Requests
149161

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

153165
#### Building Locally
@@ -162,9 +174,9 @@ go build .
162174
#### Code Formatter
163175

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

170182
#### GitHub Actions

0 commit comments

Comments
 (0)