반응형

rclone 이란?

 

Rclone

© Nick Craig-Wood 2014-2021 Source file _index.md last updated 2021-10-19 Website hosted on a MEMSET CLOUD VPS, uploaded with rclone and built with Hugo. Logo by @andy23.

rclone.org

  • rsync의 cloud 버전
  • 클라우드 저장소의 파일을 관리하는 CLI도구
  • 주로 클라우드에 대한 동기화나 복사, 미러링 등을 수행할 수 있다.

 

rclone 빌드

Go 가 설치되어있지 않은 분은 아래 글을 참고해 설치해주세요.

https://bmaru.tistory.com/164

 

윈도우 Go(Golang) 설치 / Windows Go(Golang) install

1. Go setup 다운로드 아래 링크에서 설치 파일을 다운로드합니다. https://go.dev/dl/ Downloads - The Go Programming Language Downloads After downloading a binary release suitable for your system, pleas..

bmaru.tistory.com

 

이렇게 하면 rclone.exe 를 얻을 수 있다.

빌드된 rclone.exe 확인

  • cmd창에서 rclone version 입력하면 rclone.exe의 빌드 정보를 확인 할 수 있습니다.

 

참고

  • https://rclone.org/downloads/​ 에서 이미 빌드된 바이너리를 제공하고 있으니,
    필요하신 분은 다운로드해서 사용하세요
반응형
반응형

 

1. Go setup 다운로드

 

아래 링크에서 설치 파일을 다운로드합니다.

https://go.dev/dl/

 

 

Downloads - The Go Programming Language

Downloads After downloading a binary release suitable for your system, please follow the installation instructions. If you are building from source, follow the source installation instructions. See the release history for more information about Go releases

go.dev

 

윈도우용 설치 파일 링크를 클릭해서 다운로드합니다.

2. Go 설치 확인

  • cmd창에서 go version 을 입력해서 정상적으로 설치되었는지 확인합니다.

반응형
반응형

Build and Use Go Packages as C Libraries

GO의 공식기능인 CGO를 통해 C라이브러리를 참조하는 GO패키지를 만들 수 있습니다.

놀랍게도 그뿐아니라, 반대로 C에서 GO를 참조할 수 있도록 GO패키지에서 C라이브러리를 만들 수도 있습니다. 

 

How to

Build Go package as C shared library (or shared object)

모든 GO main 패키지는 C 공유 라이브러리로 빌드될 수 있어요.

$ go build -go build -buildmode c-shared -o <c-lib>.so <go-package>

 

위 명령을 실행하면 대상이된 Go main 패키지의 모든 종속성을 C공유라이브러리 하나로 빌드합니다.

이 C공유 라이브러리를 참조할 수 있는 모든 어플리케이션에 배포,설치, 링크할 수도 있습니다.

 

주의 : C공유라이브러리의 output 이름은 lib*.so 로 표준형식으로 지정해야합니다.

 

Generate C header and export Go functions as C functions

Go main package를 C shared library로 빌드한다고 해서 자동으로 C헤더를 생성하거나 Go함수를 C심볼로 노출하지 않습니다. 이건 개발자가 명시적으로 어떤 Go 함수를 노출할지 지정해야합니다.

 

 

Go 함수를 C 심볼로 export 하기

  • export 할 Go 함수 위에 //export FuncName 으로 주석을 추가합니다.

  • 이 함수가 있는 Go 코드파일에 import "c" 를 넣어주세요

  • 이 함수는 main 패키지에 포함되어 있어야합니다.

  • 함수 signature 에 Go struct, interface, array나 가변인수가 포함될 수 없습니다.

 

package main  

import "C"

import (
    "math/rand"
    "time"
)

//export cgoCurrentMillis
func cgoCurrentMillis() C.long {
    return C.long(time.Now().Unix()) 
}

//export cgoSeed
func cgoSeed(m C.long) {
    rand.Seed(int64(m))
}

//export cgoRandom
func cgoRandom(m C.int) C.int {     
    return C.int(rand.Intn(int(m))) 
}

위 Go main 패키지를 빌드하면 C헤더파일 <output.h> 과 C공유객체 <output>.so가 생성됩니다.

 

 

// Other stuff.  

extern long int cgoCurrentMillis();  

extern void cgoSeed(long int p0);  

extern int cgoRandom(int p0);

cgoCurrentMilli, cgoSeed 및 cgoRandom 도 <output>.so 에 C 심볼로 노출됩니다. 

 

 

이제 모든 C어플리케이션에서 만들어진 C헤더를 include 하고 C공유라이브러를 link해서 export된 C심볼을 사용할 수 있습니다.

 

 

#include <stdio.h> 
#include <cgo-random.h>  

int main() {     
    cgoSeed(cgoCurrentMilli());     
    
    printf("Hello World from C!\n");     
    printf("cgoRandom() -> %d\n", cgoRandom(256));   
    return 0;
}

 

 

원문 : 

https://medium.com/swlh/build-and-use-go-packages-as-c-libraries-889eb0c19838

 

Build and Use Go Packages as C Libraries

CGO is an official builtin feature of Go, it enables the creation of Go packages that reference to C libraries. But it isn’t just that, it…

medium.com

 

 

반응형
반응형

License

licence(영) / license(미)

라이센스라고 쓰는 경우가 많지만, 국립국어원의 표기법에 따르면 라이선스가 맞는 표기이다.

참조 : https://namu.wiki/w/라이선스 

 

 

olis.or.kr 라이선스 가이드

https://www.olis.or.kr/license/licenseGuide.do

 

OLIS 에서 제공하고 있는 오픈 소스 라이선스 가이드입니다.

실무자들이 참고하기 좋게 잘 정리되어 있습니다.

 

 

oss.kr

https://www.oss.kr/oss_license

 

공개SW 라이선스 - 공개SW 포털

.blind { position: absolute; overflow: hidden; clip: rect(0 0 0 0); margin: -1px; width: 1px; height...

www.oss.kr

oss.kr 에 방문하시면 아래와 같이 주요 라이선스에 대한 비교표를 확인하실 수 있습니다.

잘 정리되어 있어 한눈에 보기 편합니다.

 

반응형

+ Recent posts