func GetComposerArchive(src []byte, repoUUID, repoRef string) ([]byte, error) {
	cacheKey := fmt.Sprintf("archive_%s_%s", repoUUID, repoRef)
	if repoRef != "master" {
		if item, ok := globalCache.Get(cacheKey); ok {
			if archive, ok := item.([]byte); ok {
				log.Printf("Cache hit: archive-lru %s # %s", repoUUID, repoRef)
				return archive, nil
			} else {
				globalCache.Remove(cacheKey)
				return nil, fmt.Errorf("Cache broken: archive-lru %s # %s", repoUUID, repoRef)
			}
		}
	}
	log.Printf("Cache miss: archive-lru %s # %s", repoUUID, repoRef)
	u := uuid.NewV4().String()
	t := os.TempDir()
	tarBeforeRenameDir := filepath.Join(t, fmt.Sprintf("dir_%s", u))
	tarDestinationFile := filepath.Join(t, fmt.Sprintf("%s.tar", u))
	tarDestinationDir := filepath.Join(t, fmt.Sprintf("dir_%s", u))
	zipDestinationFile := filepath.Join(t, fmt.Sprintf("%s.zip", u))
	if err := unGzip(src, tarDestinationFile); err != nil {
		return nil, err
	}
	tarArchive, err := getFileContents(tarDestinationFile)
	os.Remove(tarDestinationFile)
	if err != nil {
		return nil, err
	}
	if err := unTar(tarArchive, tarDestinationDir); err != nil {
		return nil, err
	}
	files, err := ioutil.ReadDir(tarDestinationDir)
	if err != nil {
		return nil, err
	}
	if len(files) != 1 {
		return nil, errors.New("Broken archive received from GitLab")
	}
	oldPath := filepath.Join(tarBeforeRenameDir, files[0].Name())
	tarDestinationDir = filepath.Join(tarBeforeRenameDir, fmt.Sprintf("%s-%s", repoUUID, repoRef))
	if err := os.Rename(oldPath, tarDestinationDir); err != nil {
		return nil, err
	}
	err = makeZip(tarDestinationDir, zipDestinationFile)
	os.RemoveAll(tarBeforeRenameDir)
	if err != nil {
		return nil, err
	}
	composerArchive, err := getFileContents(zipDestinationFile)
	os.Remove(zipDestinationFile)
	if err != nil {
		return nil, err
	}
	if repoRef != "master" {
		globalCache.Add(cacheKey, composerArchive)
	}
	return composerArchive, nil
}
Note:

GitLab serves repository archive as tar.gz archive, so, for composer:
* repack gitlab archive: ungzip -> untar -> zip
* during repack, set directory and file mtime/atime to predefined constant
* cleanup all temporary files and directories
* cache archive bytes
* return zip archive bytes
package helpers
import (
	"archive/tar"
	"bytes"
	"compress/gzip"
	"crypto/sha1"
	"errors"
	"fmt"
	"github.com/hashicorp/golang-lru"
	"github.com/jhoonb/archivex"
	"github.com/satori/go.uuid"
	"io"
	"io/ioutil"
	"log"
	"os"
	"path/filepath"
	"time"
)
var (
	globalCache, _ = lru.New(2048)
	archiveTime    = time.Date(2016, time.October, 16, 23, 0, 0, 0, time.UTC)
)
func GetNpmArchiveFromCache(repoUUID, repoRef string) ([]byte, error) {
	cacheKey := fmt.Sprintf("archive_%s_%s", repoUUID, repoRef)
	if item, ok := globalCache.Get(cacheKey); ok {
		if archive, ok := item.([]byte); ok {
			log.Printf("Cache hit: archive-lru %s # %s", repoUUID, repoRef)
			return archive, nil
		} else {
			globalCache.Remove(cacheKey)
			return nil, fmt.Errorf("Cache broken: archive-lru %s # %s", repoUUID, repoRef)
		}
	}
	return nil, fmt.Errorf("No cache found: archive-lru %s # %s", repoUUID, repoRef)
}
func PutNpmArchiveToCache(src []byte, repoUUID, repoRef string) ([]byte, string, error) {
	if npmArchive, err := GetNpmArchiveFromCache(repoUUID, repoRef); err == nil {
		log.Printf("Cache hit: archive-lru %s # %s", repoUUID, repoRef)
		return npmArchive, fmt.Sprintf("%x", sha1.Sum(npmArchive)), nil
	}
	log.Printf("Cache miss: archive-lru %s # %s", repoUUID, repoRef)
	u := uuid.NewV4().String()
	t := os.TempDir()
	tarBeforeRenameDir := filepath.Join(t, fmt.Sprintf("dir_%s", u))
	tarDestinationFile := filepath.Join(t, fmt.Sprintf("%s.tar", u))
	tarDestinationDir := filepath.Join(t, fmt.Sprintf("dir_%s", u))
	tgzDestinationFile := filepath.Join(t, fmt.Sprintf("%s.tgz", u))
	if err := unGzip(src, tarDestinationFile); err != nil {
		return nil, "", err
	}
	tarArchive, err := getFileContents(tarDestinationFile)
	os.Remove(tarDestinationFile)
	if err != nil {
		return nil, "", err
	}
	if err := unTar(tarArchive, tarDestinationDir); err != nil {
		return nil, "", err
	}
	files, err := ioutil.ReadDir(tarDestinationDir)
	if err != nil {
		return nil, "", err
	}
	if len(files) != 1 {
		return nil, "", errors.New("Broken archive received from GitLab")
	}
	oldPath := filepath.Join(tarBeforeRenameDir, files[0].Name())
	tarDestinationDir = filepath.Join(tarBeforeRenameDir, fmt.Sprintf("%s-%s", repoUUID, repoRef))
	if err := os.Rename(oldPath, tarDestinationDir); err != nil {
		return nil, "", err
	}
	err = makeTar(tarDestinationDir, tarDestinationFile)
	os.RemoveAll(tarBeforeRenameDir)
	if err != nil {
		return nil, "", err
	}
	tarArchive, err = getFileContents(tarDestinationFile)
	os.Remove(tarDestinationFile)
	if err != nil {
		return nil, "", err
	}
	if err := makeGzip(tarArchive, tgzDestinationFile); err != nil {
		return nil, "", err
	}
	npmArchive, err := getFileContents(tgzDestinationFile)
	os.Remove(tgzDestinationFile)
	if err != nil {
		return nil, "", err
	}
	if repoRef != "master" {
		cacheKey := fmt.Sprintf("archive_%s_%s", repoUUID, repoRef)
		globalCache.Add(cacheKey, npmArchive)
	}
	return npmArchive, fmt.Sprintf("%x", sha1.Sum(npmArchive)), nil
}