packagehcsimport("io""syscall""github.com/Microsoft/go-winio")// makeOpenFiles calls winio.MakeOpenFile for each handle in a slice but closes all the handles// if there is an error.funcmakeOpenFiles(hs[]syscall.Handle)(_[]io.ReadWriteCloser,errerror){fs:=make([]io.ReadWriteCloser,len(hs))fori,h:=rangehs{ifh!=syscall.Handle(0){iferr==nil{fs[i],err=winio.MakeOpenFile(h)}iferr!=nil{syscall.Close(h)}}}iferr!=nil{for_,f:=rangefs{iff!=nil{f.Close()}}returnnil,err}returnfs,nil}