Blane187's picture
Upload folder using huggingface_hub
7ff2ba3 verified
raw
history blame contribute delete
602 Bytes
package main
import (
"crypto/sha256"
"encoding/hex"
"fmt"
"io"
"os"
)
func main() {
var buf [32]byte
h := sha256.New()
lst := make([]any, 0, 64)
for _, fname := range files {
f, err := os.Open("assets/" + fname)
if err != nil {
panic(err)
}
_, err = io.Copy(h, f)
if err != nil {
panic(err)
}
s := hex.EncodeToString(h.Sum(buf[:0]))
fmt.Println("sha256 of", fname, "=", s)
lst = append(lst, s)
h.Reset()
f.Close()
}
f, err := os.Create("sha256.env")
if err != nil {
panic(err)
}
_, err = fmt.Fprintf(f, envtmpl, lst...)
if err != nil {
panic(err)
}
}