mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 10:25:52 +02:00
style: format go code with tab indent #605
This commit is contained in:
parent
96cff98c66
commit
598d91a417
15 changed files with 244 additions and 251 deletions
|
@ -3,7 +3,7 @@ package nginx
|
|||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"github.com/tufanbarisyildirim/gonginx"
|
||||
"github.com/tufanbarisyildirim/gonginx/dumper"
|
||||
"github.com/tufanbarisyildirim/gonginx/parser"
|
||||
"strings"
|
||||
)
|
||||
|
@ -83,11 +83,11 @@ func (c *NgxConfig) BuildConfig() (content string, err error) {
|
|||
content += fmt.Sprintf("%sserver {\n%s}\n\n", comments, server)
|
||||
}
|
||||
p := parser.NewStringParser(content, parser.WithSkipValidDirectivesErr())
|
||||
config, err := p.Parse()
|
||||
cfg, err := p.Parse()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
content = gonginx.DumpConfig(config, gonginx.IndentedStyle)
|
||||
content = dumper.DumpConfig(cfg, dumper.IndentedStyle)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package nginx
|
||||
|
||||
import (
|
||||
"github.com/tufanbarisyildirim/gonginx"
|
||||
"github.com/tufanbarisyildirim/gonginx/dumper"
|
||||
"github.com/tufanbarisyildirim/gonginx/parser"
|
||||
)
|
||||
|
||||
func (c *NgxConfig) FmtCode() (fmtContent string) {
|
||||
fmtContent = gonginx.DumpConfig(c.c, gonginx.IndentedStyle)
|
||||
fmtContent = dumper.DumpConfig(c.c, dumper.IndentedStyle)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -16,6 +16,6 @@ func FmtCode(content string) (fmtContent string, err error) {
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
fmtContent = gonginx.DumpConfig(c, gonginx.IndentedStyle)
|
||||
fmtContent = dumper.DumpConfig(c, dumper.IndentedStyle)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package nginx
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/tufanbarisyildirim/gonginx"
|
||||
"github.com/tufanbarisyildirim/gonginx/config"
|
||||
"github.com/tufanbarisyildirim/gonginx/parser"
|
||||
"strings"
|
||||
"testing"
|
||||
|
@ -32,7 +32,7 @@ func TestNgxConfParse(t *testing.T) {
|
|||
fmt.Println(c)
|
||||
}
|
||||
|
||||
func fn(block gonginx.IBlock, deep int) {
|
||||
func fn(block config.IBlock, deep int) {
|
||||
if block == nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package nginx
|
|||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/tufanbarisyildirim/gonginx"
|
||||
"github.com/tufanbarisyildirim/gonginx/config"
|
||||
"github.com/tufanbarisyildirim/gonginx/parser"
|
||||
"strings"
|
||||
)
|
||||
|
@ -13,11 +13,11 @@ const (
|
|||
Upstream = "upstream"
|
||||
)
|
||||
|
||||
func (s *NgxServer) ParseServer(directive gonginx.IDirective) {
|
||||
func (s *NgxServer) ParseServer(directive config.IDirective) {
|
||||
s.parseServer(directive)
|
||||
}
|
||||
|
||||
func (s *NgxServer) parseServer(directive gonginx.IDirective) {
|
||||
func (s *NgxServer) parseServer(directive config.IDirective) {
|
||||
if directive.GetBlock() == nil {
|
||||
return
|
||||
}
|
||||
|
@ -40,10 +40,10 @@ func (s *NgxServer) parseServer(directive gonginx.IDirective) {
|
|||
}
|
||||
}
|
||||
}
|
||||
func (l *NgxLocation) ParseLocation(directive gonginx.IDirective, deep int) {
|
||||
func (l *NgxLocation) ParseLocation(directive config.IDirective, deep int) {
|
||||
l.parseLocation(directive, deep)
|
||||
}
|
||||
func (l *NgxLocation) parseLocation(directive gonginx.IDirective, deep int) {
|
||||
func (l *NgxLocation) parseLocation(directive config.IDirective, deep int) {
|
||||
if directive.GetBlock() == nil {
|
||||
return
|
||||
}
|
||||
|
@ -64,11 +64,11 @@ func (l *NgxLocation) parseLocation(directive gonginx.IDirective, deep int) {
|
|||
}
|
||||
}
|
||||
|
||||
func (d *NgxDirective) ParseDirective(directive gonginx.IDirective, deep int) {
|
||||
func (d *NgxDirective) ParseDirective(directive config.IDirective, deep int) {
|
||||
d.parseDirective(directive, deep)
|
||||
}
|
||||
|
||||
func (d *NgxDirective) parseDirective(directive gonginx.IDirective, deep int) {
|
||||
func (d *NgxDirective) parseDirective(directive config.IDirective, deep int) {
|
||||
if directive.GetBlock() != nil {
|
||||
d.Params += directive.GetName() + " "
|
||||
d.Directive = ""
|
||||
|
@ -97,7 +97,7 @@ func (d *NgxDirective) parseDirective(directive gonginx.IDirective, deep int) {
|
|||
}
|
||||
}
|
||||
|
||||
func (u *NgxUpstream) parseUpstream(directive gonginx.IDirective) {
|
||||
func (u *NgxUpstream) parseUpstream(directive config.IDirective) {
|
||||
if directive.GetBlock() == nil {
|
||||
return
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ func (u *NgxUpstream) parseUpstream(directive gonginx.IDirective) {
|
|||
}
|
||||
}
|
||||
|
||||
func (c *NgxConfig) parseCustom(directive gonginx.IDirective) {
|
||||
func (c *NgxConfig) parseCustom(directive config.IDirective) {
|
||||
if directive.GetBlock() == nil {
|
||||
return
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ func buildComment(c []string) string {
|
|||
return strings.ReplaceAll(strings.Join(c, "\n"), "#", "")
|
||||
}
|
||||
|
||||
func parse(block gonginx.IBlock, ngxConfig *NgxConfig) (err error) {
|
||||
func parse(block config.IBlock, ngxConfig *NgxConfig) (err error) {
|
||||
if block == nil {
|
||||
err = errors.New("block is nil")
|
||||
return
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package nginx
|
||||
|
||||
import (
|
||||
"github.com/tufanbarisyildirim/gonginx"
|
||||
"github.com/tufanbarisyildirim/gonginx/config"
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
|
@ -12,7 +12,7 @@ type NgxConfig struct {
|
|||
Upstreams []*NgxUpstream `json:"upstreams"`
|
||||
Servers []*NgxServer `json:"servers"`
|
||||
Custom string `json:"custom"`
|
||||
c *gonginx.Config
|
||||
c *config.Config
|
||||
}
|
||||
|
||||
type NgxServer struct {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue