pax_global_header00006660000000000000000000000064142132254650014516gustar00rootroot0000000000000052 comment=ee0b0d51c1663e9e5ed3e11d1e7d2d02179f86ea moul-http2curl-ee0b0d5/000077500000000000000000000000001421322546500151055ustar00rootroot00000000000000moul-http2curl-ee0b0d5/.gitattributes000066400000000000000000000004651421322546500200050ustar00rootroot00000000000000# Auto detect text files and perform LF normalization * text=auto # Collapse vendored and generated files on GitHub vendor/* linguist-vendored rules.mk linguest-vendored */vendor/* linguist-vendored *.gen.* linguist-generated *.pb.go linguist-generated # Reduce conflicts on markdown files *.md merge=union moul-http2curl-ee0b0d5/.github/000077500000000000000000000000001421322546500164455ustar00rootroot00000000000000moul-http2curl-ee0b0d5/.github/CODEOWNERS000066400000000000000000000000101421322546500200270ustar00rootroot00000000000000* @moul moul-http2curl-ee0b0d5/.github/CODE_OF_CONDUCT.md000066400000000000000000000064371421322546500212560ustar00rootroot00000000000000# Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, 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. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers 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, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at m+coc-report@42.am. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html [homepage]: https://www.contributor-covenant.org For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq moul-http2curl-ee0b0d5/.github/CONTRIBUTING.md000066400000000000000000000004621421322546500207000ustar00rootroot00000000000000# Contributing When contributing to this repository, you can first discuss the change you wish to make via issue, email, or any other method with the maintainers of this repository before making a change. Please note we have a code of conduct, please follow it in all your interactions with the project. moul-http2curl-ee0b0d5/.github/FUNDING.yml000066400000000000000000000002031421322546500202550ustar00rootroot00000000000000github: ["moul"] patreon: moul open_collective: moul custom: - "https://www.buymeacoffee.com/moul" - "https://manfred.life/donate" moul-http2curl-ee0b0d5/.github/ISSUE_TEMPLATE/000077500000000000000000000000001421322546500206305ustar00rootroot00000000000000moul-http2curl-ee0b0d5/.github/ISSUE_TEMPLATE/bug_report.md000066400000000000000000000013311421322546500233200ustar00rootroot00000000000000--- name: Bug report about: Create a report to help us improve title: "[BUG] " labels: bug assignees: '' --- **Describe the bug** A clear and concise description of what the bug is. **To Reproduce** Steps to reproduce the behavior: 1. Go to '...' 2. Type '....' 3. See error **Expected behavior** A clear and concise description of what you expected to happen. **Screenshots / Logs** If applicable, add screenshots or logs to help explain your problem. **Versions (please complete the following information, if relevant):** - Software version: [e.g. v1.2.3, latest, building from sources] - OS: [e.g. Ubuntu, Mac, iOS, ...] - Golang version [e.g. 1.13] **Additional context** Add any other context about the problem here. moul-http2curl-ee0b0d5/.github/ISSUE_TEMPLATE/custom.md000066400000000000000000000002131421322546500224600ustar00rootroot00000000000000--- name: Custom about: 'Anything else: questions, discussions, thanks, ascii-arts, ...' title: '' labels: discussion assignees: moul --- moul-http2curl-ee0b0d5/.github/ISSUE_TEMPLATE/feature_request.md000066400000000000000000000011431421322546500243540ustar00rootroot00000000000000--- name: Feature request about: Suggest an idea for this project title: "[IDEA] " 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. **Describe alternatives you've considered** A clear and concise description of any alternative solutions or features you've considered. **Additional context** Add any other context or screenshots about the feature request here. moul-http2curl-ee0b0d5/.github/PULL_REQUEST_TEMPLATE.md000066400000000000000000000000611421322546500222430ustar00rootroot00000000000000 moul-http2curl-ee0b0d5/.github/dependabot.yml000066400000000000000000000006251421322546500213000ustar00rootroot00000000000000version: 2 updates: - package-ecosystem: docker directory: "/" schedule: interval: daily time: "04:00" open-pull-requests-limit: 10 - package-ecosystem: github-actions directory: "/" schedule: interval: daily time: "04:00" open-pull-requests-limit: 10 - package-ecosystem: gomod directory: "/" schedule: interval: daily time: "04:00" open-pull-requests-limit: 10 moul-http2curl-ee0b0d5/.github/renovate.json000066400000000000000000000001241421322546500211600ustar00rootroot00000000000000{ "extends": [ "config:base" ], "groupName": "all", "gomodTidy": true } moul-http2curl-ee0b0d5/.github/workflows/000077500000000000000000000000001421322546500205025ustar00rootroot00000000000000moul-http2curl-ee0b0d5/.github/workflows/go.yml000066400000000000000000000073021421322546500216340ustar00rootroot00000000000000name: Go on: push: tags: - v* branches: - master paths: - '**.go' - ".goreleaser.yml" - ".golangci.yml" - ".dockerignore" - "Makefile" - "rules.mk" - "go.*" - ".github/workflows/go.yml" pull_request: paths: - '**.go' - ".goreleaser.yml" - ".golangci.yml" - ".dockerignore" - "Makefile" - "rules.mk" - "go.*" - ".github/workflows/go.yml" jobs: golangci-lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: golangci-lint uses: golangci/golangci-lint-action@v3.1.0 with: version: v1.38 #github-token: ${{ secrets.GITHUB_TOKEN }} args: --timeout=2m only-new-issues: false working-directory: . tests-on-windows: needs: golangci-lint # run after golangci-lint action to not produce duplicated errors runs-on: windows-latest strategy: matrix: golang: - 1.16.x steps: - uses: actions/checkout@v3 - name: Install Go uses: actions/setup-go@v2 with: go-version: ${{ matrix.golang }} - name: Run tests on Windows run: make.exe unittest continue-on-error: true tests-on-mac: needs: golangci-lint # run after golangci-lint action to not produce duplicated errors runs-on: macos-latest strategy: matrix: golang: - 1.16.x env: OS: macos-latest GOLANG: ${{ matrix.golang }} steps: - uses: actions/checkout@v3 - name: Install Go uses: actions/setup-go@v2 with: go-version: ${{ matrix.golang }} - uses: actions/cache@v2.1.7 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ matrix.golang }}-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go-${{ matrix.golang }}- - name: Run tests on Unix-like operating systems run: make unittest - name: Check go.mod and go.sum run: | go mod tidy -v git --no-pager diff go.mod go.sum git --no-pager diff --quiet go.mod go.sum - name: Upload coverage to Codecov uses: codecov/codecov-action@v2.1.0 with: #token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.txt flags: unittests env_vars: OS,GOLANG name: codecov-umbrella fail_ci_if_error: false tests-on-linux: needs: golangci-lint # run after golangci-lint action to not produce duplicated errors runs-on: ubuntu-latest strategy: matrix: golang: - 1.14.x - 1.15.x - 1.16.x env: OS: ubuntu-latest GOLANG: ${{ matrix.golang }} steps: - uses: actions/checkout@v3 - name: Install Go uses: actions/setup-go@v2 with: go-version: ${{ matrix.golang }} - uses: actions/cache@v2.1.7 with: path: ~/go/pkg/mod key: ${{ runner.os }}-go-${{ matrix.golang }}-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ runner.os }}-go-${{ matrix.golang }}- - name: Check go.mod and go.sum run: | go mod tidy -v git --no-pager diff go.mod go.sum git --no-pager diff --quiet go.mod go.sum - name: Run tests on Unix-like operating systems run: make unittest - name: Upload coverage to Codecov uses: codecov/codecov-action@v2.1.0 with: #token: ${{ secrets.CODECOV_TOKEN }} file: ./coverage.txt flags: unittests env_vars: OS,GOLANG name: codecov-umbrella fail_ci_if_error: false moul-http2curl-ee0b0d5/.github/workflows/pr.yml000066400000000000000000000017501421322546500216510ustar00rootroot00000000000000name: PR on: #pull_request_target: pull_request: branches: [ master ] issue_comment: types: [ edited ] jobs: preview: name: Release-Notes Preview runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - run: | git fetch --prune --unshallow --tags - uses: snyk/release-notes-preview@v1.6.2 with: releaseBranch: master env: GITHUB_PR_USERNAME: ${{ github.actor }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} doc: name: Documentation runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 with: depth: 1 - uses: nosborn/github-action-markdown-cli@master with: files: . config_file: ./tool/lint/.markdownlint.json - uses: K-Phoen/action-misspell@master with: github_token: ${{ github.token }} reporter: github-pr-review locale: "US" - name: alexjs uses: theashraf/alex-action@master moul-http2curl-ee0b0d5/.github/workflows/release.yml000066400000000000000000000017731421322546500226550ustar00rootroot00000000000000name: Release on: push: branches: - master jobs: release: name: releaser runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Unshallow run: git fetch --prune --unshallow - name: Run Semantic Release id: semantic uses: docker://ghcr.io/codfish/semantic-release-action:v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set up Go if: steps.semantic.outputs.new-release-published == 'true' uses: actions/setup-go@v2 with: go-version: 1.15.x - name: Register version on pkg.go.dev if: steps.semantic.outputs.new-release-published == 'true' run: | package=$(cat go.mod | grep ^module | awk '{print $2}') version=v${{ steps.semantic.outputs.release-version }} url=https://proxy.golang.org/${package}/@v/${version}.info set -x +e curl -i $url moul-http2curl-ee0b0d5/.gitignore000066400000000000000000000005001421322546500170700ustar00rootroot00000000000000# Temporary files *~ *# .#* coverage.txt # Vendors package-lock.json node_modules/ vendor/ # Binaries for programs and plugins dist/ gin-bin *.exe *.exe~ *.dll *.so *.dylib # Test binary, build with `go test -c` *.test # Output of the go coverage tool, specifically when used with LiteIDE *.out # IDE settings .ideamoul-http2curl-ee0b0d5/.releaserc.js000066400000000000000000000003101421322546500174600ustar00rootroot00000000000000module.exports = { branch: 'master', plugins: [ '@semantic-release/commit-analyzer', '@semantic-release/release-notes-generator', '@semantic-release/github', ], }; moul-http2curl-ee0b0d5/AUTHORS000066400000000000000000000011651421322546500161600ustar00rootroot00000000000000# This file lists all individuals having contributed content to the repository. # For how it is generated, see 'https://github.com/moul/rules.mk' Darko Djalevski Drew LeSueur Elliot Chance Hani Zakher Jay Taylor Manfred Touron <94029+moul@users.noreply.github.com> Manfred Touron psaffrey Quentin Perez Renovate Bot Richardson Lima Th3Whit3D3ath <49405908+Th3Whit3D3ath@users.noreply.github.com> moul-http2curl-ee0b0d5/COPYRIGHT000066400000000000000000000014161421322546500164020ustar00rootroot00000000000000Copyright 2015-2021 Manfred Touron and other http2curl Developers. Intellectual Property Notice ---------------------------- http2curl is licensed under the Apache License, Version 2.0 (see LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0) or the MIT license (see LICENSE-MIT or http://opensource.org/licenses/MIT), at your option. Copyrights and patents in the http2curls project are retained by contributors. No copyright assignment is required to contribute to http2curl. SPDX-License-Identifier: (Apache-2.0 OR MIT) SPDX usage ---------- Individual files may contain SPDX tags instead of the full license text. This enables machine processing of license information based on the SPDX License Identifiers that are available here: https://spdx.org/licenses/ moul-http2curl-ee0b0d5/LICENSE-APACHE000066400000000000000000000261621421322546500170400ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2015-2021 Manfred Touron (manfred.life) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. moul-http2curl-ee0b0d5/LICENSE-MIT000066400000000000000000000021041421322546500165360ustar00rootroot00000000000000Copyright (c) 2015-2021 Manfred Touron (manfred.life) 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. moul-http2curl-ee0b0d5/Makefile000066400000000000000000000000701421322546500165420ustar00rootroot00000000000000GOPKG ?= moul.io/http2curl all: test include rules.mk moul-http2curl-ee0b0d5/README.md000066400000000000000000000056241421322546500163730ustar00rootroot00000000000000# http2curl :triangular_ruler: Convert Golang's http.Request to CURL command line [![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white)](https://pkg.go.dev/moul.io/http2curl) [![License](https://img.shields.io/badge/license-Apache--2.0%20%2F%20MIT-%2397ca00.svg)](https://github.com/moul/http2curl/blob/master/COPYRIGHT) [![GitHub release](https://img.shields.io/github/release/moul/http2curl.svg)](https://github.com/moul/http2curl/releases) [![Docker Metrics](https://images.microbadger.com/badges/image/moul/http2curl.svg)](https://microbadger.com/images/moul/http2curl) [![Made by Manfred Touron](https://img.shields.io/badge/made%20by-Manfred%20Touron-blue.svg?style=flat)](https://manfred.life/) [![Go](https://github.com/moul/http2curl/workflows/Go/badge.svg)](https://github.com/moul/http2curl/actions?query=workflow%3AGo) [![Release](https://github.com/moul/http2curl/workflows/Release/badge.svg)](https://github.com/moul/http2curl/actions?query=workflow%3ARelease) [![PR](https://github.com/moul/http2curl/workflows/PR/badge.svg)](https://github.com/moul/http2curl/actions?query=workflow%3APR) [![GolangCI](https://golangci.com/badges/github.com/moul/http2curl.svg)](https://golangci.com/r/github.com/moul/http2curl) [![codecov](https://codecov.io/gh/moul/http2curl/branch/master/graph/badge.svg)](https://codecov.io/gh/moul/http2curl) [![Go Report Card](https://goreportcard.com/badge/moul.io/http2curl)](https://goreportcard.com/report/moul.io/http2curl) [![CodeFactor](https://www.codefactor.io/repository/github/moul/http2curl/badge)](https://www.codefactor.io/repository/github/moul/http2curl) To do the reverse operation, check out [mholt/curl-to-go](https://github.com/mholt/curl-to-go). ## Example ```go import ( "http" "moul.io/http2curl" ) data := bytes.NewBufferString(`{"hello":"world","answer":42}`) req, _ := http.NewRequest("PUT", "http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu", data) req.Header.Set("Content-Type", "application/json") command, _ := http2curl.GetCurlCommand(req) fmt.Println(command) // Output: curl -X PUT -d "{\"hello\":\"world\",\"answer\":42}" -H "Content-Type: application/json" http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu ``` ## Install ```bash go get moul.io/http2curl ``` ## Usages - https://github.com/parnurzeal/gorequest - https://github.com/scaleway/scaleway-cli - https://github.com/nmonterroso/cowsay-slackapp - https://github.com/moul/as-a-service - https://github.com/gavv/httpexpect - https://github.com/smallnest/goreq ## License © 2019-2021 [Manfred Touron](https://manfred.life) Licensed under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) ([`LICENSE-APACHE`](LICENSE-APACHE)) or the [MIT license](https://opensource.org/licenses/MIT) ([`LICENSE-MIT`](LICENSE-MIT)), at your option. See the [`COPYRIGHT`](COPYRIGHT) file for more details. `SPDX-License-Identifier: (Apache-2.0 OR MIT)` moul-http2curl-ee0b0d5/doc.go000066400000000000000000000000221421322546500161730ustar00rootroot00000000000000package http2curl moul-http2curl-ee0b0d5/go.mod000066400000000000000000000001571421322546500162160ustar00rootroot00000000000000module moul.io/http2curl/v2 go 1.13 require github.com/tailscale/depaware v0.0.0-20210622194025-720c4b409502 moul-http2curl-ee0b0d5/go.sum000066400000000000000000000100201421322546500162310ustar00rootroot00000000000000github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/pkg/diff v0.0.0-20200914180035-5b29258ca4f7 h1:+/+DxvQaYifJ+grD4klzrS5y+KJXldn/2YTl5JG+vZ8= github.com/pkg/diff v0.0.0-20200914180035-5b29258ca4f7/go.mod h1:zO8QMzTeZd5cpnIkz/Gn6iK0jDfGicM1nynOkkPIl28= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/tailscale/depaware v0.0.0-20210622194025-720c4b409502 h1:34icjjmqJ2HPjrSuJYEkdZ+0ItmGQAQ75cRHIiftIyE= github.com/tailscale/depaware v0.0.0-20210622194025-720c4b409502/go.mod h1:p9lPsd+cx33L3H9nNoecRRxPssFKUwwI50I3pZ0yT+8= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0 h1:8pl+sMODzuvGJkmj2W4kZihvVb5mKm8pB/X44PIQHv8= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58 h1:1Bs6RVeBFtLZ8Yi1Hk07DiOqzvwLD/4hln4iahvFlag= golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= moul-http2curl-ee0b0d5/http2curl.go000066400000000000000000000034251421322546500173670ustar00rootroot00000000000000package http2curl import ( "bytes" "fmt" "io/ioutil" "net/http" "sort" "strings" ) // CurlCommand contains exec.Command compatible slice + helpers type CurlCommand []string // append appends a string to the CurlCommand func (c *CurlCommand) append(newSlice ...string) { *c = append(*c, newSlice...) } // String returns a ready to copy/paste command func (c *CurlCommand) String() string { return strings.Join(*c, " ") } func bashEscape(str string) string { return `'` + strings.Replace(str, `'`, `'\''`, -1) + `'` } // GetCurlCommand returns a CurlCommand corresponding to an http.Request func GetCurlCommand(req *http.Request) (*CurlCommand, error) { if req.URL == nil { return nil, fmt.Errorf("getCurlCommand: invalid request, req.URL is nil") } command := CurlCommand{} command.append("curl") schema := req.URL.Scheme requestURL := req.URL.String() if schema == "" { schema = "http" if req.TLS != nil { schema = "https" } requestURL = schema + "://" + req.Host + req.URL.Path } if schema == "https" { command.append("-k") } command.append("-X", bashEscape(req.Method)) if req.Body != nil { var buff bytes.Buffer _, err := buff.ReadFrom(req.Body) if err != nil { return nil, fmt.Errorf("getCurlCommand: buffer read from body error: %w", err) } // reset body for potential re-reads req.Body = ioutil.NopCloser(bytes.NewBuffer(buff.Bytes())) if len(buff.String()) > 0 { bodyEscaped := bashEscape(buff.String()) command.append("-d", bodyEscaped) } } var keys []string for k := range req.Header { keys = append(keys, k) } sort.Strings(keys) for _, k := range keys { command.append("-H", bashEscape(fmt.Sprintf("%s: %s", k, strings.Join(req.Header[k], " ")))) } command.append(bashEscape(requestURL)) return &command, nil } moul-http2curl-ee0b0d5/http2curl_test.go000066400000000000000000000126561421322546500204340ustar00rootroot00000000000000package http2curl import ( "bytes" "fmt" "io/ioutil" "net/http" "net/http/httptest" "net/url" "strconv" "strings" "testing" ) func ExampleGetCurlCommand() { form := url.Values{} form.Add("age", "10") form.Add("name", "Hudson") body := form.Encode() req, _ := http.NewRequest(http.MethodPost, "http://foo.com/cats", ioutil.NopCloser(bytes.NewBufferString(body))) req.Header.Set("API_KEY", "123") command, _ := GetCurlCommand(req) fmt.Println(command) // Output: // curl -X 'POST' -d 'age=10&name=Hudson' -H 'Api_key: 123' 'http://foo.com/cats' } func ExampleGetCurlCommand_json() { req, _ := http.NewRequest("PUT", "http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu", bytes.NewBufferString(`{"hello":"world","answer":42}`)) req.Header.Set("Content-Type", "application/json") command, _ := GetCurlCommand(req) fmt.Println(command) // Output: // curl -X 'PUT' -d '{"hello":"world","answer":42}' -H 'Content-Type: application/json' 'http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu' } func ExampleGetCurlCommand_slice() { // See https://github.com/moul/http2curl/issues/12 req, _ := http.NewRequest("PUT", "http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu", bytes.NewBufferString(`{"hello":"world","answer":42}`)) req.Header.Set("Content-Type", "application/json") command, _ := GetCurlCommand(req) fmt.Println(strings.Join(*command, " \\\n ")) // Output: // curl \ // -X \ // 'PUT' \ // -d \ // '{"hello":"world","answer":42}' \ // -H \ // 'Content-Type: application/json' \ // 'http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu' } func ExampleGetCurlCommand_noBody() { req, _ := http.NewRequest("PUT", "http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu", nil) req.Header.Set("Content-Type", "application/json") command, _ := GetCurlCommand(req) fmt.Println(command) // Output: // curl -X 'PUT' -H 'Content-Type: application/json' 'http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu' } func ExampleGetCurlCommand_emptyStringBody() { req, _ := http.NewRequest("PUT", "http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu", bytes.NewBufferString("")) req.Header.Set("Content-Type", "application/json") command, _ := GetCurlCommand(req) fmt.Println(command) // Output: // curl -X 'PUT' -H 'Content-Type: application/json' 'http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu' } func ExampleGetCurlCommand_newlineInBody() { req, _ := http.NewRequest("POST", "http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu", bytes.NewBufferString("hello\nworld")) req.Header.Set("Content-Type", "application/json") command, _ := GetCurlCommand(req) fmt.Println(command) // Output: // curl -X 'POST' -d 'hello // world' -H 'Content-Type: application/json' 'http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu' } func ExampleGetCurlCommand_specialCharsInBody() { req, _ := http.NewRequest("POST", "http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu", bytes.NewBufferString(`Hello $123 o'neill -"-`)) req.Header.Set("Content-Type", "application/json") command, _ := GetCurlCommand(req) fmt.Println(command) // Output: // curl -X 'POST' -d 'Hello $123 o'\''neill -"-' -H 'Content-Type: application/json' 'http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu' } func ExampleGetCurlCommand_other() { uri := "http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu" payload := new(bytes.Buffer) payload.Write([]byte(`{"hello":"world","answer":42}`)) req, err := http.NewRequest("PUT", uri, payload) if err != nil { panic(err) } req.Header.Set("X-Auth-Token", "private-token") req.Header.Set("Content-Type", "application/json") command, err := GetCurlCommand(req) if err != nil { panic(err) } fmt.Println(command) // Output: curl -X 'PUT' -d '{"hello":"world","answer":42}' -H 'Content-Type: application/json' -H 'X-Auth-Token: private-token' 'http://www.example.com/abc/def.ghi?jlk=mno&pqr=stu' } func ExampleGetCurlCommand_https() { uri := "https://www.example.com/abc/def.ghi?jlk=mno&pqr=stu" payload := new(bytes.Buffer) payload.Write([]byte(`{"hello":"world","answer":42}`)) req, err := http.NewRequest("PUT", uri, payload) if err != nil { panic(err) } req.Header.Set("X-Auth-Token", "private-token") req.Header.Set("Content-Type", "application/json") command, err := GetCurlCommand(req) if err != nil { panic(err) } fmt.Println(command) // Output: curl -k -X 'PUT' -d '{"hello":"world","answer":42}' -H 'Content-Type: application/json' -H 'X-Auth-Token: private-token' 'https://www.example.com/abc/def.ghi?jlk=mno&pqr=stu' } // Benchmark test for GetCurlCommand func BenchmarkGetCurlCommand(b *testing.B) { form := url.Values{} for i := 0; i <= b.N; i++ { form.Add("number", strconv.Itoa(i)) body := form.Encode() req, _ := http.NewRequest(http.MethodPost, "http://foo.com", ioutil.NopCloser(bytes.NewBufferString(body))) _, err := GetCurlCommand(req) if err != nil { panic(err) } } } func TestGetCurlCommand_serverSide(t *testing.T) { svr := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { c, err := GetCurlCommand(r) if err != nil { t.Error(err) } fmt.Fprint(w, c.String()) })) defer svr.Close() resp, err := http.Get(svr.URL) if err != nil { t.Error(err) } defer resp.Body.Close() data, err := ioutil.ReadAll(resp.Body) if err != nil { t.Error(err) } exp := fmt.Sprintf("curl -X 'GET' -H 'Accept-Encoding: gzip' -H 'User-Agent: Go-http-client/1.1' '%s/'", svr.URL) if out := string(data); out != exp { t.Errorf("act: %s, exp: %s", out, exp) } } moul-http2curl-ee0b0d5/internal/000077500000000000000000000000001421322546500167215ustar00rootroot00000000000000moul-http2curl-ee0b0d5/internal/tools/000077500000000000000000000000001421322546500200615ustar00rootroot00000000000000moul-http2curl-ee0b0d5/internal/tools/tools_test.go000066400000000000000000000001461421322546500226100ustar00rootroot00000000000000// +build tools package tools import ( _ "github.com/tailscale/depaware" // required by rules.mk ) moul-http2curl-ee0b0d5/rules.mk000066400000000000000000000237071421322546500166010ustar00rootroot00000000000000# +--------------------------------------------------------------+ # | * * * moul.io/rules.mk | # +--------------------------------------------------------------+ # | | # | ++ ______________________________________ | # | ++++ / \ | # | ++++ | | | # | ++++++++++ | https://moul.io/rules.mk is a set | | # | +++ | | of common Makefile rules that can | | # | ++ | | be configured from the Makefile | | # | + -== ==| | or with environment variables. | | # | ( <*> <*> | | | # | | | /| Manfred Touron | | # | | _) / | manfred.life | | # | | +++ / \______________________________________/ | # | \ =+ / | # | \ + | # | |\++++++ | # | | ++++ ||// | # | ___| |___ _||/__ __| # | / --- \ \| ||| __ _ ___ __ __/ /| # |/ | | \ \ / / ' \/ _ \/ // / / | # || | | | | | /_/_/_/\___/\_,_/_/ | # +--------------------------------------------------------------+ .PHONY: _default_entrypoint _default_entrypoint: help ## ## Common helpers ## rwildcard = $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d)) check-program = $(foreach exec,$(1),$(if $(shell PATH="$(PATH)" which $(exec)),,$(error "No $(exec) in PATH"))) my-filter-out = $(foreach v,$(2),$(if $(findstring $(1),$(v)),,$(v))) novendor = $(call my-filter-out,vendor/,$(1)) ## ## rules.mk ## ifneq ($(wildcard rules.mk),) .PHONY: rulesmk.bumpdeps rulesmk.bumpdeps: wget -O rules.mk https://raw.githubusercontent.com/moul/rules.mk/master/rules.mk BUMPDEPS_STEPS += rulesmk.bumpdeps endif ## ## Maintainer ## ifneq ($(wildcard .git/HEAD),) .PHONY: generate.authors generate.authors: AUTHORS AUTHORS: .git/ echo "# This file lists all individuals having contributed content to the repository." > AUTHORS echo "# For how it is generated, see 'https://github.com/moul/rules.mk'" >> AUTHORS echo >> AUTHORS git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf >> AUTHORS GENERATE_STEPS += generate.authors endif ## ## Golang ## ifndef GOPKG ifneq ($(wildcard go.mod),) GOPKG = $(shell sed '/module/!d;s/^omdule\ //' go.mod) endif endif ifdef GOPKG GO ?= go GOPATH ?= $(HOME)/go GO_INSTALL_OPTS ?= GO_TEST_OPTS ?= -test.timeout=30s GOMOD_DIRS ?= $(sort $(call novendor,$(dir $(call rwildcard,*,*/go.mod go.mod)))) GOCOVERAGE_FILE ?= ./coverage.txt GOTESTJSON_FILE ?= ./go-test.json GOBUILDLOG_FILE ?= ./go-build.log GOINSTALLLOG_FILE ?= ./go-install.log ifdef GOBINS .PHONY: go.install go.install: ifeq ($(CI),true) @rm -f /tmp/goinstall.log @set -e; for dir in $(GOBINS); do ( set -xe; \ cd $$dir; \ $(GO) install -v $(GO_INSTALL_OPTS) .; \ ); done 2>&1 | tee $(GOINSTALLLOG_FILE) else @set -e; for dir in $(GOBINS); do ( set -xe; \ cd $$dir; \ $(GO) install $(GO_INSTALL_OPTS) .; \ ); done endif INSTALL_STEPS += go.install .PHONY: go.release go.release: $(call check-program, goreleaser) goreleaser --snapshot --skip-publish --rm-dist @echo -n "Do you want to release? [y/N] " && read ans && \ if [ $${ans:-N} = y ]; then set -xe; goreleaser --rm-dist; fi RELEASE_STEPS += go.release endif .PHONY: go.unittest go.unittest: ifeq ($(CI),true) @echo "mode: atomic" > /tmp/gocoverage @rm -f $(GOTESTJSON_FILE) @set -e; for dir in $(GOMOD_DIRS); do (set -e; (set -euf pipefail; \ cd $$dir; \ (($(GO) test ./... $(GO_TEST_OPTS) -cover -coverprofile=/tmp/profile.out -covermode=atomic -race -json && touch $@.ok) | tee -a $(GOTESTJSON_FILE) 3>&1 1>&2 2>&3 | tee -a $(GOBUILDLOG_FILE); \ ); \ rm $@.ok 2>/dev/null || exit 1; \ if [ -f /tmp/profile.out ]; then \ cat /tmp/profile.out | sed "/mode: atomic/d" >> /tmp/gocoverage; \ rm -f /tmp/profile.out; \ fi)); done @mv /tmp/gocoverage $(GOCOVERAGE_FILE) else @echo "mode: atomic" > /tmp/gocoverage @set -e; for dir in $(GOMOD_DIRS); do (set -e; (set -xe; \ cd $$dir; \ $(GO) test ./... $(GO_TEST_OPTS) -cover -coverprofile=/tmp/profile.out -covermode=atomic -race); \ if [ -f /tmp/profile.out ]; then \ cat /tmp/profile.out | sed "/mode: atomic/d" >> /tmp/gocoverage; \ rm -f /tmp/profile.out; \ fi); done @mv /tmp/gocoverage $(GOCOVERAGE_FILE) endif .PHONY: go.checkdoc go.checkdoc: go doc $(first $(GOMOD_DIRS)) .PHONY: go.coverfunc go.coverfunc: go.unittest go tool cover -func=$(GOCOVERAGE_FILE) | grep -v .pb.go: | grep -v .pb.gw.go: .PHONY: go.lint go.lint: @set -e; for dir in $(GOMOD_DIRS); do ( set -xe; \ cd $$dir; \ golangci-lint run --verbose ./...; \ ); done .PHONY: go.tidy go.tidy: @# tidy dirs with go.mod files @set -e; for dir in $(GOMOD_DIRS); do ( set -xe; \ cd $$dir; \ $(GO) mod tidy; \ ); done .PHONY: go.depaware-update go.depaware-update: go.tidy @# gen depaware for bins @set -e; for dir in $(GOBINS); do ( set -xe; \ cd $$dir; \ $(GO) run github.com/tailscale/depaware --update .; \ ); done @# tidy unused depaware deps if not in a tools_test.go file @set -e; for dir in $(GOMOD_DIRS); do ( set -xe; \ cd $$dir; \ $(GO) mod tidy; \ ); done .PHONY: go.depaware-check go.depaware-check: go.tidy @# gen depaware for bins @set -e; for dir in $(GOBINS); do ( set -xe; \ cd $$dir; \ $(GO) run github.com/tailscale/depaware --check .; \ ); done .PHONY: go.build go.build: @set -e; for dir in $(GOMOD_DIRS); do ( set -xe; \ cd $$dir; \ $(GO) build ./...; \ ); done .PHONY: go.bump-deps go.bumpdeps: @set -e; for dir in $(GOMOD_DIRS); do ( set -xe; \ cd $$dir; \ $(GO) get -u ./...; \ ); done .PHONY: go.bump-deps go.fmt: @set -e; for dir in $(GOMOD_DIRS); do ( set -xe; \ cd $$dir; \ $(GO) run golang.org/x/tools/cmd/goimports -w `go list -f '{{.Dir}}' ./...` \ ); done VERIFY_STEPS += go.depaware-check BUILD_STEPS += go.build BUMPDEPS_STEPS += go.bumpdeps go.depaware-update TIDY_STEPS += go.tidy LINT_STEPS += go.lint UNITTEST_STEPS += go.unittest FMT_STEPS += go.fmt # FIXME: disabled, because currently slow # new rule that is manually run sometimes, i.e. `make pre-release` or `make maintenance`. # alternative: run it each time the go.mod is changed #GENERATE_STEPS += go.depaware-update endif ## ## Gitattributes ## ifneq ($(wildcard .gitattributes),) .PHONY: _linguist-ignored _linguist-kept: @git check-attr linguist-vendored $(shell git check-attr linguist-generated $(shell find . -type f | grep -v .git/) | grep unspecified | cut -d: -f1) | grep unspecified | cut -d: -f1 | sort .PHONY: _linguist-kept _linguist-ignored: @git check-attr linguist-vendored linguist-ignored `find . -not -path './.git/*' -type f` | grep '\ set$$' | cut -d: -f1 | sort -u endif ## ## Node ## ifndef NPM_PACKAGES ifneq ($(wildcard package.json),) NPM_PACKAGES = . endif endif ifdef NPM_PACKAGES .PHONY: npm.publish npm.publish: @echo -n "Do you want to npm publish? [y/N] " && read ans && \ @if [ $${ans:-N} = y ]; then \ set -e; for dir in $(NPM_PACKAGES); do ( set -xe; \ cd $$dir; \ npm publish --access=public; \ ); done; \ fi RELEASE_STEPS += npm.publish endif ## ## Docker ## docker_build = docker build \ --build-arg VCS_REF=`git rev-parse --short HEAD` \ --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \ --build-arg VERSION=`git describe --tags --always` \ -t "$2" -f "$1" "$(dir $1)" ifndef DOCKERFILE_PATH DOCKERFILE_PATH = ./Dockerfile endif ifndef DOCKER_IMAGE ifneq ($(wildcard Dockerfile),) DOCKER_IMAGE = $(notdir $(PWD)) endif endif ifdef DOCKER_IMAGE ifneq ($(DOCKER_IMAGE),none) .PHONY: docker.build docker.build: $(call check-program, docker) $(call docker_build,$(DOCKERFILE_PATH),$(DOCKER_IMAGE)) BUILD_STEPS += docker.build endif endif ## ## Common ## TEST_STEPS += $(UNITTEST_STEPS) TEST_STEPS += $(LINT_STEPS) TEST_STEPS += $(TIDY_STEPS) ifneq ($(strip $(TEST_STEPS)),) .PHONY: test test: $(PRE_TEST_STEPS) $(TEST_STEPS) endif ifdef INSTALL_STEPS .PHONY: install install: $(PRE_INSTALL_STEPS) $(INSTALL_STEPS) endif ifdef UNITTEST_STEPS .PHONY: unittest unittest: $(PRE_UNITTEST_STEPS) $(UNITTEST_STEPS) endif ifdef LINT_STEPS .PHONY: lint lint: $(PRE_LINT_STEPS) $(FMT_STEPS) $(LINT_STEPS) endif ifdef TIDY_STEPS .PHONY: tidy tidy: $(PRE_TIDY_STEPS) $(TIDY_STEPS) endif ifdef BUILD_STEPS .PHONY: build build: $(PRE_BUILD_STEPS) $(BUILD_STEPS) endif ifdef VERIFY_STEPS .PHONY: verify verify: $(PRE_VERIFY_STEPS) $(VERIFY_STEPS) endif ifdef RELEASE_STEPS .PHONY: release release: $(PRE_RELEASE_STEPS) $(RELEASE_STEPS) endif ifdef BUMPDEPS_STEPS .PHONY: bumpdeps bumpdeps: $(PRE_BUMDEPS_STEPS) $(BUMPDEPS_STEPS) endif ifdef FMT_STEPS .PHONY: fmt fmt: $(PRE_FMT_STEPS) $(FMT_STEPS) endif ifdef GENERATE_STEPS .PHONY: generate generate: $(PRE_GENERATE_STEPS) $(GENERATE_STEPS) endif .PHONY: help help:: @echo "General commands:" @[ "$(BUILD_STEPS)" != "" ] && echo " build" || true @[ "$(BUMPDEPS_STEPS)" != "" ] && echo " bumpdeps" || true @[ "$(FMT_STEPS)" != "" ] && echo " fmt" || true @[ "$(GENERATE_STEPS)" != "" ] && echo " generate" || true @[ "$(INSTALL_STEPS)" != "" ] && echo " install" || true @[ "$(LINT_STEPS)" != "" ] && echo " lint" || true @[ "$(RELEASE_STEPS)" != "" ] && echo " release" || true @[ "$(TEST_STEPS)" != "" ] && echo " test" || true @[ "$(TIDY_STEPS)" != "" ] && echo " tidy" || true @[ "$(UNITTEST_STEPS)" != "" ] && echo " unittest" || true @[ "$(VERIFY_STEPS)" != "" ] && echo " verify" || true @# FIXME: list other commands print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true moul-http2curl-ee0b0d5/tool/000077500000000000000000000000001421322546500160625ustar00rootroot00000000000000moul-http2curl-ee0b0d5/tool/lint/000077500000000000000000000000001421322546500170305ustar00rootroot00000000000000moul-http2curl-ee0b0d5/tool/lint/.markdownlint.json000066400000000000000000000002531421322546500225120ustar00rootroot00000000000000{ "default": true, "no-inline-html": false, "no-hard-tabs": false, "no-trailing-punctuation": false, "no-bare-urls": false, "MD013": false, "MD031": false } moul-http2curl-ee0b0d5/tool/lint/.remarkignore000066400000000000000000000000261421322546500215140ustar00rootroot00000000000000node_modules/ vendor/ moul-http2curl-ee0b0d5/tool/lint/.remarkrc000066400000000000000000000017631421322546500206460ustar00rootroot00000000000000{ "plugins": { "lint": { "blockquote-indentation": 2, "emphasis-marker": "*", "first-heading-level": false, "link-title-style": "\"", "list-item-indent": false, "list-item-spacing": false, "no-shell-dollars": false, "maximum-heading-length": false, "maximum-line-length": false, "no-duplicate-headings": false, "no-blockquote-without-caret": false, "no-file-name-irregular-characters": true, "no-file-name-outer-dashes": false, "no-heading-punctuation": false, "no-html": false, "no-multiple-toplevel-headings": false, "ordered-list-marker-style": ".", "ordered-list-marker-value": "one", "strong-marker": "*" } }, "settings": { "gfm": true, "yaml": true, "rule": "-", "ruleSpaces": false, "ruleRepetition": 70, "emphasis": "*", "listItemIndent": "1", "incrementListMarker": false, "spacedTable": false } } moul-http2curl-ee0b0d5/tool/lint/.spelling000066400000000000000000000001141421322546500206420ustar00rootroot00000000000000http2curl triangular_ruler Golang mholt http.Request Touron CONTRIBUTING.md moul-http2curl-ee0b0d5/tool/lint/Makefile000066400000000000000000000022401421322546500204660ustar00rootroot00000000000000rwildcard = $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d)) my-filter-out = $(foreach v,$(2),$(if $(findstring $(1),$(v)),,$(v))) testfiles ?= $(sort $(call my-filter-out,node_modules/,$(call rwildcard,../..,*.md))) all: test test: info offensive-wording remark markdownlint spellcheck @echo "" @echo "--- OK. ---" .PHONY: test info: deps @echo "" @echo "==> Files to check:" @echo " $(testfiles:../.%=%)" .PHONY: info offensive-wording: deps @echo "" @echo "==> Checking for inconsiderate/insensitive wording..." @node_modules/.bin/alex --diff $(testfiles) || true .PHONY: offensive-wording spellcheck: deps @echo "" @echo "==> Checking for spelling errors..." @node_modules/.bin/mdspell --report --en-us --ignore-numbers --ignore-acronyms $(testfiles) .PHONY: spellcheck remark: deps @echo "" @echo "==> Checking for messy formatting..." @node_modules/.bin/remark --frail $(testfiles) .PHONY: remark markdownlint: deps @echo "" @echo "==> Checking for good practices..." @node_modules/.bin/markdownlint $(testfiles) .PHONY: markdownlint deps: node_modules/ node_modules/: package.json npm install touch $@ .PHONY: deps moul-http2curl-ee0b0d5/tool/lint/package.json000066400000000000000000000002571421322546500213220ustar00rootroot00000000000000{ "dependencies": { "alex": "10.0.0", "markdown-spellcheck": "1.3.1", "markdownlint-cli": "0.28.1", "remark-cli": "10.0.1", "remark-lint": "9.1.1" } }