Im trying to write a program that takes user input flags, reads an input file containing data (testInput.txt), then appends the user's flags to the input data and exports it all to an output file (testOutput.txt). I am getting an error in func employeeReadWrite() when trying to append the two together. "invalid operation: contents + cnvUserProfile (operator + not defined on slice)". I'm new to programming with go being my 1st language, and I don't have a great handle on slices yet. What do I need to do to resolve that error?
package main
import (
"flag"
"fmt"
"io/ioutil"
"os"
)
var targetEmployee *string
var targetUsername *string
var targetLocation *string
var targetDepartment *string
var targetManager *string
var targetTitle *string
var userProfile string
func getFlagVariables() {
targetEmployee = flag.String("employee", "", "What is there name? (-employee)")
targetUsername = flag.String("username", "", "What is there username? (-username)")
targetLocation = flag.String("location", "", "Where are the working from? (-location)")
targetDepartment = flag.String("department", "", "What is there department? (-department)")
targetManager = flag.String("manager", "", "Who is there manager? (-manager)")
targetTitle = flag.String("title", "", "What is there job title? (-title)")
flag.Parse()
fmt.Println("-----------------------------------")
userProfile = *targetEmployee + "
" + *targetUsername + "
" + *targetUsername + "@genericCompany.com" + "
" + *targetLocation + "
" + *targetDepartment + "
" + *targetManager + "
" + *targetTitle
fmt.Println(userProfile)
fmt.Println("-----------------------------------")
}
func employeeReadWriteFile() {
contents, _ := ioutil.ReadFile("testInput.txt")
cnvrtUserProfile := []byte(userProfile)
ioutil.WriteFile("testOutput.txt", contents+cnvrtUserProfile, 0x777)
}