title: How can I extract data from a shared memory file, originally a C struct, into Go?
body: <p>For a student project I'm trying to build an interface between Project Cars 2 which has a shared memory address where you can collect car telemetry data, and an embedded system communicating over UART. </p>
  
  <p>I'd like to build it in Go and in the long run make a package for Go that can communicate and collect telemetry data and use it in the future. The shared memory struct and data is <a href="https://github.com/bglebrun/PCarsUART/blob/master/pcars/SharedMemory.h" rel="nofollow noreferrer">written in C and found here</a> <a href="https://www.projectcarsgame.com/project-cars-2-api/" rel="nofollow noreferrer">(source of this file)</a>. When you access the memory mapped file "%pcars2%", this address contains the data in the organization of the linked struct.</p>
  
  <p>My question is how's the best way to extract data from this struct? I understand I can use cgo and interpret the struct's data, but is there a way I could do a memory copy like in C directly in Go using a struct built from similar types from this address? I understand I can use the UDP API for telemetry data but am curious if Go has this sort of functionality.</p>