Advertisement
Gygaweb

golang time to write strings array

Mar 10th, 2023
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.37 KB | Source Code | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "time"
  6. )
  7.  
  8. func main() {
  9.     start := time.Now()
  10.  
  11.     // Escrever um array de string com 1000 elementos no console
  12.     var arr [1000]string
  13.     for i := 0; i < 1000; i++ {
  14.         arr[i] = "linha " + fmt.Sprintf("%d", i+1)
  15.     }
  16.     fmt.Println(arr)
  17.  
  18.     elapsed := time.Since(start)
  19.     fmt.Printf("Tempo de execução em segundos: %.6f", elapsed.Seconds())
  20. }
  21.  
Tags: golang
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement