아카이브
close
프로필 사진

아카이브

github: @denev6

  • 모두 보기 (158)
    • 일기장 (12)
    • AI (32)
      • study (9)
    • 프로그래밍 언어 (54)
      • Python (30)
      • Go (12)
      • C++ (9)
    • 기타 주제 (28)
      • 웹 (23)
  • 소개
  • 프로젝트
  • 일기장

Go - testing

Go는 testing을 통해 테스트 코드 작성을 지원한다. 테스트를 수행할 테스트 파일은 _test.go 형식의 파일 이름을 가져야 한다. (예: cv_test.go) import "testing" Test func Test함수이름(t *testing.T) { res := 함수(...) if res != 결과 { t.Errorf("...") } } 테스트를 수행할 함수는 Test로 시작하고, *testing.T를 파라미터로 받는다. 예: func RepeatAdd(n int) int { i := 0 for j := 1; j

  • format_list_bulleted 프로그래밍 언어/Go
  • · 2022. 11. 11.

Go루틴을 활용한 비동기 처리

Asynchronous Non-blocking 작업 - Synchronous vs Asynchronous - Blocking vs Non-Blocking - Asynchronous Non-blocking Request Sync / Async 두 항목을 나누는 기준은 요청한 작업이 진행되는 순서이다. Synchronous - 동기: 요청된 작업이.. denev6.tistory.com 위 글에서 설명했듯이 비동기 처리는 속도와 효율성 면에서 큰 이점을 가진다. 그리고 Go는 이러한 비동기 루틴 실행을 아주아주아주 쉽게 할 수 있다. Go 루틴 Go의 루틴은 2KB 스택 공간만을 사용하기 때문에 가볍고, 하나의 코어 당 하나의 OS 스레드만 할당하기 때문에 스레드의 컨텍스트 스위칭 비용이 발생하지 않는다. g..

  • format_list_bulleted 프로그래밍 언어/Go
  • · 2022. 11. 9.

Go - map, list, queue, stack

map Go에서 기본으로 제공하는 map은 Hash Map 구조를 가진다. // map[키]값 dict := map[int]string{ 1: "one", 2: "two", } dict[3] = "three" {중괄호} 안에서 초기화하거나 키를 이용해 값을 삽입할 수 있다. dict := map[int]string{ 1: "one", 2: "two", } val, exist := dict[5] if !exist { fmt.Println("dict[5] doesn't exist") } else { fmt.Println(val) } // dict[5] doesn't exist 키로 값을 가져올 때, 값과 존재 여부를 반환한다. for key, value := range dict { fmt.Printf("%d..

  • format_list_bulleted 프로그래밍 언어/Go
  • · 2022. 11. 6.

Go - defer, panic, recover

defer defer는 함수가 종료될 때 실행한다. func Test() { fmt.Println("--Begin--") defer fmt.Println("111") defer fmt.Println("222") defer fmt.Println("333") fmt.Println("--End--") /* --Begin-- * --End-- * 333 * 222 * 111 */ } defer 문이 '--End--'보다 먼저 선언되었지만 함수 마지막에 실행된다. defer 문이 여러 개일 때는 stack처럼 동작된다. panic panic은 오류가 발생했을 때 프로그램을 중지시키고 defer 문이 실행된다. func WriteTxt(file, sentence string) { f, err := os.Create..

  • format_list_bulleted 프로그래밍 언어/Go
  • · 2022. 11. 3.

Go - Interface

Interface 인터페이스는 OOP에서 다형성을 형성하고 결합도를 낮추기 위해 사용되는 추상화 기법이다. type SampleInterface interface { PrintMember() // Method(s string) // Method(n1, n2 int) int } type ABInterface interface { AInterface BInterface } interface 명령어를 통해 인터페이스를 생성한다. 일반적으로 내부에 구현될 메서드를 선언해야 한다. 그런데 인터페이스 내부에 인터페이스를 담기도 한다. Interface 기본값 interface는 추상화된 개념이기 때문에 그 자체로는 nil 타입을 가진다. func main() { var itf SampleInterface fmt.P..

  • format_list_bulleted 프로그래밍 언어/Go
  • · 2022. 11. 1.

Python 3.11 업데이트

except* & ExceptionGroup except*와 ExceptionGroup이라는 새로운 문법이 추가되었다. try: raise ExceptionGroup("Group1", [TypeError("a"), ValueError("b")]) except* TypeError as e: print(f"Error: {e!r}") except* ValueError as e: print(f"Error: {e!r}") """ Error: ExceptionGroup('Group1', [TypeError('a')]) Error: ExceptionGroup('Group1', [ValueError('b')]) """ ExceptionGroup을 통해 여러 에러를 동시에 처리할 수 있도록 하는 것이 가능해졌다. exp..

  • format_list_bulleted 프로그래밍 언어/Python
  • · 2022. 10. 25.
  • navigate_before
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • ···
  • 9
  • navigate_next
전체 카테고리
  • 모두 보기 (158)
    • 일기장 (12)
    • AI (32)
      • study (9)
    • 프로그래밍 언어 (54)
      • Python (30)
      • Go (12)
      • C++ (9)
    • 기타 주제 (28)
      • 웹 (23)
Copyright © denev6 모든 권리 보유.
SKIN: Copyright © 쭈미로운 생활 All rights reserved. Designed by JJuum.
and Current skin "dev-roo" is modified by Jin.

티스토리툴바