1
0
mirror of https://github.com/nitezs/sub2clash.git synced 2024-12-23 15:24:42 -05:00

🎨 Refactor package for public import

This commit is contained in:
Nite07 2024-09-17 13:10:13 +08:00
parent 3cfa4bdf24
commit e504a6cca4
21 changed files with 67 additions and 49 deletions

View File

@ -2,9 +2,10 @@ package handler
import ( import (
"net/http" "net/http"
"sub2clash/config"
"sub2clash/model" "github.com/nitezs/sub2clash/config"
"sub2clash/validator" "github.com/nitezs/sub2clash/model"
"github.com/nitezs/sub2clash/validator"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"

View File

@ -9,11 +9,12 @@ import (
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
"sub2clash/common"
"sub2clash/logger" "github.com/nitezs/sub2clash/common"
"sub2clash/model" "github.com/nitezs/sub2clash/logger"
"sub2clash/parser" "github.com/nitezs/sub2clash/model"
"sub2clash/validator" "github.com/nitezs/sub2clash/parser"
"github.com/nitezs/sub2clash/validator"
"go.uber.org/zap" "go.uber.org/zap"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"

View File

@ -3,9 +3,10 @@ package handler
import ( import (
_ "embed" _ "embed"
"net/http" "net/http"
"sub2clash/config"
"sub2clash/model" "github.com/nitezs/sub2clash/config"
"sub2clash/validator" "github.com/nitezs/sub2clash/model"
"github.com/nitezs/sub2clash/validator"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"

View File

@ -7,11 +7,11 @@ import (
"strings" "strings"
"time" "time"
"sub2clash/common" "github.com/nitezs/sub2clash/common"
"sub2clash/common/database" "github.com/nitezs/sub2clash/common/database"
"sub2clash/config" "github.com/nitezs/sub2clash/config"
"sub2clash/model" "github.com/nitezs/sub2clash/model"
"sub2clash/validator" "github.com/nitezs/sub2clash/validator"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -5,9 +5,10 @@ import (
"html/template" "html/template"
"log" "log"
"net/http" "net/http"
"sub2clash/api/handler"
"sub2clash/constant" "github.com/nitezs/sub2clash/api/handler"
"sub2clash/middleware" "github.com/nitezs/sub2clash/constant"
"github.com/nitezs/sub2clash/middleware"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )

View File

@ -5,7 +5,7 @@ import (
"errors" "errors"
"path/filepath" "path/filepath"
"sub2clash/model" "github.com/nitezs/sub2clash/model"
"go.etcd.io/bbolt" "go.etcd.io/bbolt"
) )

View File

@ -3,8 +3,9 @@ package common
import ( import (
"errors" "errors"
"net/http" "net/http"
"sub2clash/config"
"time" "time"
"github.com/nitezs/sub2clash/config"
) )
type GetConfig struct { type GetConfig struct {

View File

@ -2,10 +2,11 @@ package common
import ( import (
"strings" "strings"
"sub2clash/constant"
"sub2clash/logger" "github.com/nitezs/sub2clash/constant"
"sub2clash/model" "github.com/nitezs/sub2clash/logger"
"sub2clash/parser" "github.com/nitezs/sub2clash/model"
"github.com/nitezs/sub2clash/parser"
"go.uber.org/zap" "go.uber.org/zap"
) )

View File

@ -3,7 +3,8 @@ package common
import ( import (
"fmt" "fmt"
"strings" "strings"
"sub2clash/model"
"github.com/nitezs/sub2clash/model"
) )
func PrependRuleProvider( func PrependRuleProvider(

View File

@ -8,9 +8,10 @@ import (
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
"sub2clash/config"
"sync" "sync"
"time" "time"
"github.com/nitezs/sub2clash/config"
) )
var subsDir = "subs" var subsDir = "subs"

View File

@ -3,7 +3,8 @@ package common
import ( import (
"os" "os"
"path/filepath" "path/filepath"
"sub2clash/config"
"github.com/nitezs/sub2clash/config"
) )
func writeTemplate(path string, template string) error { func writeTemplate(path string, template string) error {

2
go.mod
View File

@ -1,4 +1,4 @@
module sub2clash module github.com/nitezs/sub2clash
go 1.21 go 1.21

11
main.go
View File

@ -4,11 +4,12 @@ import (
_ "embed" _ "embed"
"io" "io"
"strconv" "strconv"
"sub2clash/api"
"sub2clash/common" "github.com/nitezs/sub2clash/api"
"sub2clash/common/database" "github.com/nitezs/sub2clash/common"
"sub2clash/config" "github.com/nitezs/sub2clash/common/database"
"sub2clash/logger" "github.com/nitezs/sub2clash/config"
"github.com/nitezs/sub2clash/logger"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"go.uber.org/zap" "go.uber.org/zap"

View File

@ -2,9 +2,10 @@ package middleware
import ( import (
"strconv" "strconv"
"sub2clash/logger"
"time" "time"
"github.com/nitezs/sub2clash/logger"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"go.uber.org/zap" "go.uber.org/zap"
) )

View File

@ -5,8 +5,9 @@ import (
"net/url" "net/url"
"strconv" "strconv"
"strings" "strings"
"sub2clash/constant"
"sub2clash/model" "github.com/nitezs/sub2clash/constant"
"github.com/nitezs/sub2clash/model"
) )
func ParseHysteria(proxy string) (model.Proxy, error) { func ParseHysteria(proxy string) (model.Proxy, error) {

View File

@ -4,8 +4,9 @@ import (
"fmt" "fmt"
"net/url" "net/url"
"strings" "strings"
"sub2clash/constant"
"sub2clash/model" "github.com/nitezs/sub2clash/constant"
"github.com/nitezs/sub2clash/model"
) )
func ParseHysteria2(proxy string) (model.Proxy, error) { func ParseHysteria2(proxy string) (model.Proxy, error) {

View File

@ -4,8 +4,9 @@ import (
"fmt" "fmt"
"net/url" "net/url"
"strings" "strings"
"sub2clash/constant"
"sub2clash/model" "github.com/nitezs/sub2clash/constant"
"github.com/nitezs/sub2clash/model"
) )
func ParseShadowsocks(proxy string) (model.Proxy, error) { func ParseShadowsocks(proxy string) (model.Proxy, error) {

View File

@ -4,8 +4,9 @@ import (
"net/url" "net/url"
"strconv" "strconv"
"strings" "strings"
"sub2clash/constant"
"sub2clash/model" "github.com/nitezs/sub2clash/constant"
"github.com/nitezs/sub2clash/model"
) )
func ParseShadowsocksR(proxy string) (model.Proxy, error) { func ParseShadowsocksR(proxy string) (model.Proxy, error) {

View File

@ -4,8 +4,9 @@ import (
"fmt" "fmt"
"net/url" "net/url"
"strings" "strings"
"sub2clash/constant"
"sub2clash/model" "github.com/nitezs/sub2clash/constant"
"github.com/nitezs/sub2clash/model"
) )
func ParseTrojan(proxy string) (model.Proxy, error) { func ParseTrojan(proxy string) (model.Proxy, error) {

View File

@ -4,8 +4,9 @@ import (
"fmt" "fmt"
"net/url" "net/url"
"strings" "strings"
"sub2clash/constant"
"sub2clash/model" "github.com/nitezs/sub2clash/constant"
"github.com/nitezs/sub2clash/model"
) )
func ParseVless(proxy string) (model.Proxy, error) { func ParseVless(proxy string) (model.Proxy, error) {

View File

@ -5,8 +5,9 @@ import (
"net/url" "net/url"
"strconv" "strconv"
"strings" "strings"
"sub2clash/constant"
"sub2clash/model" "github.com/nitezs/sub2clash/constant"
"github.com/nitezs/sub2clash/model"
) )
func ParseVmess(proxy string) (model.Proxy, error) { func ParseVmess(proxy string) (model.Proxy, error) {