diff --git a/swego.go b/swego.go index ca17be5..40e28a1 100644 --- a/swego.go +++ b/swego.go @@ -37,6 +37,13 @@ type CalcFlags struct { FileNameJPL string } +// Copy returns a copy of the calculation flags fl. +func (fl *CalcFlags) Copy() *CalcFlags { + copy := new(CalcFlags) + *copy = *fl + return copy +} + // Ephemeris represents an ephemeris implemented in the C library. type Ephemeris int32 diff --git a/swego_test.go b/swego_test.go index b1c1313..5c9a521 100644 --- a/swego_test.go +++ b/swego_test.go @@ -53,8 +53,18 @@ func TestNewHSys(t *testing.T) { } } +func TestCalcFlags_Copy(t *testing.T) { + fl := new(CalcFlags) + fl.Flags = FlagSpeed + got := fl.Copy() + + if got == fl { + t.Errorf("%p = %p, want copy", got, fl) + } +} + func TestCalcFlags_SetEphemeris(t *testing.T) { - fl := CalcFlags{} + fl := new(CalcFlags) fl.SetEphemeris(JPL) if fl.Flags != int32(JPL) {