func (p4 *P4) SaveTxt(specName string, specContents map[string]string, args []string) (string, error) {
	opts := p4.getOptionsNonMarshal()
	nargs := []string{specName, "-i"}
	nargs = append(nargs, args...)
	args = append(opts, nargs...)

	log.Println(args)
	cmd := exec.Command("p4", args...)
	var stdout, stderr bytes.Buffer
	stdin, err := cmd.StdinPipe()
	if err != nil {
		fmt.Println("An error occured: ", err)
	}
	cmd.Stdout = &stdout
	cmd.Stderr = &stderr
	mainerr := cmd.Start()
	if mainerr != nil {
		fmt.Println("An error occured: ", mainerr)
	}
	spec := formatSpec(specContents)
	log.Println(spec)
	io.WriteString(stdin, spec)
	// Need to explicitly call this for the command to fire
	stdin.Close()
	cmd.Wait()

	e, err := ioutil.ReadAll(&stderr)
	log.Println(e)
	if len(e) > 0 {
		return "", errors.New(string(e))
	}
	x, err := ioutil.ReadAll(&stdout)
	s := string(x)
	log.Println(s)
	return s, mainerr
}
// The Save() func doesn't work as it needs the data marshalled instead of
// map[string]string
// This is a quick fix, the real fix is writing a marshal() function or try
// using gopymarshal
The Save() func doesn't work as it needs the data marshalled instead of
map[string]string
This is a quick fix, the real fix is writing a marshal() function or try
using gopymarshal
// The Save () func doesn ' t work as it needs the data marshalled instead of // map [ string ] string // This is a quick fix the real fix is writing a marshal () function or try // using gopymarshal
func (p4 *P4) SaveTxt(specName string, specContents map[string]string, args []string) (string, error) {
	opts := p4.getOptionsNonMarshal()
	nargs := []string{specName, "-i"}
	nargs = append(nargs, args...)
	args = append(opts, nargs...)
	log.Println(args)
	cmd := exec.Command("p4", args...)
	var stdout, stderr bytes.Buffer
	stdin, err := cmd.StdinPipe()
	if err != nil {
		fmt.Println("An error occured: ", err)
	}
	cmd.Stdout = &stdout
	cmd.Stderr = &stderr
	mainerr := cmd.Start()
	if mainerr != nil {
		fmt.Println("An error occured: ", mainerr)
	}
	spec := formatSpec(specContents)
	log.Println(spec)
	io.WriteString(stdin, spec)
	stdin.Close()
	cmd.Wait()
	e, err := ioutil.ReadAll(&stderr)
	log.Println(e)
	if len(e) > 0 {
		return "", errors.New(string(e))
	}
	x, err := ioutil.ReadAll(&stdout)
	s := string(x)
	log.Println(s)
	return s, mainerr
}
func ( p4 * P4 ) SaveTxt ( specName string , specContents map [ string ] string , args [ ] string ) ( string , error ) { opts := p4 . getOptionsNonMarshal ( ) nargs := [ ] string { specName , " " } nargs = append ( nargs , args ... ) args = append ( opts , nargs ... ) log . Println ( args ) cmd := exec . Command ( " " , args ... ) var stdout , stderr bytes . Buffer stdin , err := cmd . StdinPipe ( ) if err != nil { fmt . Println ( " " , err ) } cmd . Stdout = & stdout cmd . Stderr = & stderr mainerr := cmd . Start ( ) if mainerr != nil { fmt . Println ( " " , mainerr ) } spec := formatSpec ( specContents ) log . Println ( spec ) io . WriteString ( stdin , spec ) stdin . Close ( ) cmd . Wait ( ) e , err := ioutil . ReadAll ( & stderr ) log . Println ( e ) if len ( e ) > 0 { return " " , errors . New ( string ( e ) ) } x , err := ioutil . ReadAll ( & stdout ) s := string ( x ) log . Println ( s ) return s , mainerr }
The Save() func doesn't work as it needs the data marshalled instead of
map[string]string
This is a quick fix, the real fix is writing a marshal() function or try
using gopymarshal
The Save () func doesn ' t work as it needs the data marshalled instead of map [ string ] string This is a quick fix the real fix is writing a marshal () function or try using gopymarshal
// Need to explicitly call this for the command to fire