top of page
  • admin

Golang and Procore Integration

SDG's Procore integration services stem from our growing use of Go (or Golang), the safety-first, statically-typed language from Google. It has a number of features which dramatically ease development of code designed to interact with web APIs.

Our choice of Go to intermediate between two APIs was in part dictated by previous project requirements, but as it turns out, Go has a number of features which make it a good choice for this sort of project, especially when the APIs (like Procore's) are well-designed.


Extensive Library Support


Out of the box, Go has library functions to do everything you need to do to make HTTP requests. For more esoteric requirements, like OAuth support, exponential backoff, and nearly anything else, there are well-supported third-party libraries.

SDG has used the Goth OAuth library for prior Procore integrations. With an account for the relevant service, OAuth login provides security and easy access control without the need to store credentials locally.

SDG has also used the Pester library to handle retrying and backoff, to guard against transient network problems. Like many Go libraries which enhance standard library features, it's API-compatible with the standard library function it replaces. Switching is as easy as changing, for instance, calls to http.Get() to pester.Get().


Easy JSON Handling


Go is built with data marshaling and unmarshaling in mind. Without any developer work, a Go struct can be marshalled to JSON or unmarshalled from JSON:

type Example struct {
	FieldA int
	FieldB string
	TaggedField string `json:"fieldc"`
}

becomes

{
	"FieldA": 0,  // when unmarshalling, field names are
	"FieldB": "", // case-insensitive

	"fieldc": ""  // struct tags override the default scheme
}

This is a feature of the Go encoding/json package; other, non-JSON packages may define their own standard marshalling and unmarshalling for arbitrary Go structs. Dealing with a SOAP API? There are packages for that, too, with the same developer-transparent ethos.

The less you have to think about translating native data to JSON form, the better. Go is freeing in this way, leaving you with more cognitive resources to spend on the important logic.


Type Safety


Go is a strongly-typed language. This is an advantage over server-side JavaScript or some other loosely-typed language: it means that the consequences of a poorly-formatted JSON response from an API are obvious and immediate. It also requires that, in the case of translating data between two representations, structs be defined both for the input format and the output format. Far from being a problem, this is a feature: it requires that thought be given to the nature of the translation, and helps to avoid logic errors in writing it.


Speed


Go's second advantage over loosely-typed languages is that it runs much more quickly. Go code runs as quickly or more quickly than Java code in many cases, and its compiler is still comparatively immature. As it receives more optimization, it should slot into the statically-typed-and-precompiled space somewhere slower than C but faster than Java.

This may not seem like an important feature for an API translator, given that the slow part is usually the web requests, but in our experience translating between Procore and the Veriwolf product, we've found several places where the structure of the queries don't match. This can require querying for a lot of data and implementing the filtering we need in the integration service. For that case, adding as little overhead as possible has great value.


Good Tools


Lastly, Go's tools are well-designed and well-integrated. Although Java's tools are still better, Go's tools are rapidly approaching the same level. The usual set—search and navigation, smart code completion, and integrated compilation and testing—are joined by somewhat less common ones, like integrated debugging and complex refactoring.

Good tools are crucial for developer productivity, and Go's already surpass those available for JavaScript.


Conclusion


Go is a good choice for API integration work, and SDG has a lot of experience working with Go to do API integrations. Not only that, but we also have experience working with Procore's API. Our Procore integration services leverage experienced developers using the right tools to deliver reliable solutions and quick turnaround.

To learn more about our software development services, please contact us.

42 views

Recent Posts

See All
bottom of page