Skip to content

Instantly share code, notes, and snippets.

@zhangzhhz
Last active November 25, 2023 15:33
Show Gist options
  • Save zhangzhhz/95d12dafadb801f0cdfc76df471b1981 to your computer and use it in GitHub Desktop.
Save zhangzhhz/95d12dafadb801f0cdfc76df471b1981 to your computer and use it in GitHub Desktop.
create a binary file of 50MB size, all 0x00

python

with open("50M.dat", "wb") as outfile:
    outfile.write(b'\x00' * 50 * 1024 * 1024)
    # outfile.write(bytes(50 * 1024 * 1024))

go

package main

import (
    "os"
    "log"
)

func main() {
    f, err := os.Create("50MB_go.dat")
    if err != nil {
        log.Fatal(err)
    }
    defer f.Close()
    size := 50 * 1024 * 1024
    bytes := make([]byte, size)
    f.Write(bytes)
}

lua

outfile = io.open("50M.dat", "wb")
outfile:write(string.rep(string.char(0), 50 * 1024 * 1024))
outfile:close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment