func (a *Aria2) ChangeGlobalOptions(options Options) error {
	cOptions := C.CString(a.fromOptions(options))
	defer C.free(unsafe.Pointer(cOptions))
	if !C.changeGlobalOptions(cOptions) {
		return errors.New("libaria2: change global options error")
	}
	return nil
}
ChangeGlobalOptions changes global options. See available options in
https://aria2.github.io/manual/en/html/aria2c.html#input-file except for
`checksum`, `index-out`, `out`, `pause` and `select-file`.
package aria2go
import "C"
import (
	"errors"
	"fmt"
	"log"
	"strconv"
	"strings"
	"unsafe"
)
type Aria2 struct {
	notifier             Notifier
	shutdownNotification chan bool
	shouldShutdown       bool
}
type Config struct {
	Options  Options
	Notifier Notifier
}
func NewAria2(config Config) *Aria2 {
	a := &Aria2{
		notifier:             newDefaultNotifier(),
		shutdownNotification: make(chan bool),
	}
	a.SetNotifier(config.Notifier)
	C.init(C.uint64_t(uintptr(unsafe.Pointer(a))),
		C.CString(a.fromOptions(config.Options)))
	return a
}
func (a *Aria2) Shutdown() int {
	C.shutdownSchedules(true)
	a.shouldShutdown = true
	select {
	case <-a.shutdownNotification:
		break
	}
	return int(C.deinit())
}
func (a *Aria2) Run() {
	for {
		if C.run() != 1 && a.shouldShutdown {
			break
		}
	}
	a.shutdownNotification <- true
}
func (a *Aria2) SetNotifier(notifier Notifier) {
	if notifier == nil {
		return
	}
	a.notifier = notifier
}
func (a *Aria2) AddUri(uri string, options Options) (gid string, err error) {
	cUri := C.CString(uri)
	cOptions := C.CString(a.fromOptions(options))
	defer C.free(unsafe.Pointer(cUri))
	defer C.free(unsafe.Pointer(cOptions))
	ret := C.addUri(cUri, cOptions)
	if ret == 0 {
		return "", errors.New("libaria2: add uri failed")
	}
	return fmt.Sprintf("%x", uint64(ret)), nil
}
func (a *Aria2) AddTorrent(filepath string, options Options) (gid string, err error) {
	cFilepath := C.CString(filepath)
	cOptions := C.CString(a.fromOptions(options))
	defer C.free(unsafe.Pointer(cFilepath))
	defer C.free(unsafe.Pointer(cOptions))
	ret := C.addTorrent(cFilepath, cOptions)
	if ret == 0 {
		return "", errors.New("libaria2: add torrent failed")
	}
	return fmt.Sprintf("%x", uint64(ret)), nil
}
func (a *Aria2) ChangeOptions(gid string, options Options) error {
	cOptions := C.CString(a.fromOptions(options))
	defer C.free(unsafe.Pointer(cOptions))
	if !C.changeOptions(a.hexToGid(gid), cOptions) {
		return errors.New("libaria2: change options error")
	}
	return nil
}
func (a *Aria2) GetOptions(gid string) Options {
	cOptions := C.getOptions(a.hexToGid(gid))
	if cOptions == nil {
		return make(Options)
	}
	return a.toOptions(C.GoString(cOptions))
}