[Go언어] VSCode에서 gopls 에러가 날때

vscode에서 아래와 같은 에러 발생시 gopls requires a module at the root of your workspace. You can work with multiple modules by opening each one as a workspace folder. settings.json 파일에 아래와 같이 추가하고 vscode를 재실행한다. "gopls": { "experimentalWorkspaceModule": true, },

April 16, 2021 · 1 min · icecat471

Hugo syntax highlight 변경

1. 원하는 테마 찾기 highlightjs.org에서 원하는 테마를 찾는다.2. css 찾기 highlightjs github에서 원하는 테마의 css파일 내용을 복사한다.3. 테마 변경 config.yml에 아래의 내용을 추가한다.pygmentsUseClasses:true(Hugo PaperMod 테마 기준)/themes/PaperMod/assests/css/hljs/an-old-hope.min.css 의 내용을 복사한 내용으로 바꾼다.=> 임시적으로 설정한것으로 theme overriding으로 변경 가능한지 찾아봐야 함.

April 16, 2021 · 1 min · icecat471

Hugo 블로그 댓글 기능 추가하기

1. 세팅하기 이곳을 클릭 하여 utterances 사이트로 이동한다.configuration 부분을 따라 utterances app을 설치하고 repository설정을 한다.그 외 Blog Post <=> Issue Mapping, Theme 설정등을 한다.설정을 끝내면 Enalble Utterances 부분에 코드가 생성된다 <script src="https://utteranc.es/client.js" repo="(account)/(repo)" issue-term="pathname" theme="github-dark" crossorigin="anonymous" async> </script> 2. hugo에 적용하기 테마마다 설정 방법이 다른데 내가 사용중인 PaperMod 기준 설정방법이다.ParperMod 깃허브 에서도 확인 가능하다./layouts/partials/comments.html 파일을 만들고 위에서 생성된 코드를 붙여넣기한다.그 후 config.yml 파일에 아래부분을 추가해준다....

April 16, 2021 · 1 min · icecat471

gRPC란?

gRPC란? 구글에서 개발한 RPC 시스템. 기본 개념은 RPC와 동일하지만 HTTP/2 기반으로 양방향 스트리밍 지원.HTTP/2를 사용함으로써 메세지의 압축률과 성능이 좋음.HTTP와 비교 Feature gRPC HTTP APIs with JSON Contract Required (.proto) Optional (OpenAPI) Protocol HTTP/2 HTTP Payload Protobuf (small, binary) JSON (large, human readable) Prescriptiveness Strict specification Loose. Any HTTP is valid. Streaming Client, server, bi-directional Client, server Browser support No (requires grpc-web) Yes Security Transport (TLS) Transport (TLS) Clientcode-generation Yes OpenAPI + third-party tooling gRPC의 장점 1....

April 15, 2021 · 1 min · icecat471

Go언어 log.SetPrefix()

package main import ( "fmt" "log" ) func init() { log.SetPrefix("Blockchain: ") } func main() { fmt.Println("test") log.Println("test") } 실행시켜보면 test Blockchain: 2021/04/15 15:04:03 test

April 15, 2021 · 1 min · icecat471

html 캔버스에 이미지 그리기

<canvas id="myCanvas" width="500" height="800"></canvas> let canvas = document.querySelector('#myCanvas'); let context = canvas.getContext('2d'); // 이미지 로딩 let dragon = new Image(); dragon.src = '이미지 경로'; context.drawImage(dragon, x좌표, y좌표, width, height); setInterval()을 사용해서 특정시간마다 화면을 새로 그릴 수 있다. // 1초마다 새로 그림 setInterval(()=> { context.drawImage(dragon, x좌표, y좌표, width, height); }, 1000); // 1000ms

April 14, 2021 · 1 min · icecat471

Go언어 defer와 panic

출처: 예제로 배우는 Go 프로그래밍 1. defer 특정 문장 혹은 함수를 defer를 호출하는 함수가 return하기 직전에 실행하게 한다. package main import "os" func main() { f, err := os.Open("1.txt") if err != nil { panic(err) } // main 마지막에 파일 close 실행 defer f.Close() // 파일 읽기 bytes := make([]byte, 1024) f.Read(bytes) println(len(bytes)) } 2. panic 함수를 즉시 멈추고 defer를 모두 실행한 뒤 즉시 리턴.이것은 콜스택을 따라 상위함수에도 모두 적용....

April 13, 2021 · 1 min · icecat471

Go언어 flag 패키지를 통한 command-line flag 파싱

golang flag package command-line flag를 파싱해주는 패키지. // flag값에 저장된 int64변수의 주소값 반환 maxValue := flag.Int64("max", 10, "Defines maximum value") /* xxxVar() 함수는 반환값이 없고 첫번째 인자로 변수의 포인터를 넘겨주면 변수에 값을 할당해줌. */ var minValue int64 flag.Int64Var(&minValue, "min", 0, "Defines minimum value") // flag에 command-line 파싱 // 꼭 호출해주어야 함 flag.Parse()

April 12, 2021 · 1 min · icecat471

Go언어 프로젝트 외부의 모듈 import하기

go.mod 파일에서 require ( <모듈명> v0.0.0 ) replace <모듈명> v0.0.0 => ../module // 이런 형태로 경로를 지정해줌

April 12, 2021 · 1 min · icecat471

브라우저에서 유니티 함수 호출하기

참고: Unity Document WebGL build시 생성되는 unityInstance에 메세지를 보내서 호출. unityInstace.SendMessage('오브젝트명', '함수명');

April 12, 2021 · 1 min · icecat471