├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ ├── feature_request.md
│ ├── question.md
│ └── refactor.md
├── pre-commit
├── pre-push
└── workflows
│ ├── go-fmt.yml
│ ├── go.yml
│ ├── golangci-lint.yml
│ └── stale.yml
├── .gitignore
├── LICENSE
├── Makefile
├── README-zh_CN.md
├── README.md
├── cmd
└── optioner
│ └── main.go
├── example
├── examples.go
├── third_party
│ └── types.go
└── user_option.go
├── go.mod
├── go.sum
├── options
└── options_generator.go
├── script
├── fmt.sh
└── setup.sh
└── templates
├── additional_templates.go
└── options_templates.go
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 错误报告 | Bug Report
3 | about: 请详细描述您在使用过程中遇到的问题。| Please provide a detailed description of the issue you encountered during use.
4 | title: ""
5 | labels: ["bug"]
6 | assignees: ''
7 | ---
8 |
9 | 在提交之前请先查找 [已有 issues](https://github.com/chenmingyong0423/go-mongox/issues),避免重复上报。| Before submitting, please search for [existing issues](https://github.com/chenmingyong0423/go-mongox/issues) to avoid duplicate reports.
10 |
11 | 并且确保自己已经 | Also, ensure that you have:
12 | - [ ] 阅读过文档 | Read the documentation
13 | - [ ] 阅读过注释 | Reviewed the comments
14 | - [ ] 阅读过例子 | Looked at the examples
15 |
16 |
17 | ### 您使用的 mongox 版本 | The version of mongox you are using
18 |
19 | ### 您遇到的问题 | The issue you encountered.
20 |
21 | ### 复现步骤 | Steps to reproduce
22 | > 请提供简单的复现代码 | Please provide simple code to reproduce the issue.
23 |
24 | ### 错误日志或者截图 | Error logs or Screenshots
25 |
26 | ### 你排查的结果,或者你觉得可行的修复方案 | Your Findings or Possible Solutions
27 | > 可选。我们希望你能够尽量先排查问题,帮助我们减轻维护负担。这对于你个人能力提升同样是有帮助的。| Optional. We hope you can try to troubleshoot the issue first, helping us to reduce our maintenance burden. This is also beneficial for your personal skill development
28 |
29 | #### 您期望的结果 | Expected Outcome
30 |
31 | ### 你设置的的 Go 环境 | Your Go Environment Setting
32 | > 上传 `go env` 的结果 | Upload the result of `go env`
33 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 功能请求 | Feature Request
3 | about: 请描述您期望的功能 | The features you expect.
4 | title: '[功能请求] | [Feature Request] '
5 | labels: ['enhancement']
6 | assignees: ''
7 | ---
8 |
9 | ### 使用场景 | Use Case Scenario
10 | > 请尽可能详细地描述您希望添加的功能。包括其具体用途和实现的效果。| Please describe the feature you would like to be added in as much detail as possible. Include its specific use case and how it would function.
11 |
12 | ### 可行方案 | Feasible Solutions
13 | > 如果你知道有框架提供了类似功能,可以在这里描述,并且给出文档或者例子。 | If you are aware of any frameworks that provide similar features, please describe them here and include documentation or examples.
14 | >
15 | > 如果你有设计思路或者解决方案,请在这里提供。你可以提供多个方案,并且给出自己的选择。| If you have any design ideas or proposed solutions, please share them here. You may provide multiple options and explain your preference.
16 |
17 | ### 其它 | Others
18 | > 任何你觉得有利于解决问题的补充说明 | Any additional information you think may be helpful in solving the problem.
19 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/question.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 问题 | Question
3 | about: 你想问的问题 | The question you want to ask
4 | title: ''
5 | labels: ["question"]
6 | ---
7 |
8 | 在提交之前请先查找 [已有 issues](https://github.com/chenmingyong0423/go-mongox/issues),避免重复上报。| Before submitting, please search for [existing issues](https://github.com/chenmingyong0423/go-mongox/issues) to avoid duplicate reports.
9 |
10 | ### 您使用的 mongox 版本 | The version of mongox you are using
11 |
12 | ### 你的问题 | Your question
13 |
14 | ### 你设置的的 Go 环境 | Your Go Environment Setting
15 | > 上传 `go env` 的结果 | Upload the result of `go env`
16 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/refactor.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: 重构请求 | Refactor request
3 | about: 重构已有代码 | Refactor existing code
4 | title: ''
5 | labels: [ refactor ]
6 | assignees: ''
7 | ---
8 |
9 | 在提交之前请先查找 [已有 issues](https://github.com/chenmingyong0423/go-mongox/issues),避免重复上报。| Before submitting, please search for [existing issues](https://github.com/chenmingyong0423/go-mongox/issues) to avoid duplicate reports.
10 |
11 | ### 您使用的 mongox 版本 | The version of mongox you are using
12 |
13 | ### 当前实现缺陷 | Current Implementation Deficiencies
14 |
15 | ### 重构方案 | Refactoring Plan
16 | > 描述可以如何重构,以及重构之后带来的效果,如可读性、性能等方面的提升 | Describe how you can refactor, and the benefits it would bring, such as improvements in readability, performance, etc
17 |
18 | ### 其它 | Others
19 | > 任何你觉得有利于解决问题的补充说明 | Any other information you think would be helpful in addressing the issue
20 |
21 | ### 你设置的的 Go 环境 | Your Go Environment Setting
22 | > 上传 `go env` 的结果 | Upload the result of `go env`
23 |
--------------------------------------------------------------------------------
/.github/pre-commit:
--------------------------------------------------------------------------------
1 | # Copyright 2023 chenmingyong0423
2 |
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 |
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | #
15 | # This script does not handle file names that contain spaces.
16 |
17 | # Pre-commit configuration
18 |
19 | RESULT=$(make check)
20 | printf "Checking in progress...\n"
21 |
22 | if [ -n "$RESULT" ]; then
23 | echo >&2 "[ERROR]: One or more files have changed, please add the changed files to this submission."
24 | exit 1
25 | fi
26 |
27 | exit 0
28 |
--------------------------------------------------------------------------------
/.github/pre-push:
--------------------------------------------------------------------------------
1 | # Copyright 2023 chenmingyong0423
2 |
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 |
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 | #
15 | # This script does not handle file names that contain spaces.
16 |
17 | # Pre-push configuration
18 | remote=$1
19 | url=$2
20 | echo >&2 "Try pushing $2 to $1"
21 |
22 | TEST="go test ./... -race -cover -failfast"
23 |
24 | LINTER="golangci-lint run"
25 |
26 | # Run test and return if failed
27 | printf "Running go test..."
28 | $TEST
29 | RESULT=$?
30 | if [ $RESULT -ne 0 ]; then
31 | echo >&2 "$TEST"
32 | echo >&2 "Check code to pass test."
33 | exit 1
34 | fi
35 |
36 | # Run linter and return if failed
37 | printf "Running go linter..."
38 | $LINTER
39 | RESULT=$?
40 | if [ $RESULT -ne 0 ]; then
41 | echo >&2 "$LINTER"
42 | echo >&2 "Check code to pass linter."
43 | exit 1
44 | fi
45 |
46 | exit 0
47 |
--------------------------------------------------------------------------------
/.github/workflows/go-fmt.yml:
--------------------------------------------------------------------------------
1 | # Copyright 2023 chenmingyong0423
2 |
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 |
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | name: Format Go code
16 |
17 | on:
18 | push:
19 | branches: [ main, dev]
20 | pull_request:
21 | branches: [ main, dev]
22 |
23 | jobs:
24 | build:
25 | runs-on: ubuntu-latest
26 | steps:
27 | - uses: actions/checkout@v4
28 | - name: Set up Go
29 | uses: actions/setup-go@v5
30 | with:
31 | go-version: ">=1.22.0"
32 |
33 | - name: Install goimports
34 | run: go install golang.org/x/tools/cmd/goimports@latest
35 |
36 | - name: Check
37 | run: |
38 | make check
39 | if [ -n "$(git status --porcelain)" ]; then
40 | echo >&2 "error: Please execute the command → 'make check' in the local warehouse and submit again."
41 | exit 1
42 | fi
43 |
--------------------------------------------------------------------------------
/.github/workflows/go.yml:
--------------------------------------------------------------------------------
1 | # Copyright 2023 chenmingyong0423
2 |
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 |
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | # This workflow will build a golang project
16 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
17 |
18 | name: Go
19 |
20 | on:
21 | push:
22 | branches: [ "main", "dev" ]
23 | pull_request:
24 | branches: [ "main", "dev" ]
25 |
26 | jobs:
27 |
28 | build:
29 | runs-on: ubuntu-latest
30 | steps:
31 | - uses: actions/checkout@v4
32 |
33 | - name: Set up Go
34 | uses: actions/setup-go@v5
35 | with:
36 | go-version: '1.22'
37 |
38 | - name: Build
39 | run: go build -v ./...
40 |
41 | - name: Test
42 | run: go test -race -coverprofile=cover.out -v ./...
43 |
44 | - name: Post Coverage
45 | uses: codecov/codecov-action@v4
46 |
--------------------------------------------------------------------------------
/.github/workflows/golangci-lint.yml:
--------------------------------------------------------------------------------
1 | # Copyright 2023 chenmingyong0423
2 |
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 |
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | name: golangci-lint
16 | on:
17 | push:
18 | tags:
19 | - v*
20 | branches:
21 | - master
22 | - main
23 | - dev
24 | pull_request:
25 | permissions:
26 | contents: read
27 | # Optional: allow read access to pull request. Use with `only-new-issues` option.
28 | # pull-requests: read
29 | jobs:
30 | golangci:
31 | name: lint
32 | runs-on: ubuntu-latest
33 | steps:
34 | - uses: actions/setup-go@v5
35 | with:
36 | go-version: '1.22'
37 | - uses: actions/checkout@v4
38 | - name: golangci-lint
39 | uses: golangci/golangci-lint-action@v6
40 | with:
41 | # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
42 | version: latest
43 |
44 | # Optional: working directory, useful for monorepos
45 | # working-directory: somedir
46 |
47 | # Optional: golangci-lint command line arguments.
48 | args: --timeout=10m # --issues-exit-code=0
49 |
50 | # Optional: show only new issues if it's a pull request. The default value is `false`.
51 | only-new-issues: true
52 |
53 | # Optional: if set to true then the all caching functionality will be complete disabled,
54 | # takes precedence over all other caching options.
55 | # skip-cache: true
56 |
57 | # Optional: if set to true then the action don't cache or restore ~/go/pkg.
58 | # skip-pkg-cache: true
59 |
60 | # Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
61 | # skip-build-cache: true
62 |
--------------------------------------------------------------------------------
/.github/workflows/stale.yml:
--------------------------------------------------------------------------------
1 | # Copyright 2023 chenmingyong0423
2 |
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 |
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | name: Mark stale issues and pull requests
16 |
17 | on:
18 | schedule:
19 | - cron: "30 1 * * *"
20 |
21 | jobs:
22 | stale:
23 |
24 | runs-on: ubuntu-latest
25 |
26 | steps:
27 | - uses: actions/stale@v9
28 | with:
29 | repo-token: ${{ secrets.GITHUB_TOKEN }}
30 | stale-issue-message: 'This issue is inactive for a long time.'
31 | stale-pr-message: 'This PR is inactive for a long time'
32 | stale-issue-label: 'inactive-issue'
33 | stale-pr-label: 'inactive-pr'
34 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # If you prefer the allow list template instead of the deny list, see community template:
2 | # https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
3 | #
4 | # Binaries for programs and plugins
5 | *.exe
6 | *.exe~
7 | *.dll
8 | *.so
9 | *.dylib
10 |
11 | # Test binary, built with `go test -c`
12 | *.test
13 |
14 | # Output of the go coverage tool, specifically when used with LiteIDE
15 | *.out
16 |
17 | # Dependency directories (remove the comment below to include it)
18 | # vendor/
19 |
20 | # Go workspace file
21 | go.work
22 |
23 | .idea
24 |
25 | ./.idea
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | # 单元测试
2 | .PHONY: ut
3 | ut:
4 | @go test -race ./...
5 |
6 | .PHONY: setup
7 | setup:
8 | @sh ./script/setup.sh
9 |
10 | .PHONY: lint
11 | lint:
12 | golangci-lint run
13 |
14 | .PHONY: fmt
15 | fmt:
16 | @sh ./script/fmt.sh
17 |
18 | .PHONY: tidy
19 | tidy:
20 | @go mod tidy -v
21 |
22 | .PHONY: check
23 | check:
24 | @$(MAKE) --no-print-directory fmt
25 | @$(MAKE) --no-print-directory tidy
26 |
27 | .PHONY: e2e_up
28 | e2e_up:
29 | docker-compose -f script/integration_test_compose.yml up -d
30 |
31 | .PHONY: e2e_down
32 | e2e_down:
33 | docker-compose -f script/integration_test_compose.yml down -v
--------------------------------------------------------------------------------
/README-zh_CN.md:
--------------------------------------------------------------------------------
1 |
2 | go-optioner
3 |
4 |
5 | [](https://github.com/chenmingyong0423/go-optioner/stargazers)
6 | [](https://github.com/chenmingyong0423/go-optioner/issues)
7 | [](https://github.com/chenmingyong0423/go-optioner/blob/main/LICENSE)
8 | [](https://github.com/chenmingyong0423/go-optioner)
9 | [](https://goreportcard.com/report/github.com/chenmingyong0423/go-optioner)
10 | [](#contributors-)
11 |
12 | `go-optioner` 是一个在 Go 代码中生成函数选项模式代码的工具。该工具可以根据给定的结构定义自动生成相应的选项代码。
13 |
14 | ---
15 |
16 | [English](./README.md) | 中文简体
17 |
18 | # 安装
19 | - 1、`go install github.com/chenmingyong0423/go-optioner/cmd/optioner@latest`
20 | - 2、执行 `optioner` 命令检查是否安装成功
21 | ```
22 | > optioner
23 | optioner is a tool for generating functional options pattern.
24 | Usage:
25 | optioner [flags]
26 | Flags:
27 | -type
28 | -output