importService

package
v0.0.0-...-bef4ad1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const NoTitle = ""

NoTitle 未命名文章题目修改为空,方便前端处理

Variables

This section is empty.

Functions

func Transform

func Transform(file []byte) (blog model.Blog)

Transform to parse md file for model.Blog

Example
c := make(chan []byte)
done := make(chan bool)
count := 0
t1 := time.Now()

go func() {
	for {
		res, ok := <-c
		if ok {
			blog := Transform(res)
			println(blog.Title)
			println(count, "write", time.Since(t1))
			count--
		} else {
			println("finished!")
			done <- true
			return
		}
	}
}()

mo2utils.ProcessAllFiles("./", "", func(parameter ...string) {
	if strings.HasSuffix(parameter[0], ".md") {
		source, err := ioutil.ReadFile(parameter[0])
		if err != nil {
			panic(err)
		}
		c <- source
		count++
		println(count, " read", time.Since(t1))
	}
})
close(c)
<-done
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL