Skip to content

jackal-xmpp/stravaganza

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stravaganza

CI Status Go Report Card Coverage Godoc Releases LICENSE

Installation

go get -u github.com/jackal-xmpp/stravaganza

Example

package main

import (
	"fmt"
	"os"

	"github.com/jackal-xmpp/stravaganza"
)

func main() {
	iq, err := stravaganza.NewBuilder("iq").
		WithValidateJIDs(true).		
		WithAttribute("id", "zid615d9").
		WithAttribute("from", "[email protected]/yard").
		WithAttribute("to", "[email protected]/balcony").
		WithAttribute("type", "get").
		WithChild(
			stravaganza.NewBuilder("ping").
				WithAttribute("xmlns", "urn:xmpp:ping").
				Build(),
		).
		BuildIQ()
	if err != nil {
		_, _ = fmt.Fprint(os.Stderr, err.Error())
		return
	}
	_ = iq.ToXML(os.Stdout, true)
}

Expected output:

<iq id='zid615d9' from='[email protected]/yard' to='[email protected]/balcony' type='get'><ping xmlns='urn:xmpp:ping'/></iq>

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

License

Apache License 2.0