github.com/khulnasoft-lab/tunnel-db@v0.0.0-20231117205118-74e1113bd007/pkg/utils/utils.go (about)

     1  package utils
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  	"path/filepath"
     7  )
     8  
     9  func CacheDir() string {
    10  	tmpDir, err := os.UserCacheDir()
    11  	if err != nil {
    12  		tmpDir = os.TempDir()
    13  	}
    14  	return filepath.Join(tmpDir, "tunnel-db")
    15  }
    16  
    17  func ConstructVersion(epoch, version, release string) string {
    18  	verStr := ""
    19  	if epoch != "0" && epoch != "" {
    20  		verStr += fmt.Sprintf("%s:", epoch)
    21  	}
    22  	verStr += version
    23  
    24  	if release != "" {
    25  		verStr += fmt.Sprintf("-%s", release)
    26  
    27  	}
    28  	return verStr
    29  }