chore: Fix fmt in #321

Replace all double spaces to tabs due to Go fmt proposal.
This commit is contained in:
H1JK
2023-01-07 12:24:28 +08:00
parent cd7134e309
commit fd48c6df8a
10 changed files with 75 additions and 71 deletions

View File

@ -5,8 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/dlclark/regexp2"
"gopkg.in/yaml.v3"
"net/http"
"runtime"
"strings"
@ -19,6 +17,9 @@ import (
C "github.com/Dreamacro/clash/constant"
types "github.com/Dreamacro/clash/constant/provider"
"github.com/Dreamacro/clash/log"
"github.com/dlclark/regexp2"
"gopkg.in/yaml.v3"
)
const (
@ -141,15 +142,15 @@ func stopProxyProvider(pd *ProxySetProvider) {
_ = pd.Fetcher.Destroy()
}
func NewProxySetProvider(name string, interval time.Duration, filter string, excludeFilter string,excludeType string, vehicle types.Vehicle, hc *HealthCheck) (*ProxySetProvider, error) {
func NewProxySetProvider(name string, interval time.Duration, filter string, excludeFilter string, excludeType string, vehicle types.Vehicle, hc *HealthCheck) (*ProxySetProvider, error) {
excludeFilterReg, err := regexp2.Compile(excludeFilter, 0)
if err != nil {
return nil, fmt.Errorf("invalid excludeFilter regex: %w", err)
}
var excludeTypeArray []string
if excludeType !=""{
excludeTypeArray=strings.Split(excludeType,"|")
}
var excludeTypeArray []string
if excludeType != "" {
excludeTypeArray = strings.Split(excludeType, "|")
}
var filterRegs []*regexp2.Regexp
for _, filter := range strings.Split(filter, "`") {
@ -169,7 +170,7 @@ func NewProxySetProvider(name string, interval time.Duration, filter string, exc
healthCheck: hc,
}
fetcher := resource.NewFetcher[[]C.Proxy](name, interval, vehicle, proxiesParseAndFilter(filter, excludeFilter, excludeTypeArray,filterRegs, excludeFilterReg), proxiesOnUpdate(pd))
fetcher := resource.NewFetcher[[]C.Proxy](name, interval, vehicle, proxiesParseAndFilter(filter, excludeFilter, excludeTypeArray, filterRegs, excludeFilterReg), proxiesOnUpdate(pd))
pd.Fetcher = fetcher
pd.getSubscriptionInfo()
@ -267,7 +268,7 @@ func proxiesOnUpdate(pd *proxySetProvider) func([]C.Proxy) {
}
}
func proxiesParseAndFilter(filter string, excludeFilter string,excludeTypeArray []string, filterRegs []*regexp2.Regexp, excludeFilterReg *regexp2.Regexp) resource.Parser[[]C.Proxy] {
func proxiesParseAndFilter(filter string, excludeFilter string, excludeTypeArray []string, filterRegs []*regexp2.Regexp, excludeFilterReg *regexp2.Regexp) resource.Parser[[]C.Proxy] {
return func(buf []byte) ([]C.Proxy, error) {
schema := &ProxySchema{}
@ -287,27 +288,27 @@ func proxiesParseAndFilter(filter string, excludeFilter string,excludeTypeArray
proxiesSet := map[string]struct{}{}
for _, filterReg := range filterRegs {
for idx, mapping := range schema.Proxies {
if nil !=excludeTypeArray && len(excludeTypeArray)>0{
mType,ok:=mapping["type"]
if !ok {
continue
}
pType,ok:=mType.(string)
if !ok {
continue
}
flag:=false
for i := range excludeTypeArray {
if(strings.EqualFold(pType,excludeTypeArray[i])){
flag=true
}
if nil != excludeTypeArray && len(excludeTypeArray) > 0 {
mType, ok := mapping["type"]
if !ok {
continue
}
pType, ok := mType.(string)
if !ok {
continue
}
flag := false
for i := range excludeTypeArray {
if strings.EqualFold(pType, excludeTypeArray[i]) {
flag = true
}
}
if(flag){
continue
}
}
if flag {
continue
}
}
}
mName, ok := mapping["name"]
if !ok {
continue