Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【开源自荐】递归获取文件夹大小,使用 go,足够快,可以跑在 node 中 #2865

Closed
markthree opened this issue Jan 30, 2023 · 0 comments

Comments

@markthree
Copy link

go-get-folder-size

递归获取文件夹大小,使用 go,足够快,可以跑在 node 中


仓库

Github 👉 go-get-folder-size


特性


动机

想要快速知道文件夹大小,但 nodejs 实现的 get-folder-size 是慢的,所以用 go 实现了递归获取文件夹大小,能跑在 nodejs 中。

具体可见 issue 👉 get-folder-size/issues/22


使用

npm

install

npm install go-get-folder-size

cli

# Binary go, fastest
npx go-get-folder-size

program

import {
	getFolderSize,
	getFolderSizeBin,
	getFolderSizeWasm
} from 'go-get-folder-size'

const base = './' // 你想要获取的目录

await getFolderSizeBin(base) // 二进制 go,最快

await getFolderSize(base) // 原生 node

await getFolderSizeWasm(base) // Wasm go,最慢 🥵

go

install

go install github.com/markthree/go-get-folder-size

cli

go-get-folder-size

program

go get github.com/markthree/go-get-folder-size
package main

import (
	getFolderSize "github.com/markthree/go-get-folder-size/src"
)

func main() {
	size, err := getFolderSize.Parallel("./") // 并发计算,超级快
}

提示

  • wasm 出奇的比原生 node 要慢 🫣
  • 目前该包被使用在组织内的本地项目管理器中,首次获取项目大小优化到 1s 内 👉 x-pm

灵感来源

esbuild


License

Made with markthree

Published under MIT License.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants