github.com/thlcodes/genfig@v0.3.2-alpha/example/config/plugin_write_to_env.go (about)

     1  // Code generated by genfig plugin 'write_to_env'; DO NOT EDIT.
     2  
     3  package config
     4  
     5  import (
     6  	"encoding/json"
     7  	"fmt"
     8  	"io"
     9  	"os"
    10  )
    11  
    12  var (
    13  	_ = os.Setenv
    14  	_ = fmt.Sprintf
    15  	_ = json.Marshal
    16  )
    17  
    18  func (c *Config) WriteToEnv() {
    19  	var buf []byte
    20  	_ = buf
    21  
    22  	_ = os.Setenv("APIS_GOOGLE_URI", fmt.Sprintf("%v", c.Apis.Google.Uri))
    23  
    24  	_ = os.Setenv("DB_PASS", fmt.Sprintf("%v", c.Db.Pass))
    25  
    26  	_ = os.Setenv("DB_URI", fmt.Sprintf("%v", c.Db.Uri))
    27  
    28  	_ = os.Setenv("DB_USER", fmt.Sprintf("%v", c.Db.User))
    29  
    30  	buf, _ = json.Marshal(c.EmptyArray)
    31  	_ = os.Setenv("EMPTYARRAY", string(buf))
    32  
    33  	buf, _ = json.Marshal(c.List)
    34  	_ = os.Setenv("LIST", string(buf))
    35  
    36  	_ = os.Setenv("LONGDESC_DE", fmt.Sprintf("%v", c.LongDesc.De))
    37  
    38  	_ = os.Setenv("LONGDESC_EN", fmt.Sprintf("%v", c.LongDesc.En))
    39  
    40  	_ = os.Setenv("PROJECT", fmt.Sprintf("%v", c.Project))
    41  
    42  	_ = os.Setenv("RANDOMIZER_THRESHOLD", fmt.Sprintf("%v", c.Randomizer.Threshold))
    43  
    44  	buf, _ = json.Marshal(c.Secrets)
    45  	_ = os.Setenv("SECRETS", string(buf))
    46  
    47  	_ = os.Setenv("SERVER_HOST", fmt.Sprintf("%v", c.Server.Host))
    48  
    49  	_ = os.Setenv("SERVER_PORT", fmt.Sprintf("%v", c.Server.Port))
    50  
    51  	_ = os.Setenv("VERSION", fmt.Sprintf("%v", c.Version))
    52  
    53  	_ = os.Setenv("WIP", fmt.Sprintf("%v", c.Wip))
    54  
    55  }
    56  
    57  func (c *Config) PrintDebugEnvs(w io.Writer) {
    58  	var buf []byte
    59  	_ = buf
    60  
    61  	fmt.Fprintf(w, "APIS_GOOGLE_URI/apis.google.uri='%v'\n", c.Apis.Google.Uri)
    62  
    63  	fmt.Fprintf(w, "DB_PASS/db.pass='%v'\n", c.Db.Pass)
    64  
    65  	fmt.Fprintf(w, "DB_URI/db.uri='%v'\n", c.Db.Uri)
    66  
    67  	fmt.Fprintf(w, "DB_USER/db.user='%v'\n", c.Db.User)
    68  
    69  	buf, _ = json.Marshal(c.EmptyArray)
    70  	fmt.Fprintf(w, "EMPTYARRAY/emptyarray='%v'\n", string(buf))
    71  
    72  	buf, _ = json.Marshal(c.List)
    73  	fmt.Fprintf(w, "LIST/list='%v'\n", string(buf))
    74  
    75  	fmt.Fprintf(w, "LONGDESC_DE/longdesc.de='%v'\n", c.LongDesc.De)
    76  
    77  	fmt.Fprintf(w, "LONGDESC_EN/longdesc.en='%v'\n", c.LongDesc.En)
    78  
    79  	fmt.Fprintf(w, "PROJECT/project='%v'\n", c.Project)
    80  
    81  	fmt.Fprintf(w, "RANDOMIZER_THRESHOLD/randomizer.threshold='%v'\n", c.Randomizer.Threshold)
    82  
    83  	buf, _ = json.Marshal(c.Secrets)
    84  	fmt.Fprintf(w, "SECRETS/secrets='%v'\n", string(buf))
    85  
    86  	fmt.Fprintf(w, "SERVER_HOST/server.host='%v'\n", c.Server.Host)
    87  
    88  	fmt.Fprintf(w, "SERVER_PORT/server.port='%v'\n", c.Server.Port)
    89  
    90  	fmt.Fprintf(w, "VERSION/version='%v'\n", c.Version)
    91  
    92  	fmt.Fprintf(w, "WIP/wip='%v'\n", c.Wip)
    93  
    94  }