//WriteTo function will read the properties from a io.Writer.
//If error occurs while writing to the reader, this will immediately return the error.This may cause partial writes.
//This function does not close the writer and it is the responsibility of the caller to close the writer
WriteTo function will read the properties from a io.Writer.
If error occurs while writing to the reader, this will immediately return the error.This may cause partial writes.
This function does not close the writer and it is the responsibility of the caller to close the writer
// WriteTo function will read the properties from a io . Writer . // If error occurs while writing to the reader this will immediately return the error . This may cause partial writes . // This function does not close the writer and it is the responsibility of the caller to close the writer
func (p *Properties) WriteTo(w io.Writer) error {
	bufWriter := bufio.NewWriter(w)
	var err error = nil
	for k := range p.props {
		_, err = bufWriter.WriteString(k)
		if err != nil {
			break
		}
		_, err = bufWriter.WriteString(textutils.EqualStr)
		if err != nil {
			break
		}
		v := p.props[k]
		if v.hasVars {
			if varName, ok := v.vars[0]; ok {
				_, err = bufWriter.WriteString(createVarStructure(varName))
				if err != nil {
					break
				}
			}
			for i, c := range v.content {
				if varName, ok := v.vars[i+1]; ok {
					_, err = bufWriter.WriteString(c)
					if err != nil {
						break
					}
					_, err = bufWriter.WriteString(createVarStructure(varName))
					if err != nil {
						break
					}
				}
			}
		} else {
			_, err = bufWriter.WriteString(v.content[0])
			if err != nil {
				break
			}
		}
	}
	if err == nil {
		err = bufWriter.Flush()
	}
	return err
}
func ( p * Properties ) WriteTo ( w io . Writer ) error { bufWriter := bufio . NewWriter ( w ) var err error = nil for k := range p . props { _ , err = bufWriter . WriteString ( k ) if err != nil { break } _ , err = bufWriter . WriteString ( textutils . EqualStr ) if err != nil { break } v := p . props [ k ] if v . hasVars { if varName , ok := v . vars [ 0 ] ; ok { _ , err = bufWriter . WriteString ( createVarStructure ( varName ) ) if err != nil { break } } for i , c := range v . content { if varName , ok := v . vars [ i + 1 ] ; ok { _ , err = bufWriter . WriteString ( c ) if err != nil { break } _ , err = bufWriter . WriteString ( createVarStructure ( varName ) ) if err != nil { break } } } } else { _ , err = bufWriter . WriteString ( v . content [ 0 ] ) if err != nil { break } } } if err == nil { err = bufWriter . Flush ( ) } return err }
WriteTo function will read the properties from a io.Writer.
WriteTo function will read the properties from a io . Writer .
//Check if the value starts with a variable