Programming/golang2022. 4. 7. 12:12

변수 타입에 포인터 임을 명시하지, 변수에 포인터를 붙일 수 없도록 문법이 변경 된 듯.

 

func main() {
i, j := 42, 2701

// var p *int
var *p int
p = &i

// p := &i         // point to i
fmt.Println(*p) // read i through the pointer
*p = 21         // set i through the pointer
fmt.Println(i)  // see the new value of i

p = &j         // point to j
*p = *p / 37   // divide j through the pointer
fmt.Println(j) // see the new value of j
}

 

포인터 참조는 가능하지만, 주소 연산은 지원하지 않는건가..

C언어와는 다르게, Go는 포인터 산술을 지원하지 않습니다.

[링크 : https://go-tour-ko.appspot.com/moretypes/1]

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

golang a tour of go offline  (0) 2022.04.07
golang struct  (0) 2022.04.07
golang switch는 break 가 없다 (fallthough)  (0) 2022.04.07
golang for 반복문  (0) 2022.04.07
golang 사용자 함수  (0) 2022.04.07
Posted by 구차니
Programming/golang2022. 4. 7. 11:58

;를 통해 연속된 명령을 수행할 수 있는 것 같고

다음 case가 나오기 전까지만 실행된다.

 

func main() {
fmt.Print("Go runs on ")

switch os := runtime.GOOS; os {

case "darwin":
fmt.Println("OS X.")
case "linux":
fmt.Println("Linux.")
default:
// freebsd, openbsd,
// plan9, windows...
fmt.Printf("%s.\n", os)
}
}

[링크 : https://go-tour-ko.appspot.com/flowcontrol/9]

 

복잡한 if else문을 단순화 하기 위해 쓸 수 있다는데, 가독성이 영...

func main() {
t := time.Now()
fmt.Println(t)
switch {
case t.Hour() < 12:
fmt.Println("Good morning!")
case t.Hour() < 17:
fmt.Println("Good afternoon.")
default:
fmt.Println("Good evening.")
}
}

[링크 : https://go-tour-ko.appspot.com/flowcontrol/11]

 

+

22.04.11

대신 fallthrough를 통해서 다음 것을 실행할 순 있다.

default 구현할때 이걸 꼭 써줘야 한다면 좀 귀찮을 듯.

[링크 : https://golangbyexample.com/fallthrough-keyword-golang/]

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

golang struct  (0) 2022.04.07
golang pointer  (0) 2022.04.07
golang for 반복문  (0) 2022.04.07
golang 사용자 함수  (0) 2022.04.07
golang import  (0) 2022.04.07
Posted by 구차니
Programming/golang2022. 4. 7. 11:46

for 에서는 짧은할당문만 쓰도록 강제되는 것으로 보인다.

func main() {
sum := 0
for i := 0; i < 10; i++ {
sum += i
}
fmt.Println(sum)

// for var i = 0; i < 10; i++ {
// sum -= i
// }
// fmt.Println(sum)
}

 

var i =0 식으로 할당하면 for 초기화에서는 var 선언이 허용되지 않는다며 에러를 발생시킨다.

syntax error: var declaration not allowed in for initializer

[링크 : https://go-tour-ko.appspot.com/flowcontrol/1]

 

for문에서 초기화, 증감문을 생략 가능하므로 키워드 while은 삭제되고 for로 돌리면 된다.

func main() {
sum := 1
for sum < 1000 {
sum += sum
}
fmt.Println(sum)
}

[링크 : https://go-tour-ko.appspot.com/flowcontrol/3]

 

while(1)이나 for(;;) 보다 간결하게 무한반복을 구현할 수 있다.

func main() {
for {
}
}

[링크 : https://go-tour-ko.appspot.com/flowcontrol/4]

 

 

+

문법 자체는 c와 동일하다.

continue
break
goto label
:label

[링크 : http://golang.site/go/article/8-Go-반복문]

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

golang pointer  (0) 2022.04.07
golang switch는 break 가 없다 (fallthough)  (0) 2022.04.07
golang 사용자 함수  (0) 2022.04.07
golang import  (0) 2022.04.07
golang 변수 할당문(짧은 변수 선언문) :=  (0) 2022.04.07
Posted by 구차니
Apple2022. 4. 7. 11:24

생각해보니 sportlight 잘 안쓰니(솔찍히 간지는 나는데 용도를 모름...)

좌측 command + space를 한영 변환으로 등록!

 

우측 option을 한영키로 등록할 순 있으나 외부 프로그램 사용이 필요하다고 하니 패스.

[링크 : https://luran.me/486]

'Apple' 카테고리의 다른 글

macos opengl(cocoa?)  (0) 2022.04.28
dylib  (0) 2022.04.27
macos sshd  (0) 2022.04.07
macos cpu 정보확인  (0) 2022.04.02
mac 에서 rtl-sdr 시도..  (0) 2022.04.02
Posted by 구차니
Programming/golang2022. 4. 7. 11:09

변수 선언시에 변수명 변수타입 식으로 했듯

함수 선언에서도 

함수의 시작을 알려주는 키워드인 func 이후에 함수명(인자) 리턴 타입 순서로 선언한다.

너무 c언어에 물들어 있었나... 순서가 하나 바뀌었다고 눈에 안들어오네 -_-

 

func add(x int, y int) int {
return x + y
}

[링크 : https://go-tour-ko.appspot.com/basics/4]

 

int x,y가 함수 인자로 c에서 허용이 되었던가 기억이 안나네 -_-

아무튼 유사한 방법으로 함수 인자를 타입별로 묶어서 표현할 수 있다.

func add(x, y int) int {
return x + y
}

[링크 : https://go-tour-ko.appspot.com/basics/5]

 

요즘 언어 답게 복수 변수의 return 을 허용한다.

다만, 두개의 변수를 리턴할 때에는 소괄호를 이용해서 묶어 주어야 하는 듯.

func swap(x, y string) (string, string) {
return y, x
}

func main() {
a, b := swap("hello", "world")
fmt.Println(a, b)
}

[링크 : https://go-tour-ko.appspot.com/basics/6]

 

단순하게 return 만 씀으로서 앞서 계산한 변수의 값을 한번에 리턴한다.

물론 받는 쪽에서 리턴 변수의 이름까지 연동되진 않는다.

func split(sum int) (x, y int) {
x = sum * 4 / 9
y = sum - x
return
}

func main() {
fmt.Println(split(17))
}

[링크 : https://go-tour-ko.appspot.com/basics/7]

 

+

해당 문법은 gcc에서는 지원하지 않고 clang에서는 기본 변수타입으로 강제 지정한다.

go 에서만 지원하는 문법으로 확인.

% gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

% gcc hello.c
hello.c:3:16: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
int oops(int a,b,c)
               ^
hello.c:3:18: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
int oops(int a,b,c)

 

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)

$ gcc tt.c
tt.c:3:16: error: unknown type name ‘b’
 int oops(int a,b,c)
                ^
tt.c:3:18: error: unknown type name ‘c’
 int oops(int a,b,c)

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

golang switch는 break 가 없다 (fallthough)  (0) 2022.04.07
golang for 반복문  (0) 2022.04.07
golang import  (0) 2022.04.07
golang 변수 할당문(짧은 변수 선언문) :=  (0) 2022.04.07
golang type 변환, type 확인하기  (0) 2022.04.07
Posted by 구차니
Programming/golang2022. 4. 7. 11:04

위는 하나씩 불러올 때, 아래는 factored 라는데  무슨 의미인지 와닫지 않네..

그러고 보니 factored import 의 경우 대괄호가 아니라 소괄호를 사용하는게 특이하다. 콤마로 구분도 안하고 무슨 문법일까?

import "fmt"
import "math"

import (
"fmt"
"math"
)

[링크 : https://go-tour-ko.appspot.com/basics/2]

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

golang for 반복문  (0) 2022.04.07
golang 사용자 함수  (0) 2022.04.07
golang 변수 할당문(짧은 변수 선언문) :=  (0) 2022.04.07
golang type 변환, type 확인하기  (0) 2022.04.07
go 변수, 상수, 배열  (0) 2022.04.06
Posted by 구차니
Programming/golang2022. 4. 7. 10:57

:=는 짧은 선언문 이라고 번역이 되어야 할 것 같은데

알아서 변수형을 선언해주는 착한(?) 녀석이지만 익숙해지기 전까지는 가독성에 좀 문제가 있을 것으로 보인다.

변수에 값을 할당하는게 아니라 변수 목록(?) 처럼 ,를 사용해서 선언하고 값들을 변수에 연속으로 할당해버리네.

눈에 잘 들어오지 않아, 쓰는 건 좀 주의해야 겠다.

the := short assignment statement can be used in place of a var declaration with implicit type.

var i, j int = 1, 2
k := 3
c, python, java := true, false, "no!"

[링크 : https://go.dev/tour/basics/10]

[링크 : https://go-tour-ko.appspot.com/basics/10]

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

golang 사용자 함수  (0) 2022.04.07
golang import  (0) 2022.04.07
golang type 변환, type 확인하기  (0) 2022.04.07
go 변수, 상수, 배열  (0) 2022.04.06
go 모듈 불러오기  (0) 2022.04.06
Posted by 구차니
Programming/golang2022. 4. 7. 10:52

요즘 언어답게 형변환하는 것을 함수를 통해 변환한다. (정확하게는 함수라기 보다는... 머라고 해야 할까?)

var i int = 42
var f float64 = float64(i)
var u uint = uint(f)

[링크 : https://go-tour-ko.appspot.com/basics/13]

 

import "reflect"

reflect.Typeof(varname)

 

[링크 : https://knight76.tistory.com/entry/go-타입-확인하는-방법-reflectTypeOf]

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

golang import  (0) 2022.04.07
golang 변수 할당문(짧은 변수 선언문) :=  (0) 2022.04.07
go 변수, 상수, 배열  (0) 2022.04.06
go 모듈 불러오기  (0) 2022.04.06
golang 다른 파일 함수 불러오기  (0) 2022.04.04
Posted by 구차니
Apple2022. 4. 7. 10:32

당연하다면.. 당연하려나? X11-forwarding은 안된다.

 

'Apple' 카테고리의 다른 글

dylib  (0) 2022.04.27
macos 한영 변환 단축키 변경  (0) 2022.04.07
macos cpu 정보확인  (0) 2022.04.02
mac 에서 rtl-sdr 시도..  (0) 2022.04.02
macos 더블클릭 드래그  (0) 2022.04.01
Posted by 구차니
embeded/jetson2022. 4. 6. 18:32

약자에 대한 테이블 없나..

 

[링크 : https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/bootflow_jetson_xavier.html#]

 

Jetson Nano Development Module (P3448-0000) Flashed to Micro SD Card

NameTypeAlloc PolicyFS TypeSizeFS AttributeAlloc AttributeReservedFilenameDescription
GP1
GP1
sequential
basic
2097152
0
8
0 %
 
Required. Contains primary GPT of the sdcard device. All partitions defined after this entry are configured in the kernel, and are accessible by standard partition tools such as gdisk and parted.
APP
data
sequential
basic
APPSIZE
0
0x8
0 %
APPFILE
Required. Contains the rootfs. This partition must be defined after primary_GPT so that it can be accessed as the fixed known special device /dev/mmcblk0p1.
TXC
TBCTYPE
sequential
basic
131072
0
8
0 %
TBCFILE
Required. Contains TegraBoot CPU-side binary.
RP1
data
sequential
basic
458752
0
0x8
0 %
DTBFILE
Required. Contains Bootloader DTB binary.
EBT
bootloader
sequential
basic
589824
0
8
0 %
EBTFILE
Required. Contains CBoot, the final boot stage CPU bootloader binary that loads the binary in the kernel partition..
WX0
WB0TYPE
sequential
basic
65536
0
8
0 %
WB0FILE
Required. Contains warm boot binary.
BXF
data
sequential
basic
196608
0
8
0 %
BPFFILE
Required. Contains SC7 entry firmware.
BXF-DTB
data
sequential
basic
393216
0
8
0 %
BPFDTB-FILE
Optional. Reserved for future use by BPMP DTB binary; can't remove.
FX
FBTYPE
sequential
basic
65536
0
0x8
0 %
FBFILE
Optional. Reserved for fuse bypass; removeable.
TXS
data
sequential
basic
458752
0
8
0 %
TOSFILE
Required. Contains TOS binary.
DXB
data
sequential
basic
458752
0
0x8
0 %
DTBFILE
Required. Contains kernel DTB binary.
LNX
data
sequential
basic
786432
0
0x8
0 %
LNXFILE
Required. Contains U-Boot, which loads and launches the kernel from the rootfs at /boot.
EXS
data
sequential
basic
65536
0
8
0 %
EKSFILE
Optional. Contains the encrypted keys.
BMP
data
sequential
basic
81920
0
0x8
0 %
bmp.blob
Optional. Contains BMP images for splash screen display during boot.
RP4
data
sequential
basic
131072
0
0x8
0 %
rp4.blob
Required. Contains XUSB module’s firmware file, making XUSB a true USB 3.0 compliant host controller.
GPT
GPT
sequential
basic
2097152
0
8
0 %
 
Required. Contains secondary GPT of the sdcard device.

[링크 : https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra Linux Driver Package Development Guide/part_config.html#]

 

+

22.04.07

BootROM (BR) 
Boot Configuration Table (BCT)
bootloader (BL)

[링크 : https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/bootflow_jetson_nano.html#wwpID0E02B0HA]


boot-file-set (BFS)
kernel-file-set (KFS) 
[링크 : https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/bootloader_update_nano_tx1.html]


EKB or EKS: Encrypted keyblob, an encrypted blob which holds developer-defined content
[링크 : https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/trusty.html]

1.Boot partitions, which are used in the boot process, and are visible only to Bootloader.
Many of the boot partitions have redundant copy partitions. The copy partitions must have the same names as their primaries with the suffix ‘‑1’. For example, the NVC partition’s copy must be named NVC‑1.
The boot partitions are:
•BCT, which contains redundant instances of the Boot Configuration Table. This must be the first partition on the boot device.
•NVC contains TegraBoot. This must be the second boot partition. The following boot partitions, PT through SPF, are part of the BFS.
•PT contains layout information for each BFS, and indicates the beginning of each one. It is the first partition in the BFS.
•TBC contains the TegraBoot CPU-side binary.
•RP1 contains TegraBoot DTBs.
•EBT contains CBoot.
•WB0 contains the warm boot binary.
•BPF contains BPMP microcode.
•NVC‑1 contains a copy of NVC.
•PT‑1 through BPF‑1 are copy partitions for the primaries NVC through BPF, making up a copy of the BFS, denoted BFS‑1.
•PAD is an empty partition which ensures the VER and VER_b are at the very end of the boot partition.
•VER_b contains additional version information for redundancy and version checking.
•VER contains version information.
2.GP1 contains the sdmmc_user device’s primary GPT. All partitions defined after this one are configured in the Linux kernel, and are accessible by standard partition tools such as gdisk and parted.
3.User partitions, which have a variety of uses. Some of them may be deleted, and/or may be mounted and used to store application files.
The following partitions constitute the kernel-file-set (KFS), and have redundant copy partitions:
•DTB contains kernel DTBs.
•TOS contains the trusted OS binary.
•EKS is optional, and is reserved for future use.
•LNX contains either the Linux kernel or U-Boot, depending on your choice of DFLT_KERNEL_IMAGE in the configuration file.
•DTB‑1 through EKS‑1 constitute a copy of the primary KFS, denoted KFS‑1.
•Other partitions, such as APP and BMP, are outside the scope of this document. For information about these partitions, see the appropriate subsection for your Jetson platform in Default Partition Overview.
Kernel-file-set (KFS)

[링크 : https://docs.nvidia.com/jetson/l4t/index.html#page/Tegra%20Linux%20Driver%20Package%20Development%20Guide/bootloader_update_nano_tx1.html#]

'embeded > jetson' 카테고리의 다른 글

nvidia jetson deepstream objectDetector_SSD 실행 스크립트 분석  (0) 2022.04.13
jetson / armv8 EL  (0) 2022.04.07
jetson nano 부팅이 안됨  (0) 2022.04.06
deepstream triton server  (0) 2022.03.30
deepstream part.3  (0) 2022.03.29
Posted by 구차니