45 lines
897 B
Go
45 lines
897 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log"
|
|
"math/rand"
|
|
"sync"
|
|
|
|
"git.ksdemosapps.com/kylesoda/go-migrate/internal/app/azure"
|
|
"git.ksdemosapps.com/kylesoda/go-migrate/internal/app/config"
|
|
)
|
|
|
|
func main() {
|
|
cfg := config.App.AzureStorage
|
|
containerName := cfg.Container
|
|
|
|
client, err := azure.NewClient(cfg)
|
|
if err != nil {
|
|
log.Fatalf("Error creando cliente: %v", err)
|
|
}
|
|
ctx := context.Background()
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
for i := 1; i <= 10; i++ {
|
|
wg.Add(1)
|
|
go func(id int) {
|
|
defer wg.Done()
|
|
|
|
blobName := fmt.Sprintf("%sarchivo-%d.txt", cfg.Prefix, id)
|
|
content := fmt.Sprintf("Contenido aleatorio: %d", rand.Intn(100000))
|
|
|
|
err := client.UploadBuffer(ctx, containerName, blobName, []byte(content))
|
|
if err != nil {
|
|
log.Printf("Fallo al subir %s: %v", blobName, err)
|
|
} else {
|
|
fmt.Printf("Subido exitosamente: %s\n", blobName)
|
|
}
|
|
}(i)
|
|
}
|
|
|
|
wg.Wait()
|
|
}
|