You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"context""fmt""os""time""github.com/cnaize/pipe/pipes""github.com/cnaize/pipe/pipes/archive""github.com/cnaize/pipe/pipes/common""github.com/cnaize/pipe/pipes/hash""github.com/cnaize/pipe/pipes/localfs""github.com/cnaize/pipe/pipes/state"
)
funcmain() {
// craeate a pipelinepipeline:=pipes.Line(
// set execution timeoutcommon.Timeout(time.Second),
// open two example fileslocalfs.OpenFiles("testdata/test_0.txt", "testdata/test_1.txt"),
// calculate and compare hash for each filehash.SumSha256("kEvuni09HxM1ox-0nIj7_Ug1Adw0oIU62ukuh49oi5c=", "CeE_WA_xKsx2Dj_sRvowaCeDfQOPviSpyjaZdxuCT4Y="),
// zip the filesarchive.ZipFiles(),
// calculate hash for the zip archivehash.SumSha256(""),
// create a temporary directorylocalfs.MakeDirAll("testdata/tmp", os.ModePerm),
// create a new filelocalfs.CreateFiles("testdata/tmp/test.zip"),
// flow the files through the pipes and keep metadatastate.Consume(),
)
// run the pipelineres, _:=pipeline.Run(context.Background(), nil)
// iterate over result files and print metadataforfile:=rangeres.Files {
fmt.Printf("--> Result file:\n\tName: %s\n\tSize: %d\n\tHash: %s\n", file.Name, file.Size, file.Hash)
}
}
Output:
--> Result file:
Name: testdata/tmp/test.zip
Size: 1047
Hash: Yg3OOaBD-miLs7lDIBVAeZMZIXYfy2N25f8-b-1kWOc=