在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:exercism/go开源软件地址:https://github.com/exercism/go开源编程语言:Go 99.5%开源软件介绍:Exercism Go TrackExercism exercises in Go IssuesWe welcome issues filed at https://github.com/exercism/go/issues for problems of any size. Feel free to report typographical errors or poor wording. We are most interested in improving the quality of the test suites. You can greatly help us improve the quality of the exercises by filing reports of invalid solutions that pass tests or of valid solutions that fail tests. Development setupBeyond filing issues, if you would like to contribute directly to the Go code in the Exercism Go track, you should follow some standard Go development practices. You should have a recent version of Go installed, ideally either the current release, the previous release, or tip. You will need a github account and you will need to fork exercism/go to your account.
See GitHub Help if you are unfamiliar with the process.
Clone your fork with the command: Note that unlike most other Go code, it is not necessary to clone this to your GOPATH. This is because this repo only imports from the standard library and isn't expected to be imported by other packages. Your Go code should be formatted using the gofmt tool. There is a misspelling tool. You can install and occasionally run it to find low hanging typo problems. #570 It's not added into CI since it could give false positives. Contributing GuidePlease be familiar with the contributing guide in the docs repository. This describes some great ways to get involved. In particular, please read the Pull Request Guidelines before opening a pull request. Exercism Go styleLet's walk through an example, non-existent, exercise, which we'll call
Exercise configurationAn exercise is configured
via an entry in the exercises array in config.json file. If {
"slug": "fizzbuzz",
"uuid": "mumblety-peg-whatever",
"core": false,
"unlocked_by": "two-fer",
"difficulty": 1,
"topics": ["conditionals"]
} See Exercise Configuration for more info. Exercise files: OverviewFor any exercise you may see a number of files present in a directory under ~/go/exercises/fizzbuzz
$ tree -a
.
├── cases_test.go
├── example.go
├── fizzbuzz.go
├── fizzbuzz_test.go
├── .meta
│ └── description.md
│ └── gen.go
│ └── hints.md
│ └── metadata.yml
└── README.md This list of files can vary across exercises.
Not all exercises use all of these files.
Exercises originate their test data and README text from the Exercism problem-specification repository.
This repository collects common information for all exercises across all tracks.
However, should track-specific documentation need to be included with the exercise, files in an exercise's Let's briefly describe each file:
In some exercises there can be extra files, for instance the series exercise contains extra test files. Ignored filesWhen a user fetches an exercise, they do not need to get all the files within an exercise directory. For instance; the example.go files that contain an example solution, or the gen.go files used to generate an exercise's test cases. Therefore there are certain files and directories that are ignored when an exercise is fetched. These are:
Example solutionsexample.go is a reference solution.
It is a valid solution that the CI (continuous integration) service can run tests against.
Files with "example" in the file name are skipped by the Stub filesStub files, such as leap.go, are a starting point for solutions.
Not all exercises need to have a stub file, only exercises early in the syllabus.
By convention, the stub file for an exercise with slug TestsThe test file is fetched for the solver and deserves attention for consistency and appearance. The Identifiers within the test function appear in actual-expected order as described
at Useful Test Failures.
Here the identifier In Go we generally have all tests enabled and do not ask the solver to edit the test program, to enable progressive tests for example.
Testable examplesSome exercises can contain Example tests that document the exercise API. These examples are run alongside the standard exercise tests and will verify that the exercise API is working as expected. They are not required by all exercises and are not intended to replace the data-driven tests. They are most useful for providing examples of how an exercise's API is used. Have a look at the example tests in the clock exercise to see them in action. ErrorsWe like errors in Go. It's not idiomatic Go to ignore invalid data or have undefined behavior. Sometimes our Go tests require an error return where other language tracks don't. BenchmarksIn most test files there will also be benchmark tests, as can be seen at the end of the leap_test.go file. In Go, benchmarking is a first-class citizen of the testing package. We throw in benchmarks because they're interesting, and because it is idiomatic in Go to think about performance. There is no critical use for these though. Usually they will just bench the combined time to run over all the test data rather than attempt precise timings on single function calls. They are useful if they let the solver try a change and see a performance effect. Generating test casesSome problems that are implemented in multiple tracks use the same inputs and outputs to define the test suites. Where the problem-specifications repository contains a canonical-data.json file with these inputs and outputs, we can generate the test cases programmatically. See the gen.go file in the Test case generators are named gen.go and are kept in a special .meta directory within each exercise that makes use of a test cases generator. This .meta directory will be ignored when a user fetches an exercise. Whenever the shared JSON data changes, the test cases will need to be regenerated.
The generator will first look for a local copy of the problem-specifications repository.
If there isn't one it will attempt to get the relevant json data for the exercise from the problem-specifications repository on GitHub.
The generator uses the GitHub API to find some information about exercises when it cannot find a local copy of problem-specifications.
This can cause throttling issues if working with a large number of exercises.
We therefore recommend using a local copy of the repository when possible (remember to keep it current |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论