writefile

package
v0.0.0-...-e633676 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SplitCharacter = ","

SplitCharacter is

Functions

func CreateFile

func CreateFile(fileName string)

CreateFile is used to create a new file. This function externally takes only a value of type "string" with the name "fileName". This value determines the name of the file to be created. This function performs util using the command "os.Create". The file is closed after it is created. This is the intent of the "defer" block.

func OpenFile

func OpenFile(openedOSFile *os.File, openingFileName string) *os.File

OpenFile performs the opening process to write or read a file. This function takes two external values. openingFileName: This gets the name with the extension of the file to be opened.

If it is in the same folder as the program, only the name is enough.

openedOSFile: This variable is important. Several files can be opened

  at the same time and separate util can be performed on those files.
  If you have a single "os.File" variable, you can not do the same operation.
  For this reason, we expect the user to define a variable "var fileVarible * os.File"
 instead of a constant variable and send this variable value to the "OpenFile" function.
 This function returns the file that it opened in the form of "os.File" when opening.
 Thus, when the file is opened, writing or reading util can be performed through the variable that returns easily.
Example Usage:
   var openFile1 *os.File
   writefile.CreateFile("testFile.csv")
   openFile1 = writefile.OpenFile2("testFile.csv", openFile1)

func WriteArray

func WriteArray(openedFile *os.File, writeTextArray []string)

WriteArray writes the data received in the Array type to the opened file and closes that file. It takes two values. writeTextArray: takes an array of type string. This array is written to the file. openedFile: The file to be opened.

func WriteByte

func WriteByte(openedFile *os.File, writeTextByte []byte)

WriteByte writes the data in the byte type received in the Array type to the opened file and closes that file. It takes two values. writeTextByte: takes an array of type byte. This array is written to the file. openedFile: The file to be opened.

func WriteText

func WriteText(openedFile *os.File, writeText ...string)

WriteText retrieves data in series. A serial data stream gets the first line of a csv formatted data. Thus, how many columns have been filled in so many columns, how many times this function is called, will create as many lines. Unlike the others, the variable "os.File" comes first because it needs to be a variable terminator. openedFile: Specifies the file to be written. writeText: a serialized variable of type string. This function can be sent as a string type by putting "," between them.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL