1 Star 2 Fork 3

yongfu / nginxConfigFormatterGo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
BSD-3-Clause-Clear

nginxConfigFormatterGo

使用go语言开发的, 优雅的nginx配置文件格式化工具

https://github.com/1connect/nginx-config-formatter.git 项目激发和鼓励
之前也有给该项目提交过补丁, 还是决定用go重新造一遍轮子.

项目目标和特性

  • 可预测的格式化结果.
  • 所有的注释都独立一行(现在支持可保留原来与配置在同一行的注视选项,-l)#I73E04
  • 连续的多个空行合并为一个空行.
  • 花括号使用Java的习惯.
  • 所有的行使用统一的方式进行缩进, 缩进的空格数由用户指定 (默认 4 个空格).
  • 多余的空白字符合并为一个空格, 但是在注释和引号中的空白字符不进行任何处理.

编译要求

go 1.20

安装

1. go get 方式

go get gitee.com/RickieL/nginxConfigFormatterGo

# 可能会被安装在如下目录
$HOME/go/bin/nginxConfigFormatterGo

2. go build 方式

git clone https://gitee.com/RickieL/nginxConfigFormatterGo.git
cd nginxConfigFormatterGo
go build

3. 预编译好的二进制包

你可以在 发布页面 获取预编译的二进制包.

# linux
wget https://gitee.com/RickieL/nginxConfigFormatterGo/releases/download/v1.0.0/nginxConfigFormatterGo_linux_amd64 -O /usr/local/bin/nginxConfigFormatterGo

chmod +x /usr/local/bin/nginxConfigFormatterGo

# mac  
wget https://gitee.com/RickieL/nginxConfigFormatterGo/releases/download/v1.0.0/nginxConfigFormatterGo_darwin_amd64  -O /usr/local/bin/nginxConfigFormatterGo

chmod +x /usr/local/bin/nginxConfigFormatterGo

使用方法

NAME:
   nginxConfigFormatterGo - nginx 格式化工具

USAGE:
   ./nginxConfigFormatterGo [-s 2] [-c utf-8] [-b] [-v] [-t] <filelists>

DESCRIPTION:
   nginx 格式化工具

AUTHOR:
   github.com/rwx------

COMMANDS:
   help, h  显示命令列表或单个命令的帮助

GLOBAL OPTIONS:
   --charset value, -c value  当前支持的字符集: gbk, gb18030, windows-1252, utf-8 (默认: "utf-8")
   --space value, -s value    缩进的空格数 (默认: 4)
   --backup, -b               备份原始的配置文件
   --verbose, -v              冗长模式
   --testing, -t              只进行测试, 不真正执行
   --help, -h                 显示本页的帮助信息
The Clear BSD License Copyright (c) 2023, yongfu All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

nginx 配置文件 格式化工具 展开 收起
Go
BSD-3-Clause-Clear
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Go
1
https://gitee.com/RickieL/nginxConfigFormatterGo.git
git@gitee.com:RickieL/nginxConfigFormatterGo.git
RickieL
nginxConfigFormatterGo
nginxConfigFormatterGo
master

搜索帮助