Skip to content
Go to file
Cannot retrieve contributors at this time
132 lines (87 sloc) 5.03 KB


Table of Contents

Hazelcast Go Client

Go client implementation for Hazelcast, the open source in-memory data grid.

Go client is implemented using the Hazelcast Open Binary Client Protocol.

This client works with Hazelcast 3.6 and higher.

Hazelcast is a clustering and highly scalable data distribution platform. With its various distributed data structures, distributed caching capabilities, elastic nature and more importantly with so many happy users, Hazelcast is a feature-rich, enterprise-ready and developer-friendly in-memory data grid solution.

NOTE: This project is currently in active development.


Hazelcast Go client supports the following data structures and features:

  • Map (including entry processors and PartitionAware keys)
  • MultiMap
  • List
  • Set
  • Queue
  • Topic
  • ReplicatedMap
  • Ringbuffer
  • Query (Predicates)
  • API configuration
  • Event Listeners
  • Lifecycle Service
  • Smart and Unisocket Client operation
  • Hazelcast Serialization (IdentifiedDataSerializable, Portable, Custom Serializers, Global Serializers)

Installing the Client

Following command installs Hazelcast Go client:

go get

For more details

Using the Client

Following code snippet illustrates a simple usage of Map in Hazelcast Go Client.

	config := hazelcast.NewHazelcastConfig()

	client, err := hazelcast.NewHazelcastClientWithConfig(config)
	if err != nil {
	mp, _ := client.GetMap("simpleExample")

	mp.Put("key1", "value1")
	mp.Put("key2", "value2")

	result1, _ := mp.Get("key1")
	fmt.Println("key1 has the value of ", result1)

	result2, _ := mp.Get("key2")
	fmt.Println("key2 has the value of ", result2)


Please see Hazelcast Go code samples for more examples.

You can also refer to Hazelcast Go API Documentation.

Serialization Considerations

Hazelcast needs to serialize objects in order to be able to keep them in the server memory. For primitive types, it uses Hazelcast native serialization. For other complex types (e.g. Go objects), it uses Gob serialization.

NOTE: int and []int types in Go Language are serialized as int64 and []int64 respectively by Hazelcast Serialization.

For example, when you try to query your data using predicates, this querying is handled on the server side so Hazelcast does not have to bring all data to the client but only the relevant entries. Otherwise, there would be a lot of unneccessary data traffic between the client and the server and the performance would severely drop. Because predicates run on the server side, the server should be able to reason about your objects. That is why you need to implement serialization on the server side.

The same applies to MapStore. The server should be able to deserialize your objects in order to store them in MapStore.

Regarding arrays in a serializable object, you can use methods like WriteInt32Array if the array is of a primitive type.

If you have nested objects, these nested objects also need to be serializable. Register the serializers for nested objects and the method WriteObject will not have any problem with finding a suitable serializer for and writing/reading the nested object.


Building And Installing from Sources

Follow the below steps to build and install Hazelcast Go client from its source:


Following command starts the tests:

Run sh

Mail Group

Please join the mail group if you are interested in using or developing Hazelcast.


Hazelcast is available under the Apache 2 License. Please see the Licensing appendix for more information.


Copyright (c) 2008-2018, Hazelcast, Inc. All Rights Reserved.

Visit for more information.

You can’t perform that action at this time.