You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: gfile_contents.go
    path of file: ./repos/gf/os/gfile
    
    the code of the file until where you have to start completion: // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.

package gfile

import (
	"bufio"
	"io"
	"os"

	"github.com/gogf/gf/v2/errors/gerror"
)

var (
	// DefaultReadBuffer is the buffer size for reading file content.
	DefaultReadBuffer = 1024
)

// GetContents returns the file content of `path` as stri
    
func putContents(path string, data []byte, flag int, perm os.FileMode) error {
	// It supports creating file of `path` recursively.
	dir := Dir(path)
	if !Exists(dir) {
		if err := Mkdir(dir); err != nil {
			return err
		}
	}
	// Opening file with given `flag` and `perm`.
	f, err := OpenWithFlagPerm(path, flag, perm)
	if err != nil {
		return err
	}
	defer f.Close()
	// Write data.
	var n int
	if n, err = f.Write(data); err != nil {
		err = gerror.Wrapf(err, `Write data to file "%s" failed`, path)
		return err
	} else if n < len(data) {
		return io.ErrShortWrite
	}
	return nil
}