Skip to content

Commit

Permalink
chore: go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
caixw committed Sep 6, 2021
1 parent eff96a5 commit a765a4e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
7 changes: 4 additions & 3 deletions builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ import (

// ErrBuilding 另一个 Rebuild 正在执行
//
// 当多次快速调用 Builder.Rebuild 时,可能返回此值,
// 表示另一个调用还未返回,新的调用又开始。
// 当多次快速调用 Builder.Rebuild 时,可能返回此值, 表示另一个调用还未返回,新的调用又开始。
var ErrBuilding = errors.New("正在编译中")

// Builder 提供了一个可重复生成 HTML 内容的对象
Expand All @@ -48,7 +47,9 @@ type Builder struct {
// 预览模式下会加载草稿内容。
Preview bool

// 是否替换 conf.yaml 中的 url 变量
// 如果不空则替换 conf.yaml 中的 url 变量
//
// 一般在预览模式下,需要将其替换成本地的地址。
BaseURL string

rebuildMux sync.Mutex // 防止多次调用 Rebuild
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"golang.org/x/text/message"

"github.com/caixw/blogit/v2"
"github.com/caixw/blogit/v2/builder"
)

var (
Expand All @@ -32,7 +31,7 @@ func build(p *message.Printer) func(io.Writer) error {
start := time.Now()

info.Println(p.Sprintf("start build"))
if err := blogit.Build(os.DirFS(buildSrc), builder.DirFS(buildDest), info.AsLogger()); err != nil {
if err := blogit.Build(os.DirFS(buildSrc), blogit.DirFS(buildDest), info.AsLogger()); err != nil {
if ls, ok := err.(localeutil.LocaleStringer); ok {
erro.Println(ls.LocaleString(p))
} else {
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/create/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/issue9/cmdopt"
"golang.org/x/text/message"

"github.com/caixw/blogit/v2/builder"
"github.com/caixw/blogit/v2"
"github.com/caixw/blogit/v2/internal/cmd/console"
"github.com/caixw/blogit/v2/internal/testdata"
)
Expand All @@ -29,7 +29,7 @@ func initF(erro *console.Logger, p *message.Printer) cmdopt.DoFunc {
return nil
}

wfs := builder.DirFS(initFS.Arg(0))
wfs := blogit.DirFS(initFS.Arg(0))
return fs.WalkDir(testdata.Source, ".", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/create/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/issue9/cmdopt"
"golang.org/x/text/message"

"github.com/caixw/blogit/v2/builder"
"github.com/caixw/blogit/v2"
"github.com/caixw/blogit/v2/internal/cmd/console"
"github.com/caixw/blogit/v2/internal/vars"
)
Expand Down Expand Up @@ -69,10 +69,10 @@ func post(succ, erro *console.Logger, localePrinter *message.Printer) cmdopt.DoF
}
}

func getWD() (builder.WritableFS, error) {
func getWD() (blogit.WritableFS, error) {
dir, err := os.Getwd()
if err != nil {
return nil, err
}
return builder.DirFS(dir), nil
return blogit.DirFS(dir), nil
}
5 changes: 2 additions & 3 deletions internal/cmd/preview/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package preview

import (
"errors"
"fmt"
"io/fs"
"net/http"
"net/url"
Expand All @@ -21,7 +20,7 @@ import (
"github.com/caixw/blogit/v2/internal/cmd/console"
)

// options 启动服务的参数选项
// 启动服务的参数选项
type options struct {
p *message.Printer

Expand Down Expand Up @@ -85,7 +84,7 @@ func (o *options) parseURL() error {
case "http", "":
o.addr = ":80"
default:
return fmt.Errorf(o.p.Sprintf("preview unknown protocol", scheme))
return errors.New(o.p.Sprintf("preview unknown protocol", scheme))
}
} else {
o.addr = ":" + o.addr
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/serve/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/caixw/blogit/v2/internal/cmd/console"
)

// options 启动服务的参数选项
// 启动服务的参数选项
type options struct {
p *message.Printer

Expand Down

0 comments on commit a765a4e

Please sign in to comment.