'Programming'에 해당되는 글 1759건

  1. 2022.04.06 go 모듈 불러오기
  2. 2022.04.04 golang 다른 파일 함수 불러오기
  3. 2022.04.04 liteide
  4. 2022.03.31 golang gore(repl), delve
  5. 2022.03.31 go build 옵션
  6. 2022.03.25 웹소켓
  7. 2022.03.15 python interactive mode
  8. 2022.03.14 python3 opencv2 checker board
  9. 2022.03.14 cv2.imshow cv2.waitKey
  10. 2022.03.14 pdb
Programming/golang2022. 4. 6. 10:50

아따 어렵다 -_- 다른 동료 도움을 받아서 해결

 

일단 아래의 기본 구조를 따라가고

serial.go와 tcp.go는 이름만 거창하지 그냥 fmt.Println("hello serial world") 출력하는 테스트 코드만 들어있다.

$ tree
.
├── go.mod
├── internal
│   └── util
│       ├── serial.go
│       └── tcp.go
├── main
├── main.go
├── pkg
│   └── mod
│       └── cache
│           └── lock
└── web
    ├── img
    ├── index.html
    └── style.css

7 directories, 8 files

 

go build 하면 에러가 발생하고

go mod init 프로젝트 명   으로 모듈을 초기화 해주고 나서 다시 빌드하면 문제없이 빌드된다.

go mod tidy는 먼지 조금더 찾아봐야 할 듯.

$ go build main.go
main.go:6:2: package l2s/internal/util is not in GOROOT (/usr/lib/go-1.17/src/l2s/internal/util)

$ go mod init test
go: creating new go.mod: module test
go: to add module requirements and sums:
        go mod tidy

$ go build main.go

 

go mod init 하면서 GOMOD 경로가 변경되는 듯.

$ go env | grep GOMOD
GOMODCACHE="/home/minimonk/pkg/mod"
GOMOD="/home/minimonk/src/l2s/go.mod"

 

테스트 해보니 현재 빌드 경로에서 벗어나면 GOMOD 값이 변경된다. 신기하네..

$ go env | grep GOMOD
GOMODCACHE="/home/minimonk/pkg/mod"
GOMOD="/dev/null"

 

함수명이 대문자로 시작해야 외부에서 호출 가능한... public 함수라고 해야하나?

go 키워드를 찾아봐야겠네.

 Go에서는 대문자로 된 변수명은 패키지 외부에서 사용 할 수 있다라는 기능적 의미를 가지고 있어서 사용자가 이해하기 쉬운 측면이 있다.

[링크 : https://blog.billo.io/devposts/golang_naming_convention/]

 

아래와 같은 디렉토리들로 기본 구성되고 src는 있어서는 안된다고 한다.

/cmd (메인을 여기에?) 
/internal (메인에서 호출한 사용자 작성 모듈들을 여기에?)
/pkg (외부 종속성 추가)
/vendor

/api
/web

/configs
/init
/scripts

[링크 : https://github.com/golang-standards/project-layout/blob/master/README_ko.md]

'Programming > golang' 카테고리의 다른 글

golang type 변환, type 확인하기  (0) 2022.04.07
go 변수, 상수, 배열  (0) 2022.04.06
golang 다른 파일 함수 불러오기  (0) 2022.04.04
liteide  (0) 2022.04.04
golang gore(repl), delve  (0) 2022.03.31
Posted by 구차니
Programming/golang2022. 4. 4. 19:06

c 언어에서 처럼 다른파일의 함수를 빌드해서 끌어오는 법 찾는 중

 

[링크 : https://stackoverflow.com/questions/26942150/importing-go-files-in-same-folder]

[링크 : https://linguinecode.com/post/how-to-import-local-files-packages-in-golang]

 

[링크 : https://surpassing.tistory.com/417]

'Programming > golang' 카테고리의 다른 글

go 변수, 상수, 배열  (0) 2022.04.06
go 모듈 불러오기  (0) 2022.04.06
liteide  (0) 2022.04.04
golang gore(repl), delve  (0) 2022.03.31
go build 옵션  (0) 2022.03.31
Posted by 구차니
Programming/golang2022. 4. 4. 14:56

ubuntu 18.04에 gqrx를 먼저 깔면서 qt5가 추가된 것 같긴한데

예전의 QT가 아닌지 빠릿빠릿하게 실행되는 느낌!

 

아무튼 golang 용 ide인데 api 조회가 쉬우면 좋겠네

[링크 : http://liteide.org/en/]

[링크 : https://streamls.tistory.com/54]

 

$ sudo snap install liteide-tpaw

[링크 : https://ubunlog.com/ko/go를위한-liteide-개발-환경/]

'Programming > golang' 카테고리의 다른 글

go 모듈 불러오기  (0) 2022.04.06
golang 다른 파일 함수 불러오기  (0) 2022.04.04
golang gore(repl), delve  (0) 2022.03.31
go build 옵션  (0) 2022.03.31
go lang static http server  (0) 2022.03.10
Posted by 구차니
Programming/golang2022. 3. 31. 23:52

node.js나 python 같은 인터프리트 언어가 대세라 그런가..

컴파일 언어를 인터프리트 언어 처럼 쓰게 해주는 환경이라니..

REPL(read-eval-print loop)

[링크 : https://github.com/x-motemen/gore]

[링크 : https://gorepl.com/]

[링크 : https://tkim.info/ko/devnote/d054-gore쓰다가-답답해서-tour-of-go-설치해서-쓴-썰/]

 

delve는 디버거 패키지.. 아니 툴이라고 해야하나?

[링크 : https://www.joinc.co.kr/w/man/12/golang/delve]

'Programming > golang' 카테고리의 다른 글

golang 다른 파일 함수 불러오기  (0) 2022.04.04
liteide  (0) 2022.04.04
go build 옵션  (0) 2022.03.31
go lang static http server  (0) 2022.03.10
go hello world build static / shared  (0) 2022.02.17
Posted by 구차니
Programming/golang2022. 3. 31. 19:05

gcc와 유사한 옵션들이군..

 

-o 옵션을 통해 실행파일 이름을 지정할 수 있는데, 지정하지 않을 경우 소스코드의 이름을 출력이름으로 지정한다.

go build [-o output] [build flags] [packages]

[링크 : https://pkg.go.dev/cmd/go]

 

 

$ go build -linkshared filename.go

옵션을 통해 빌드할때

open /usr/lib/go-1.17/pkg/linux_amd64_dynlink/archive/zip.shlibname: permission denied

권한이 부족해서 거부되었다는 에러가 발생하는데 대개는 sudo를 주고 하지만

왜 발생하나 궁금해서 찾아보니

dynlink에 파일들이 linkshared 옵션으로 빌드할때 날짜가 변경되는 것으로 보인다.

*.a 나 libstd.so 들 역시 변경되는걸 봐서는 linkshared로 빌드할때 해당 so도 같이 빌드 하는 듯.

[링크 : https://superuser.com/questions/739738/how-to-use-go-get-as-non-root]

 

dynlink 에서 GOROOT라는 변수가 보이길래 보는데 선언된건 없고..

$ cd $GOROOT/pkg/linux_amd64_dynlink
$ ls libstd.so
libstd.so

[링크 : https://www.codestudyblog.com/cs2112goa/1212131010.html]

 

도움말 보다보니 env라는 명령어 발견

$ go --help
Go is a tool for managing Go source code.

Usage:

        go <command> [arguments]

The commands are:

        bug         start a bug report
        build       compile packages and dependencies
        clean       remove object files and cached files
        doc         show documentation for package or symbol
        env         print Go environment information
        fix         update packages to use new APIs
        fmt         gofmt (reformat) package sources
        generate    generate Go files by processing source
        get         add dependencies to current module and install them
        install     compile and install packages and dependencies
        list        list packages or modules
        mod         module maintenance
        run         compile and run Go program
        test        test packages
        tool        run specified go tool
        version     print Go version
        vet         report likely mistakes in packages

Use "go help <command>" for more information about a command.

Additional help topics:

        buildconstraint build constraints
        buildmode       build modes
        c               calling between Go and C
        cache           build and test caching
        environment     environment variables
        filetype        file types
        go.mod          the go.mod file
        gopath          GOPATH environment variable
        gopath-get      legacy GOPATH go get
        goproxy         module proxy protocol
        importpath      import path syntax
        modules         modules, module versions, and more
        module-get      module-aware go get
        module-auth     module authentication using go.sum
        packages        package lists and patterns
        private         configuration for downloading non-public code
        testflag        testing flags
        testfunc        testing functions
        vcs             controlling version control with GOVCS

Use "go help <topic>" for more information about that topic.

 

$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/minimonk/.cache/go-build"
GOENV="/home/minimonk/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/minimonk/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/minimonk/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.17"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.17/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.8"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1772520358=/tmp/go-build -gno-record-gcc-switches"

 

저 놈의 GOTOOLDIR을 바꾸어 주면 되려나?

 

GOOS와 GOARCH를 이용해서 크로스컴파일 가능하다고 한다.

$ env GOOS=windows GOARCH=amd64 go build source.go

[링크 : https://www.digitalocean.com/community/tutorials/how-to-build-go-executables-for-multiple-platforms-on-ubuntu-16-04]

 

이게 되네..

$ GOARCH=arm go build hello.go
$ file hello
hello: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, not stripped

$ GOARCH=arm64 go build hello.go
$ file hello
hello: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, not stripped

 

'Programming > golang' 카테고리의 다른 글

liteide  (0) 2022.04.04
golang gore(repl), delve  (0) 2022.03.31
go lang static http server  (0) 2022.03.10
go hello world build static / shared  (0) 2022.02.17
go lang rest  (0) 2022.02.11
Posted by 구차니
Programming/node.js2022. 3. 25. 17:43

전에 보기만 했지 다뤄본적은 없는데 크윽..

일단 웹을 통해서 소켓을 만드니까.. HTTPS 하면 자동으로 보안도 올라가고

릴레이 해주면 websocket - socket 도 가능하고..

 

[링크 : https://www.npmjs.com/package/websocket]

[링크 : https://niceman.tistory.com/109]

'Programming > node.js' 카테고리의 다른 글

node.js 웹소켓 채팅 서버 예제  (0) 2022.07.14
ubuntu 18.04 / nodej.s 18.x 실패  (0) 2022.05.19
broadway / jsmpeg  (0) 2020.09.16
node.js array.sort() 주의사항  (0) 2020.02.01
node.js postgresql transaction  (0) 2020.01.31
Posted by 구차니

별건 아니고 그냥

python 실행해서 뜨는 프롬프트에서 입력해서 실행하는 모드

 

[링크 : https://en.m.wikibooks.org/wiki/Python_Programming/Interactive_mode]

[링크 : https://stackabuse.com/python-programming-in-interactive-vs-script-mode/]

 

'Programming > python(파이썬)' 카테고리의 다른 글

python openCV / PIL 포맷 변경  (0) 2022.04.12
파이썬 딕셔너리 변수 생성과 리턴 enumerate, zip  (0) 2022.04.12
python3 opencv2 checker board  (0) 2022.03.14
pdb  (0) 2022.03.14
python debug (pdb)  (0) 2022.03.04
Posted by 구차니

나중에 따라해.. 봐야지 ㅠㅠ

 

[링크 : http://www.gisdeveloper.co.kr/?p=6868]

'Programming > python(파이썬)' 카테고리의 다른 글

파이썬 딕셔너리 변수 생성과 리턴 enumerate, zip  (0) 2022.04.12
python interactive mode  (0) 2022.03.15
pdb  (0) 2022.03.14
python debug (pdb)  (0) 2022.03.04
opencv python  (0) 2022.02.25
Posted by 구차니
Programming/openCV2022. 3. 14. 19:38

imshow만 하면 검은 창만 비어서 나오는데

waitKey()로 메시지 루프(?)를 돌리지 않아서 그렇다고 한다.

 

[링크 : https://stackoverflow.com/questions/21810452]

'Programming > openCV' 카테고리의 다른 글

opencv cv2.imshow() error  (0) 2024.01.16
opencv를 이용한 다중 템플릿 추적  (0) 2024.01.15
virtual mouse  (0) 2022.01.25
opencv-3.4.0 어플리케이션 빌드  (0) 2021.01.14
opencv face detect  (0) 2019.05.10
Posted by 구차니

pdb

 

$ pdb chcker.py 
> /home/minimonk/src/py/chcker.py(1)<module>()
-> import numpy as np
(Pdb) run
Restarting chcker.py with arguments:

> /home/minimonk/src/py/chcker.py(1)<module>()
-> import numpy as np
(Pdb) list
  1  -> import numpy as np
  2   import cv2
  3   import glob
  4   # termination criteria
  5   criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
  6   # prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(6,5,0)
  7   objp = np.zeros((6*7,3), np.float32)
  8   objp[:,:2] = np.mgrid[0:7,0:6].T.reshape(-1,2)
  9   # Arrays to store object points and image points from all the images.
 10   objpoints = [] # 3d point in real world space
 11   imgpoints = [] # 2d points in image plane.
(Pdb) n
> /home/minimonk/src/py/chcker.py(2)<module>()
-> import cv2
(Pdb) n
ImportError: 'No module named cv2'
> /home/minimonk/src/py/chcker.py(2)<module>()
-> import cv2
(Pdb) q

 

$ whereis pdb
pdb: /usr/bin/pdb2.7 /usr/bin/pdb /usr/bin/pdb3.6 /usr/share/man/man1/pdb.1.gz

$ ls -al /usr/bin/pdb*
lrwxrwxrwx 1 root root  6  4월 16  2018 /usr/bin/pdb -> pdb2.7
lrwxrwxrwx 1 root root 23  2월 28  2021 /usr/bin/pdb2.7 -> ../lib/python2.7/pdb.py
lrwxrwxrwx 1 root root  6  1월 28 12:37 /usr/bin/pdb3 -> pdb3.6
lrwxrwxrwx 1 root root 23 12월  9 06:08 /usr/bin/pdb3.6 -> ../lib/python3.6/pdb.py

$ ls -al /usr/lib/python3.
python3.6/ python3.7/ python3.8/ 

$ ls -al /usr/lib/python3.6/pdb.py 
-rwxr-xr-x 1 root root 61310 12월  9 06:08 /usr/lib/python3.6/pdb.py

[링크 : https://docs.python.org/ko/3.7/library/pdb.html]

'Programming > python(파이썬)' 카테고리의 다른 글

python interactive mode  (0) 2022.03.15
python3 opencv2 checker board  (0) 2022.03.14
python debug (pdb)  (0) 2022.03.04
opencv python  (0) 2022.02.25
python / opencv mouse event  (0) 2022.02.25
Posted by 구차니