일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- stringprintf
- template
- web
- ranges
- kotlin
- SHA512
- design pattern
- CustomTab
- haskell
- sprintf
- program
- Reflect
- c++
- traits
- SHA1
- Observer
- go
- Android
- WebView
- RAII
- Scala
- async
- sha256
- ChromeTab
- Clojure
- coroutines
- type_traits
- Chrono
- Functional
- AES
- Today
- Total
목록go (4)
프로그래밍 검색 블로그
go 에서 기본으로 제공하고 있는 패키지 중에 다른 언어에는 기본적으로는 없는 유용한 패키지중의 하나가 context 이다 context.Background() 기본적으로 Background()를 제외한 다른 context들은 다른 context를 받는데 기능 상으로 해당 인자로 준 context를 상속 받는다고 생각하면 된다 context의 동작은 조건이 충족되지 않을 시에는 Err() 함수의 반환값을 통해서 알 수 있다간단하게 nil이 아니면 에러 db 연결 부분은 제외하고 context만 사용하는 간단한 예제func main() { ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) defer cancel() //cance..
package main import ( "crypto/aes" "crypto/cipher" "crypto/rand" "encoding/base64" "fmt" "io" ) type AESCipher struct { block cipher.Block } func NewAesCipher(key []byte) (*AESCipher, error) { block, err := aes.NewCipher(key) if err != nil { return nil, err } return &AESCipher{block}, nil } func (a *AESCipher) EncryptString(s string) string { byteString := []byte(s) encryptByteArray := make([]by..
package main import ( "fmt" "reflect" ) type controller struct { } func (c controller) Foo(a int, b string) string { fmt.Println("Foo") return fmt.Sprint(a, b) } func (c controller) Koo(a int, b string) string { fmt.Println("Koo") return fmt.Sprint(a, b) } func (c controller) goo() { //private는 안보임 } //reflection으로 함수 호출할때는 일반 인자 대신 reflect.Value를 넣는다 func valueToReflectionArguments(args ...inte..
package main import ( "archive/zip" "io" "io/ioutil" "os" "path/filepath" ) // ZipDir 폴더를 지정해서 그 폴더 안에 있는 파일들을 // saveFile에 저장합니다 // error nil 압축성공 // 그외: 압축 실패 func ZipDir(saveFile *os.File, savePath string) error { zipWriter := zip.NewWriter(saveFile) defer zipWriter.Close() z := zipType{zipWriter} return z.dir(savePath, "") } func main() { //실행 파일과 같은 위치에 있는 test폴더 안에 있는 요소를 //result.zip으로 압축..