print head

This commit is contained in:
xing 2023-08-26 21:29:55 +08:00
parent cd5a12c9fd
commit b8112bb970
21 changed files with 159 additions and 47 deletions

View File

@ -183,6 +183,14 @@ func MapBy[K comparable, T any](fn func(*safety.Map[K, T])) *safety.Map[K, T] {
return m
}
func SafeMap[K comparable, T any]() *safety.Map[K, T] {
m := safety.NewMap[K, T]()
calls = append(calls, func() {
m.Flush()
})
return m
}
func Push(fn ...func()) {
calls = append(calls, fn...)
}

View File

@ -4,7 +4,7 @@ import (
"crypto/tls"
"fmt"
"github.com/fthvgb1/wp-go/app/pkg/config"
"github.com/soxfmr/gomail"
"gopkg.in/gomail.v2"
"mime"
"path"
)

View File

@ -7,7 +7,7 @@ import (
)
func HiddenLogin(h *wp.Handle) {
h.PushComponentFilterFn(widgets.Meta, func(h *wp.Handle, s string, args ...any) string {
h.AddActionFilter(widgets.Meta, func(h *wp.Handle, s string, args ...any) string {
return str.Replace(s, map[string]string{
`<li><a href="/wp-login.php">登录</a></li>`: "",
`<li><a href="/feed">登录</a></li>`: "",

View File

@ -18,7 +18,7 @@ func Hook(h *wp.Handle) {
}
func configs(h *wp.Handle) {
h.PushComponentFilterFn(widgets.Search, func(h *wp.Handle, s string, args ...any) string {
h.AddActionFilter(widgets.Search, func(h *wp.Handle, s string, args ...any) string {
return strings.ReplaceAll(s, `class="search-submit"`, `class="search-submit screen-reader-text"`)
})
wp.InitPipe(h)

View File

@ -38,7 +38,7 @@ func configs(h *wp.Handle) {
wp.InitPipe(h)
h.PushHandler(constraints.PipeMiddleware, constraints.Home,
wp.NewHandleFn(widget.CheckCategory, 100.006, "widget.CheckCategory"))
h.PushComponentFilterFn("bodyClass", calClass)
h.AddActionFilter("bodyClass", calClass)
h.PushCacheGroupHeadScript(constraints.AllScene, "colorScheme-customHeader", 10, colorScheme, customHeader)
components.WidgetArea(h)
pushScripts(h)
@ -176,7 +176,7 @@ func calClass(h *wp.Handle, s string, _ ...any) string {
}
func videoHeader(h *wp.Handle) {
h.PushComponentFilterFn("videoSetting", videoPlay)
h.AddActionFilter("videoSetting", videoPlay)
wp.CustomVideo(h, constraints.Home)
}

View File

@ -77,7 +77,7 @@ func (h *Handle) BodyClass() string {
if h.themeMods.ThemeSupport.ResponsiveEmbeds {
class = append(class, "wp-embed-responsive")
}
return h.ComponentFilterFnHook("bodyClass", strings.Join(class, " "))
return h.DoActionFilter("bodyClass", strings.Join(class, " "))
}
func postClass(h *Handle) func(posts models.Posts) string {
@ -113,7 +113,7 @@ func (h *Handle) PostClass(posts models.Posts) string {
class = append(class, TermClass(term))
}
return h.ComponentFilterFnHook("postClass", strings.Join(class, " "))
return h.DoActionFilter("postClass", strings.Join(class, " "))
}
func TermClass(term models.TermsMy) string {

View File

@ -199,10 +199,10 @@ func (h *Handle) ComponentFilterFn(name string) ([]func(*Handle, string, ...any)
return fn, ok
}
func (h *Handle) PushComponentFilterFn(name string, fns ...func(*Handle, string, ...any) string) {
func (h *Handle) AddActionFilter(name string, fns ...func(*Handle, string, ...any) string) {
h.componentFilterFn[name] = append(h.componentFilterFn[name], fns...)
}
func (h *Handle) ComponentFilterFnHook(name, s string, args ...any) string {
func (h *Handle) DoActionFilter(name, s string, args ...any) string {
calls, ok := h.componentFilterFn[name]
if ok {
return slice.Reduce(calls, func(fn func(*Handle, string, ...any) string, r string) string {

View File

@ -62,7 +62,7 @@ func Archive(h *wp.Handle, id string) string {
} else {
s = strings.ReplaceAll(s, "{$html}", archiveUl(h, conf, args, cache.Archives(h.C)))
}
return h.ComponentFilterFnHook(widgets.Archive, str.Replace(s, args))
return h.DoActionFilter(widgets.Archive, str.Replace(s, args))
}
var dropdownScript = `

View File

@ -69,7 +69,7 @@ func Category(h *wp.Handle, id string) string {
} else {
t = strings.ReplaceAll(t, "{$html}", categoryUL(h, args, conf, categories))
}
return h.ComponentFilterFnHook(widgets.Categories, str.Replace(t, args))
return h.DoActionFilter(widgets.Categories, str.Replace(t, args))
}
func CategoryLi(h *wp.Handle, conf map[any]any, categories []models.TermsMy) string {
@ -232,7 +232,7 @@ func DropdownCategories(h *wp.Handle, args map[string]string, conf map[any]any,
})
}
s.WriteString(" </select>\n")
return h.ComponentFilterFnHook("wp_dropdown_cats", s.String())
return h.DoActionFilter("wp_dropdown_cats", s.String())
}
func CheckCategory(h *wp.Handle) {
@ -292,8 +292,3 @@ func IsCategory(h *wp.Handle) (category models.TermsMy, r bool) {
category = cc
return
}
func IsTag(h *wp.Handle) (models.TermsMy, bool) {
//todo
return models.TermsMy{}, false
}

View File

@ -57,5 +57,5 @@ func Meta(h *wp.Handle, id string) string {
ss.Sprintf(`<li><a href="%s">条目feed</a></li>`, "/feed")
ss.Sprintf(`<li><a href="%s">评论feed</a></li>`, "/comments/feed")
s := strings.ReplaceAll(metaTemplate, "{$li}", ss.String())
return h.ComponentFilterFnHook(widgets.Meta, str.Replace(s, args))
return h.DoActionFilter(widgets.Meta, str.Replace(s, args))
}

View File

@ -64,5 +64,5 @@ func RecentComments(h *wp.Handle, id string) string {
</li>`, t.CommentAuthor, t.CommentPostId, t.CommentId, t.PostTitle)
})
s := strings.ReplaceAll(recentCommentsTemplate, "{$li}", strings.Join(comments, "\n"))
return h.ComponentFilterFnHook(widgets.RecentComments, str.Replace(s, args))
return h.DoActionFilter(widgets.RecentComments, str.Replace(s, args))
}

View File

@ -85,5 +85,5 @@ func RecentPosts(h *wp.Handle, id string) string {
</li>`, t.Id, ariaCurrent, t.PostTitle, date)
})
s := strings.ReplaceAll(recentPostsTemplate, "{$li}", strings.Join(posts, "\n"))
return h.ComponentFilterFnHook(widgets.RecentPosts, str.Replace(s, args))
return h.DoActionFilter(widgets.RecentPosts, str.Replace(s, args))
}

View File

@ -77,5 +77,5 @@ func Search(h *wp.Handle, id string) string {
val = html.SpecialChars(h.Index.Param.Search)
}
s = strings.ReplaceAll(s, "{$value}", val)
return h.ComponentFilterFnHook(widgets.Search, str.Replace(s, args))
return h.DoActionFilter(widgets.Search, str.Replace(s, args))
}

View File

@ -0,0 +1,23 @@
package widget
import (
"github.com/fthvgb1/wp-go/app/pkg/cache"
"github.com/fthvgb1/wp-go/app/pkg/constraints"
"github.com/fthvgb1/wp-go/app/pkg/models"
"github.com/fthvgb1/wp-go/app/theme/wp"
"github.com/fthvgb1/wp-go/helper/slice"
str "github.com/fthvgb1/wp-go/helper/strings"
)
func IsTag(h *wp.Handle) (models.TermsMy, bool) {
if h.Scene() == constraints.Tag {
id := str.ToInt[uint64](h.C.Query("tag"))
i, t := slice.SearchFirst(cache.CategoriesTags(h.C, constraints.Tag), func(my models.TermsMy) bool {
return id == my.Terms.TermId
})
if i > 0 {
return t, true
}
}
return models.TermsMy{}, false
}

View File

@ -85,7 +85,7 @@ func GetVideoSetting(h *Handle, u string) (string, error) {
if is := videoReg.FindString(u); is != "" {
v.MimeType = "video/x-youtube"
}
_ = h.ComponentFilterFnHook("videoSetting", "", &v)
_ = h.DoActionFilter("videoSetting", "", &v)
s, err := json.Marshal(v)
if err != nil {
return "", err

View File

@ -100,7 +100,7 @@ func BuildPipe(pipeScene string, keyFn func(*Handle, string) string, fn func(*Ha
func PipeKey(h *Handle, pipScene string) string {
key := str.Join("pipekey", "-", pipScene, "-", h.scene, "-", h.Stats)
return h.ComponentFilterFnHook("pipeKey", key, pipScene)
return h.DoActionFilter("pipeKey", key, pipScene)
}
func Run(h *Handle, conf func(*Handle)) {
@ -133,7 +133,7 @@ func Run(h *Handle, conf func(*Handle)) {
}
func MiddlewareKey(h *Handle, pipScene string) string {
return h.ComponentFilterFnHook("middleware", "middleware", pipScene)
return h.DoActionFilter("middleware", "middleware", pipScene)
}
func PipeMiddlewareHandle(h *Handle, middlewares map[string][]HandleCall, key string) (handlers []HandleCall) {

View File

@ -5,9 +5,13 @@ import (
"fmt"
"github.com/fthvgb1/wp-go/app/cmd/reload"
"github.com/fthvgb1/wp-go/app/pkg/config"
"github.com/fthvgb1/wp-go/app/pkg/constraints"
"github.com/fthvgb1/wp-go/app/pkg/logs"
"github.com/fthvgb1/wp-go/app/theme/wp"
"github.com/fthvgb1/wp-go/app/theme/wp/components/widget"
"github.com/fthvgb1/wp-go/app/wpconfig"
"github.com/fthvgb1/wp-go/helper"
"github.com/fthvgb1/wp-go/helper/number"
"github.com/fthvgb1/wp-go/helper/slice"
str "github.com/fthvgb1/wp-go/helper/strings"
"os"
@ -142,5 +146,73 @@ func restGetQueriedResourceRoute(h *wp.Handle) string {
if cate, ok := widget.IsCategory(h); ok {
return fmt.Sprintf("/wp/v2/categories/%d", cate.Terms.TermId)
}
if tag, ok := widget.IsTag(h); ok {
return fmt.Sprintf("/wp/v2/tags/%d", tag.Terms.TermId)
}
return ""
}
func RsdLink(h *wp.Handle) {
PrintHead(h, fmt.Sprintf("<link rel=\"EditURI\" type=\"application/rsd+xml\" title=\"RSD\" href=\"%s\" />\n", "xmlrpc.php?rsd"))
}
func WlwmanifestLink(h *wp.Handle) {
PrintHead(h, fmt.Sprintf("<link rel=\"wlwmanifest\" type=\"application/wlwmanifest+xml\" href=\"%s\" />\n", "/wp-includes/wlwmanifest.xml"))
}
func LocaleStylesheet(h *wp.Handle) {
uri := reload.GetAnyValBys("printHead-localStylesheet", h, func(a *wp.Handle) string {
ur := str.Join("wp-content/themes", h.Theme(), str.Join(wpconfig.GetLang(), ".css"))
path := filepath.Join(config.GetConfig().WpDir, ur)
if helper.FileExist(path) {
return str.Join("/", ur)
}
return ""
})
if uri != "" {
PrintHead(h, fmt.Sprintf("<link rel=\"stylesheet\" href=\"%s\"%s media=\"screen\" />", uri, ""))
}
}
func TheGenerator(h *wp.Handle) {
PrintHead(h, fmt.Sprintf(`<meta name="generator" content="WordPress %s"/>`, "6.2.2"))
}
func ShortLinkWpHead(h *wp.Handle) {
if h.Scene() != constraints.Detail || h.Detail.Post.Id < 1 {
return
}
shortlink := ""
post := h.Detail.Post
if post.PostType == "page" && wpconfig.GetOption("page_on_front") == number.IntToString(post.Id) &&
wpconfig.GetOption("show_on_front") == "page" {
shortlink = "/"
} else {
shortlink = str.Join("/p/", number.IntToString(post.Id))
}
if shortlink != "" {
PrintHead(h, fmt.Sprintf(`<link rel='shortlink' href="%s" />`, shortlink))
}
}
func customLogoHeaderStyles(h *wp.Handle) {
mod := h.CommonThemeMods()
if !mod.ThemeSupport.CustomHeader.HeaderText && mod.ThemeSupport.CustomLogo.HeaderText != "" {
class := mod.ThemeSupport.CustomLogo.HeaderText
attr := ""
if !slice.IsContained(mod.ThemeSupport.HTML5, "style") {
attr = ` type="text/css"`
}
PrintHead(h, fmt.Sprintf(`<style id="custom-logo-css"%s>
.%s {
position: absolute;
clip: rect(1px, 1px, 1px, 1px);
}
</style>`, attr, class))
}
}
func PrintHeadToStr(h *wp.Handle) string {
h.DoActionFilter("wp_head", "", h)
return wp.GetComponentsArgs(h, "wp_head", str.NewBuilder()).String()
}

View File

@ -1,6 +1,7 @@
package wp
import (
"errors"
"github.com/fthvgb1/wp-go/app/cmd/reload"
"github.com/fthvgb1/wp-go/app/pkg/config"
"github.com/fthvgb1/wp-go/app/pkg/constraints"
@ -42,6 +43,10 @@ type Handle struct {
template *template.Template
}
func (h *Handle) Theme() string {
return h.theme
}
func (h *Handle) GinH() gin.H {
return h.ginH
}
@ -153,7 +158,7 @@ func (h *Handle) Err() error {
}
func (h *Handle) SetErr(err error) {
h.err = err
h.err = errors.Join(err)
}
func (h *Handle) SetTempl(templ string) {

15
go.mod
View File

@ -11,19 +11,18 @@ require (
github.com/gin-gonic/gin v1.9.1
github.com/go-playground/locales v0.14.1
github.com/go-playground/universal-translator v0.18.1
github.com/go-playground/validator/v10 v10.14.1
github.com/go-playground/validator/v10 v10.15.1
github.com/go-sql-driver/mysql v1.7.1
github.com/goccy/go-json v0.10.2
github.com/jmoiron/sqlx v1.3.5
github.com/soxfmr/gomail v0.0.0-20200806033254-80bf84e583f0
golang.org/x/crypto v0.11.0
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b
golang.org/x/crypto v0.12.0
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
gopkg.in/yaml.v2 v2.4.0
)
require (
github.com/bytedance/sonic v1.10.0-rc3 // indirect
github.com/bytedance/sonic v1.10.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
@ -41,9 +40,9 @@ require (
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
golang.org/x/arch v0.4.0 // indirect
golang.org/x/net v0.13.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect

32
go.sum
View File

@ -2,6 +2,8 @@ github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
github.com/bytedance/sonic v1.10.0-rc3 h1:uNSnscRapXTwUgTyOF0GVljYD08p9X/Lbr9MweSV3V0=
github.com/bytedance/sonic v1.10.0-rc3/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
github.com/bytedance/sonic v1.10.0 h1:qtNZduETEIWJVIyDl01BeNxur2rW9OwTQ/yBqFRkKEk=
github.com/bytedance/sonic v1.10.0/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0=
@ -38,8 +40,10 @@ github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
github.com/go-playground/validator/v10 v10.14.1 h1:9c50NUPC30zyuKprjL3vNZ0m5oG+jU0zvx4AqHGnv4k=
github.com/go-playground/validator/v10 v10.14.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-playground/validator/v10 v10.15.0 h1:nDU5XeOKtB3GEa+uB7GNYwhVKsgjAR7VgKoNB6ryXfw=
github.com/go-playground/validator/v10 v10.15.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-playground/validator/v10 v10.15.1 h1:BSe8uhN+xQ4r5guV/ywQI4gO59C2raYcGffYWZEjZzM=
github.com/go-playground/validator/v10 v10.15.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
@ -96,8 +100,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/soxfmr/gomail v0.0.0-20200806033254-80bf84e583f0 h1:eVzIpz9oWTxss+/w5zHkUvCKNCt+1djBoTVlm2lgGQA=
github.com/soxfmr/gomail v0.0.0-20200806033254-80bf84e583f0/go.mod h1:FInbtXuM/O1SXBIDwtDMgV8JDa4fHNoZ4QjItNNwA5g=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
@ -120,26 +122,28 @@ golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUu
golang.org/x/arch v0.4.0 h1:A8WCeEWhLwPBKNbFi5Wv5UTCBx5zzubnXDlMOFAzFMc=
golang.org/x/arch v0.4.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA=
golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio=
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b h1:r+vk0EmXNmekl0S0BascoeeoHk/L7wmaW2QF90K+kYI=
golang.org/x/exp v0.0.0-20230801115018-d63ba01acd4b/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/exp v0.0.0-20230807204917-050eac23e9de h1:l5Za6utMv/HsBWWqzt4S8X17j+kt1uVETUX5UFhn2rE=
golang.org/x/exp v0.0.0-20230807204917-050eac23e9de/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.13.0 h1:Nvo8UFsZ8X3BhAC9699Z1j7XQ3rsZnUUm7jfBEk1ueY=
golang.org/x/net v0.13.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA=
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4=
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=

View File

@ -5,6 +5,7 @@ import (
"fmt"
str "github.com/fthvgb1/wp-go/helper/strings"
"net/url"
"os"
"reflect"
"strconv"
"strings"
@ -120,3 +121,8 @@ func IsImplements[T, A any](i A) (T, bool) {
t, ok := a.(T)
return t, ok
}
func FileExist(path string) bool {
_, err := os.Stat(path)
return err == nil
}