Skip to content

Commit

Permalink
移除无用代码
Browse files Browse the repository at this point in the history
  • Loading branch information
newpanjing committed Jun 13, 2022
1 parent 9aae3fd commit 2fb5dbb
Show file tree
Hide file tree
Showing 1,179 changed files with 3 additions and 731,354 deletions.
1 change: 1 addition & 0 deletions core/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"time"
)

// NewContainer 创建一个容器
func NewContainer(tokenizer *words.Tokenizer) *searcher.Container {
container := &searcher.Container{
Dir: global.CONFIG.Data,
Expand Down
11 changes: 2 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,15 @@ require (
)

require (
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/pretty v0.2.0 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-playground/locales v0.13.0 // indirect
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/go-playground/validator/v10 v10.4.1 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/kr/pretty v0.2.0 // indirect
github.com/leodido/go-urn v1.2.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
Expand All @@ -45,6 +39,5 @@ require (
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
google.golang.org/protobuf v1.28.0 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
10 changes: 0 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03O
github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o=
github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ=
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
Expand All @@ -96,7 +95,6 @@ golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrb
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220412020605-290c469a71a5 h1:bRb386wvrE+oBNdF1d/Xh9mQrfQ4ecYhW5qJ5GvTGT4=
golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -105,22 +103,14 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/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-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
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=
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f h1:GGU+dLjvlC3qDwqYgL6UgRmHXhOOgns0bZu2Ty5mm6U=
Expand Down
100 changes: 0 additions & 100 deletions searcher/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ import (
"compress/flate"
"encoding/binary"
"encoding/gob"
"fmt"
"io/fs"
"io/ioutil"
"log"
"os"
"path/filepath"
"regexp"
"strings"
"time"
)

Expand All @@ -23,23 +20,6 @@ func ExecTime(fn func()) float64 {
return tc / 1e6
}

// Write 写入二进制数据到磁盘文件
func Write(data interface{}, filename string) {
buffer := new(bytes.Buffer)
encoder := gob.NewEncoder(buffer)
err := encoder.Encode(data)
if err != nil {
panic(err)
}

log.Println("Write:", filename)
compressData := Compression(buffer.Bytes())
err = ioutil.WriteFile(filename, compressData, 0600)
if err != nil {
panic(err)
}
}

func Encoder(data interface{}) []byte {
if data == nil {
return nil
Expand All @@ -65,22 +45,6 @@ func Decoder(data []byte, v interface{}) {
}
}

// Compression 压缩数据
func Compression(data []byte) []byte {
buf := new(bytes.Buffer)
write, err := flate.NewWriter(buf, flate.DefaultCompression)
defer write.Close()

if err != nil {
panic(err)
}

write.Write(data)
write.Flush()
log.Println("原大小:", len(data), "压缩后大小:", buf.Len(), "压缩率:", fmt.Sprintf("%.2f", float32(buf.Len())/float32(len(data))), "%")
return buf.Bytes()
}

//Decompression 解压缩数据
func Decompression(data []byte) []byte {
return DecompressionBuffer(data).Bytes()
Expand All @@ -95,27 +59,6 @@ func DecompressionBuffer(data []byte) *bytes.Buffer {
return buf
}

// Read 从磁盘文件加载二进制数据
func Read(data interface{}, filename string) {
raw, err := ioutil.ReadFile(filename)
if err != nil {
if os.IsNotExist(err) {
//忽略
return
}
panic(err)
}
//解压
decoData := Decompression(raw)

buffer := bytes.NewBuffer(decoData)
dec := gob.NewDecoder(buffer)
err = dec.Decode(data)
if err != nil {
panic(err)
}
}

const (
c1 = 0xcc9e2d51
c2 = 0x1b873593
Expand Down Expand Up @@ -195,10 +138,6 @@ func Uint32ToBytes(i uint32) []byte {
return buf
}

func BytesToUint32(buf []byte) uint32 {
return binary.BigEndian.Uint32(buf)
}

// QuickSortAsc 快速排序
func QuickSortAsc(arr []int, start, end int, cmp func(int, int)) {
if start < end {
Expand Down Expand Up @@ -292,24 +231,6 @@ func DirSizeB(path string) int64 {
return size
}

//getFileSize get file size by path(B)
func getFileSize(path string) int64 {
if !exists(path) {
return 0
}
fileInfo, err := os.Stat(path)
if err != nil {
return 0
}
return fileInfo.Size()
}

//exists Whether the path exists
func exists(path string) bool {
_, err := os.Stat(path)
return err == nil || os.IsExist(err)
}

// RemovePunctuation 移除所有的标点符号
func RemovePunctuation(str string) string {
reg := regexp.MustCompile(`\p{P}+`)
Expand All @@ -321,24 +242,3 @@ func RemoveSpace(str string) string {
reg := regexp.MustCompile(`\s+`)
return reg.ReplaceAllString(str, "")
}

func contains(s *[]string, e string, skipIndex int) bool {
for index, a := range *s {
if index != skipIndex && strings.Contains(a, e) {
return true
}
}
return false
}

// GetLongWords 获取长词
func GetLongWords(words *[]string) []string {

var newWords = make([]string, 0)
for index, w := range *words {
if !contains(words, w, index) {
newWords = append(newWords, w)
}
}
return newWords
}
41 changes: 0 additions & 41 deletions vendor/github.com/emirpasic/gods/LICENSE

This file was deleted.

35 changes: 0 additions & 35 deletions vendor/github.com/emirpasic/gods/containers/containers.go

This file was deleted.

61 changes: 0 additions & 61 deletions vendor/github.com/emirpasic/gods/containers/enumerable.go

This file was deleted.

Loading

0 comments on commit 2fb5dbb

Please sign in to comment.