티스토리 뷰
package main
import (
"os"
"strings"
"text/template"
)
func Format(s string, v interface{}) string {
t, b := new(template.Template), new(strings.Builder)
template.Must(t.Parse(s)).Execute(b, v)
result := b.String()
if result == "<no value>" {
return s
}
return result
}
func KeyValue(item string) (key, val string) {
splits := strings.Split(item, "=")
key = splits[0]
val = splits[1]
return
}
func Env() map[string]string {
data := os.Environ()
items := make(map[string]string)
for _, item := range data {
key, val := KeyValue(item)
items[key] = val
}
return items
}
func main() {
response := Format("{{ .asdf }}", Env())
println(response)
}
https://stackoverflow.com/questions/19612449/default-value-in-gos-method
Default value in Go's method
Is there a way to specify default value in Go's function? I am trying to find this in the documentation but I can't find anything that specifies that this is even possible. func SaySomething(i str...
stackoverflow.com
https://stackoverflow.com/questions/19761393/why-does-go-have-typed-nil
Why does Go have typed nil?
Why does Go have typed nil? It throws an explicit interface conformation check for convenience. What's the problem of untyped nil and what did the designers want to solve with typed nil?
stackoverflow.com
https://gist.github.com/naveensrinivasan/5846791
Here is a code to get the environment variables as a map in go instead of slice.
Here is a code to get the environment variables as a map in go instead of slice. - environmentasmap.go
gist.github.com
'공부' 카테고리의 다른 글
[aws] s3 cp github action (workflow) (0) | 2022.08.31 |
---|---|
[MySQL] id 컬럼 데이터타입 INT? BIGINT? (0) | 2022.08.31 |
[aws] ECR docker login & pull (0) | 2022.08.23 |
Dockerfile': group id '1849965015' is too big ( > 2097151 ). Use STAR or POSIX extensions to overcome this limit (0) | 2022.08.22 |
[aws][s3] bucket lifecycle (0) | 2022.08.22 |
- Total
- Today
- Yesterday
- 레퍼럴
- 김달
- 클루지
- 테슬라
- 메디파크 내과 전문의 의학박사 김영수
- 테슬라 리퍼럴 코드 혜택
- Bot
- 팔로워 수 세기
- 모델y
- 테슬라 레퍼럴 코드 확인
- 책그림
- 테슬라 리퍼럴 코드 생성
- 개리마커스
- 유투브
- Kluge
- 어떻게 능력을 보여줄 것인가?
- 테슬라 크레딧 사용
- 모델 Y 레퍼럴
- 연애학개론
- wlw
- 테슬라 추천
- COUNT
- 인스타그램
- 테슬라 레퍼럴 적용 확인
- 할인
- 테슬라 리퍼럴 코드
- follower
- 테슬라 레퍼럴
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |