How many files?

Report a typo

Below is a Go program that takes as an input an int64 number with the availableSize of storage. Your task is to get the size of the go.mod file and then calculate how many go.mod files could be stored in the input availableSize.

Tip: Remember that you can use the os.Stat() function to get the size of a specific file.

Sample Input 1:

2048

Sample Output 1:

1
Write a program in Go
package main

import (
"fmt"
"log"
"os"
)

func main() {
var availableSize, size, filesCount int64
fmt.Scan(&availableSize)

fileInfo, err := ?
if err != nil {
log.Fatal(err)
}

for {
size += ?
if size > ? {
break
}
filesCount++
}

fmt.Println(filesCount)
}
___

Create a free account to access the full topic