JRascagneres/Simconnect-Go

Example doesn't work, here's one that does

sybrenstuvel opened this issue · 2 comments

The example from the README file doesn't compile, as NewSimConnect() requires a string argument now. Also the last assignment to err is unchecked, which is a bad idea. And finally the example code can only work from within this package, but is typically run from the main package.

This code addresses all these points:

package main

import (
	"fmt"

	simconnect "github.com/JRascagneres/Simconnect-Go"
)

func main() {
	instance, err := simconnect.NewSimConnect("Simconnect-Go")
	if err != nil {
		panic(err)
	}

	report, err := instance.GetReport()
	if err != nil {
		panic(err)
	}

	fmt.Printf("User Altitude: %f\n", report.Altitude)

	if err := instance.Close(); err != nil {
		panic(err)
	}
}

Hey! Thanks for this! Will add it in. Are you happy for me to replace or do you want to open up a PR with this change so you get credit?

I can make a PR tomorrow!