github.com/blend/go-sdk@v1.20220411.3/examples/vault/client/main.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package main
     9  
    10  import (
    11  	"context"
    12  
    13  	"github.com/blend/go-sdk/logger"
    14  	"github.com/blend/go-sdk/vault"
    15  )
    16  
    17  func main() {
    18  	log := logger.All()
    19  	client, _ := vault.New(vault.OptConfigFromEnv(), vault.OptLog(log))
    20  
    21  	key := "cubbyhole/willtest"
    22  
    23  	ctx := context.Background()
    24  
    25  	if err := client.Put(ctx, key, vault.Values{"value": "THE FOOOS"}); err != nil {
    26  		log.Fatal(err)
    27  		return
    28  	}
    29  	if err := client.Put(ctx, key, vault.Values{"value": "THE BUZZ"}); err != nil {
    30  		log.Fatal(err)
    31  		return
    32  	}
    33  
    34  	values, err := client.Get(ctx, key)
    35  	if err != nil {
    36  		log.Fatal(err)
    37  		return
    38  	}
    39  	log.Infof("values: %#v", values)
    40  
    41  	if err := client.Delete(ctx, key); err != nil {
    42  		log.Fatal(err)
    43  		return
    44  	}
    45  	log.Infof("~fin~")
    46  }