Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
go - copia la carpeta relativa usando incrustar

Estoy usando nuestra biblioteca go (podría cambiarse si es necesario) con una carpeta llamada "devops", que contiene contenido anidado.

en la biblioteca, copio la carpeta devops con su contenido, a otra carpeta.

esta es la función de copia:

 func CopyDirectory(scrDir, dest string) error { // scrDir = devops entries, err := ioutil.ReadDir(scrDir) if err != nil { return err } for _, entry := range entries { sourcePath := filepath.Join(scrDir, entry.Name()) destPath := filepath.Join(dest, entry.Name()) fileInfo, err := os.Stat(sourcePath) fmt.Println(fileInfo) if err != nil { return err } stat, ok := fileInfo.Sys().(*syscall.Stat_t) if !ok { return fmt.Errorf("failed to get raw syscall.Stat_t data for '%s'", sourcePath) } switch fileInfo.Mode() & os.ModeType { case os.ModeDir: if err := CreateIfNotExists(destPath, 0755); err != nil { // CreateIfNotExists is a internal function return err } if err := CopyDirectory(sourcePath, destPath); err != nil { // CopyDirectory is a internal function return err } case os.ModeSymlink: if err := CopySymLink(sourcePath, destPath); err != nil { // CopySymLink is a internal function return err } default: if err := Copy(sourcePath, destPath); err != nil { // Copy is a internal function return err } } if err := os.Lchown(destPath, int(stat.Uid), int(stat.Gid)); err != nil { return err } isSymlink := entry.Mode()&os.ModeSymlink != 0 if !isSymlink { if err := os.Chmod(destPath, entry.Mode()); err != nil { return err } } } return nil

}

la biblioteca funciona bien como autoejecutable, pero cuando la uso desde otro proyecto, intenta copiar la carpeta devops de la ruta del proyecto y, por supuesto, falla.

Intenté hacerlo con incrustar pkg, pero el código falla al llamar

información de archivo.Sys().(*syscall.Stat_t)

con un error que no da ningún detalle.

este es mi codigo:

 //go:embed devops var f embed.FS ... dir, _ := f.ReadDir("devops") for _, entry := range dir { fileInfo, _ := entry.Info() err, ok := fileInfo.Sys().(*syscall.Stat_t) if !ok { println(err) // prints 0x0 } }

¿Cómo resolverlo?

PD: el código se ejecuta en el sistema operativo Linux.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!