Code Monkey home page Code Monkey logo

swephgo's Introduction

SwEphGo

Golang interface binding to the Swiss Ephemeris C library v2.10.03.

Swiss Ephemeris is a powerful and versatile astronomical calculation library that serves the needs of astrologers, archeoastronomers, and, depending on the purpose, also astronomers. It includes long-term ephemerides for the Sun, the Moon, the planets, over 300,000 asteroids, historically relevant fixed stars, and some hypothetical objects.

Installation

To get started with using SwEphGo, you'll first need to install the Swiss Ephemeris Library. You can download it here and then follow these installation steps:

  1. To compile the library, navigate to the src folder of the downloaded library and execute make libswe.so. In some environments, you may need to modify the build command by adding -lm -ldl to libswe.so in the Makefile. Here's the updated Makefile code:
libswe.so: $(SWEOBJ)
	$(CC) -shared -o libswe.so $(SWEOBJ) -lm -ldl
  1. After compiling the library, copy the libswe.so file to /usr/local/lib/.
$ cp libswe.so /usr/local/lib/
  1. Get the library with the following command:
$ go get github.com/mshafiee/swephgo

Usage

Once you have the library installed, you can use it in your Go projects by importing it in the main package and calling the Version function to print out the version of the library being used. For example, you can use the following code:

package main

import (
	"fmt"
	"github.com/mshafiee/swephgo"
)

func main() {
	sweVer := make([]byte, 12)
	swephgo.Version(sweVer)
	fmt.Printf("Library used: Swiss Ephemeris v%s\n", sweVer)
}

To run the code above:

$ go run main.go

The output will be:

Library used: Swiss Ephemeris v2.10.03

Disclaimer

This project includes C header files taken from the SWISSEPH source code. These rights belong to Astrodienst AG, Switzerland. For information on how to use the rights of these files, please visit the Swiss Ephemeris website. The developer of this library is not affiliated with Astrodienst AG and this library is provided as is, without warranty of any kind, express or implied.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.