package module
v0.1.5 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2023 License: Apache-2.0 Imports: 12 Imported by: 1


FolioGo - FOLIO client library for Go

Copyright (C) 2023 Index Data Aps.

This software is distributed under the terms of the Apache License, Version 2.0. See the file "LICENSE" for more information.


FolioGo is a simple Go module to allow the creation of code that manipulate instances of the FOLIO library services platform. For example, a very simple program to list the first 20 usernames, with asterisks next to the active ones, might read as follows:

package main

import "fmt"
import ""

func main() {
	service := foliogo.NewService("")
	session, _ := service.Login("diku", "user-basic-view", "user-basic-view")
	body, _ := session.Fetch0("users?limit=20")

This module is a port of the FolioJS Node package which does the same thing for JavaScript. We need the Go version to become part of the FOLIO module mod-reporting, but it will likely have plenty of other uses.


The API is described in a separate document, The FolioGo API.


The behaviour of the FolioGo library can be modified by the values of the following environment variables:

  • LOGGING_CATEGORIES or LOGCAT -- see Logging below.
  • FOLIOGO_SESSION_TIMEOUT (or FOLIOJS_SESSION_TIMEOUT) -- if defined, the number of seconds after which a new session cookie will be requested. (If not defined, the default is to request a new cookie after half of the lifetime of the old one, which is typically about ten minutes.)


This library uses the tiny but beautiful catlogger library to provide optional logging. This is configured at run-time by the LOGGING_CATEGORIES or LOGCAT environment variable, which is set to a comma-separated list of categories such as op,curl,status. Messages in all the listed categories are logged.

Apart from categories used by log invocations in application code, the following categories are used by the libarary itself:

  • service: log when a new service is created.
  • session: log when a new session is created.
  • op: whenever a high-level Okapi operation is about to be executed, its name and parameters are logged.
  • auth: emits messages when authenticating or re-authenticating a session.
  • curl: whenever an HTTP request is made, the equivalent curl command is logged. This can be useful for reproducing bugs.
  • status: whenever an HTTP response is received, its HTTP status and content-type are logged. The combination of op,status is useful for tracing what a program is doing.
  • response: whenever an HTTP response is received, its content is logged.


Mike Taylor (, for Index Data Aps.



Package foliogo provides a client library for the FOLIO LMS



This section is empty.


This section is empty.


func MakeHTTPError

func MakeHTTPError(status int, method string, url string, addInfo string) *httpError


type Hash

type Hash map[string]interface{}

Hash is useful for writing out complex constants for JSON serialization

type RequestParams

type RequestParams struct {
	Method string
	Body   string
	Json   interface{}
	Token  string

type Service

type Service struct {
	// contains filtered or unexported fields

func NewService

func NewService(url string) Service

func (Service) Log

func (this Service) Log(cat string, args ...string)

func (Service) Login

func (this Service) Login(tenant string, username string, password string) (Session, error)

func (Service) ResumeSession added in v0.1.5

func (this Service) ResumeSession(tenant string) (Session, error)

func (Service) String

func (this Service) String() string

type Session

type Session struct {
	// contains filtered or unexported fields

func NewDefaultSession added in v0.0.2

func NewDefaultSession() (Session, error)

func NewSession

func NewSession(service Service, tenant string, username string, password string) (Session, error)

func (*Session) Fetch

func (this *Session) Fetch(path string, params RequestParams) ([]byte, error)

func (*Session) Fetch0 added in v0.1.2

func (this *Session) Fetch0(path string) ([]byte, error)

func (Session) GetTenant added in v0.1.1

func (this Session) GetTenant() string

func (Session) Log

func (this Session) Log(cat string, args ...string)

func (*Session) Login

func (this *Session) Login() error

func (Session) String

func (this Session) String() string


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL