Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Go (golang) library for calling Salesforce.com (force.com) web api's

License

Notifications You must be signed in to change notification settings

giinsure/go-force

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-force

Go Report Card build status Go version Current Release godoc

License

Golang API wrapper for Force.com, Salesforce.com

This repo is based on https://github.com/nimajalali/go-force which seems to be dormant with the last commit 4 years ago at this time (06/2024).

Installation

go get github.com/giinsure/go-force/force

Example

package main

import (
	"fmt"
	"log"

	"github.com/giinsure/go-force/force"
	"github.com/giinsure/go-force/sobjects"
)

type SomeCustomSObject struct {
	sobjects.BaseSObject
	
	Active    bool   `force:"Active__c"`
	AccountId string `force:"Account__c"`
}

func (t *SomeCustomSObject) ApiName() string {
	return "SomeCustomObject__c"
}

type SomeCustomSObjectQueryResponse struct {
	sobjects.BaseQuery

	Records []*SomeCustomSObject `force:"records"`
}

func main() {
	// Init the force
	forceApi, err := force.Create(
		"YOUR-API-VERSION",
		"YOUR-CLIENT-ID",
		"YOUR-CLIENT-SECRET",
		"YOUR-USERNAME",
		"YOUR-PASSWORD",
		"YOUR-SECURITY-TOKEN",
		"YOUR-ENVIRONMENT",
	)
	if err != nil {
		log.Fatal(err)
	}

	// Get somCustomSObject by ID
	someCustomSObject := &SomeCustomSObject{}
	err = forceApi.GetSObject("Your-Object-ID", nil, someCustomSObject)
	if err != nil {
		fmt.Println(err)
	}

	fmt.Printf("%#v", someCustomSObject)

	// Query
	someCustomSObjects := &SomeCustomSObjectQueryResponse{}
	err = forceApi.Query("SELECT Id FROM SomeCustomSObject__c LIMIT 10", someCustomSObjects)
	if err != nil {
		fmt.Println(err)
	}

	fmt.Printf("%#v", someCustomSObjects)
}

Documentation

About

Go (golang) library for calling Salesforce.com (force.com) web api's

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%