'잡동사니'에 해당되는 글 13326건

  1. 2022.09.15 golang 'go doc'
  2. 2022.09.15 golang main arg, getopt
  3. 2022.09.15 golang json
  4. 2022.09.15 golang ini
  5. 2022.09.14 golang http.request
  6. 2022.09.12 스위치 doom 최저 난이도 엔딩봄
  7. 2022.09.12 비데 교체
  8. 2022.09.12 제노블레이드3 구매
  9. 2022.09.11 오랫만에 자전거 그리고
  10. 2022.09.08 연휴의 시작
Programming/golang2022. 9. 15. 19:02

 

$ go doc os.Pipe
package os // import "os"

func Pipe() (r *File, w *File, err error)
    Pipe returns a connected pair of Files; reads from r return bytes written to
    w. It returns the files and an error, if any.

 

$ go doc os
package os // import "os"

Package os provides a platform-independent interface to operating system
functionality. The design is Unix-like, although the error handling is Go-like;
failing calls return values of type error rather than error numbers. Often, more
information is available within the error. For example, if a call that takes a
file name fails, such as Open or Stat, the error will include the failing file
name when printed and will be of type *PathError, which may be unpacked for more
information.

The os interface is intended to be uniform across all operating systems.
Features not generally available appear in the system-specific package syscall.

Here is a simple example, opening a file and reading some of it.

    file, err := os.Open("file.go") // For read access.
    if err != nil {
     log.Fatal(err)
    }

If the open fails, the error string will be self-explanatory, like

    open file.go: no such file or directory

The file's data can then be read into a slice of bytes. Read and Write take
their byte counts from the length of the argument slice.

    data := make([]byte, 100)
    count, err := file.Read(data)
    if err != nil {
     log.Fatal(err)
    }
    fmt.Printf("read %d bytes: %q\n", count, data[:count])

Note: The maximum number of concurrent operations on a File may be limited by
the OS or the system. The number should be high, but exceeding it may degrade
performance or cause other issues.

const O_RDONLY int = syscall.O_RDONLY ...
const SEEK_SET int = 0 ...
const PathSeparator = '/' ...
const ModeDir = fs.ModeDir ...
const DevNull = "/dev/null"
var ErrInvalid = fs.ErrInvalid ...
var Stdin = NewFile(uintptr(syscall.Stdin), "/dev/stdin") ...
var Args []string
var ErrProcessDone = errors.New("os: process already finished")
func Chdir(dir string) error
func Chmod(name string, mode FileMode) error
func Chown(name string, uid, gid int) error
func Chtimes(name string, atime time.Time, mtime time.Time) error
func Clearenv()
func DirFS(dir string) fs.FS
func Environ() []string
func Executable() (string, error)
func Exit(code int)
func Expand(s string, mapping func(string) string) string
func ExpandEnv(s string) string
func Getegid() int
func Getenv(key string) string
func Geteuid() int
func Getgid() int
func Getgroups() ([]int, error)
func Getpagesize() int
func Getpid() int
func Getppid() int
func Getuid() int
func Getwd() (dir string, err error)
func Hostname() (name string, err error)
func IsExist(err error) bool
func IsNotExist(err error) bool
func IsPathSeparator(c uint8) bool
func IsPermission(err error) bool
func IsTimeout(err error) bool
func Lchown(name string, uid, gid int) error
func Link(oldname, newname string) error
func LookupEnv(key string) (string, bool)
func Mkdir(name string, perm FileMode) error
func MkdirAll(path string, perm FileMode) error
func MkdirTemp(dir, pattern string) (string, error)
func NewSyscallError(syscall string, err error) error
func Pipe() (r *File, w *File, err error)
func ReadFile(name string) ([]byte, error)
func Readlink(name string) (string, error)
func Remove(name string) error
func RemoveAll(path string) error
func Rename(oldpath, newpath string) error
func SameFile(fi1, fi2 FileInfo) bool
func Setenv(key, value string) error
func Symlink(oldname, newname string) error
func TempDir() string
func Truncate(name string, size int64) error
func Unsetenv(key string) error
func UserCacheDir() (string, error)
func UserConfigDir() (string, error)
func UserHomeDir() (string, error)
func WriteFile(name string, data []byte, perm FileMode) error
type DirEntry = fs.DirEntry
    func ReadDir(name string) ([]DirEntry, error)
type File struct{ ... }
    func Create(name string) (*File, error)
    func CreateTemp(dir, pattern string) (*File, error)
    func NewFile(fd uintptr, name string) *File
    func Open(name string) (*File, error)
    func OpenFile(name string, flag int, perm FileMode) (*File, error)
type FileInfo = fs.FileInfo
    func Lstat(name string) (FileInfo, error)
    func Stat(name string) (FileInfo, error)
type FileMode = fs.FileMode
type LinkError struct{ ... }
type PathError = fs.PathError
type ProcAttr struct{ ... }
type Process struct{ ... }
    func FindProcess(pid int) (*Process, error)
    func StartProcess(name string, argv []string, attr *ProcAttr) (*Process, error)
type ProcessState struct{ ... }
type Signal interface{ ... }
    var Interrupt Signal = syscall.SIGINT ...
type SyscallError struct{ ... }

 

 

$ 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

 

$ go help doc
usage: go doc [doc flags] [package|[package.]symbol[.methodOrField]]

Doc prints the documentation comments associated with the item identified by its
arguments (a package, const, func, type, var, method, or struct field)
followed by a one-line summary of each of the first-level items "under"
that item (package-level declarations for a package, methods for a type,
etc.).

Doc accepts zero, one, or two arguments.

Given no arguments, that is, when run as

go doc

it prints the package documentation for the package in the current directory.
If the package is a command (package main), the exported symbols of the package
are elided from the presentation unless the -cmd flag is provided.

When run with one argument, the argument is treated as a Go-syntax-like
representation of the item to be documented. What the argument selects depends
on what is installed in GOROOT and GOPATH, as well as the form of the argument,
which is schematically one of these:

go doc <pkg>
go doc <sym>[.<methodOrField>]
go doc [<pkg>.]<sym>[.<methodOrField>]
go doc [<pkg>.][<sym>.]<methodOrField>

The first item in this list matched by the argument is the one whose documentation
is printed. (See the examples below.) However, if the argument starts with a capital
letter it is assumed to identify a symbol or method in the current directory.

For packages, the order of scanning is determined lexically in breadth-first order.
That is, the package presented is the one that matches the search and is nearest
the root and lexically first at its level of the hierarchy. The GOROOT tree is
always scanned in its entirety before GOPATH.

If there is no package specified or matched, the package in the current
directory is selected, so "go doc Foo" shows the documentation for symbol Foo in
the current package.

The package path must be either a qualified path or a proper suffix of a
path. The go tool's usual package mechanism does not apply: package path
elements like . and ... are not implemented by go doc.

When run with two arguments, the first is a package path (full path or suffix),
and the second is a symbol, or symbol with method or struct field:

go doc <pkg> <sym>[.<methodOrField>]

In all forms, when matching symbols, lower-case letters in the argument match
either case but upper-case letters match exactly. This means that there may be
multiple matches of a lower-case argument in a package if different symbols have
different cases. If this occurs, documentation for all matches is printed.

Examples:
go doc
Show documentation for current package.
go doc Foo
Show documentation for Foo in the current package.
(Foo starts with a capital letter so it cannot match
a package path.)
go doc encoding/json
Show documentation for the encoding/json package.
go doc json
Shorthand for encoding/json.
go doc json.Number (or go doc json.number)
Show documentation and method summary for json.Number.
go doc json.Number.Int64 (or go doc json.number.int64)
Show documentation for json.Number's Int64 method.
go doc cmd/doc
Show package docs for the doc command.
go doc -cmd cmd/doc
Show package docs and exported symbols within the doc command.
go doc template.new
Show documentation for html/template's New function.
(html/template is lexically before text/template)
go doc text/template.new # One argument
Show documentation for text/template's New function.
go doc text/template new # Two arguments
Show documentation for text/template's New function.

At least in the current tree, these invocations all print the
documentation for json.Decoder's Decode method:

go doc json.Decoder.Decode
go doc json.decoder.decode
go doc json.decode
cd go/src/encoding/json; go doc decode

Flags:
-all
Show all the documentation for the package.
-c
Respect case when matching symbols.
-cmd
Treat a command (package main) like a regular package.
Otherwise package main's exported symbols are hidden
when showing the package's top-level documentation.
-short
One-line representation for each symbol.
-src
Show the full source code for the symbol. This will
display the full Go source of its declaration and
definition, such as a function definition (including
the body), type declaration or enclosing const
block. The output may therefore include unexported
details.
-u
Show documentation for unexported as well as exported
symbols, methods, and fields.

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

golang package main  (0) 2022.09.23
golang REST client  (0) 2022.09.23
golang main arg, getopt  (0) 2022.09.15
golang json  (0) 2022.09.15
golang ini  (0) 2022.09.15
Posted by 구차니
Programming/golang2022. 9. 15. 19:00

 

package main

import (
	"fmt"
	"os"
)

func main() {
	argsWithProg := os.Args
	argsWithoutProg := os.Args[1:]

	// You can get individual args with normal indexing.
	arg := os.Args[3]

	fmt.Println(argsWithProg)
	fmt.Println(argsWithoutProg)
	fmt.Println(arg)
}

[링크 : https://gobyexample.com/command-line-arguments]

[링크 : https://stackoverflow.com/questions/2707434/how-to-access-command-line-arguments-passed-to-a-go-program]

[링크 : https://golangdocs.com/command-line-arguments-in-golang]

 

[링크 : https://pkg.go.dev/github.com/pborman/getopt]

 

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

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

golang REST client  (0) 2022.09.23
golang 'go doc'  (0) 2022.09.15
golang json  (0) 2022.09.15
golang ini  (0) 2022.09.15
golang http.request  (0) 2022.09.14
Posted by 구차니
Programming/golang2022. 9. 15. 10:36

프로그램 환경설정 파일로 ini나 다른걸 찾아보는데

golang 기본 라이브러리로 json이 있고 yaml은 없다고 하니 고민중

 

func LoadConfigration(path string) Config {
    var config Config
    file, err := os.Open("config.json")
    defer file.Close()
    if err != nil {
        fmt.Println(err.Error())
    }
    jsonParser := json.NewDecoder(file)
    jsonParser.Decode(&config)
    return config
}

[링크 : https://loperlee.tistory.com/15]

 

import "encoding/json"

[링크 : https://pkg.go.dev/encoding/json]

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

golang 'go doc'  (0) 2022.09.15
golang main arg, getopt  (0) 2022.09.15
golang ini  (0) 2022.09.15
golang http.request  (0) 2022.09.14
golang range  (0) 2022.09.06
Posted by 구차니
Programming/golang2022. 9. 15. 10:34

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

golang main arg, getopt  (0) 2022.09.15
golang json  (0) 2022.09.15
golang http.request  (0) 2022.09.14
golang range  (0) 2022.09.06
golang mutex  (0) 2022.09.06
Posted by 구차니
Programming/golang2022. 9. 14. 16:26

ajax를 통해 DELETE type으로 변수를 넘겨줄 수 있나 찾아보는데

정작 보낸다고 해도 어떻게 golang에서 받아서 쓸 수 있나, r.ParseForm() 같은거 있나 찾아보는데 영 안보인다.

 

오랫만에 jquery  보니 ajax로 어떻게 DELETE를 보내더라? 기억도 잘 안나고 ㅠㅠ

[링크 : https://api.jquery.com/jQuery.ajax/#options]

 

부랴부랴 뒤져서 http.Request의 원형(?)을 찾았는데, Body와 GetBody() 발견

type Request struct {
Method string
URL *url.URL
Proto      string // "HTTP/1.0"
ProtoMajor int    // 1
ProtoMinor int    // 0
Header Header
Body io.ReadCloser
GetBody func() (io.ReadCloser, error)
ContentLength int64
TransferEncoding []string
Close bool
Host string
Form url.Values
PostForm url.Values
MultipartForm *multipart.Form
Trailer Header
RemoteAddr string
RequestURI string
TLS *tls.ConnectionState
Cancel <-chan struct{}
Response *Response
}

[링크 : https://pkg.go.dev/net/http#Request]

[링크 : https://www.digitalocean.com/community/tutorials/how-to-make-http-requests-in-go]

 

요거 되긴 한다. body에 json 담아 보내면 이렇게 읽으면 되는 듯

다만 "io/ioutil" 패키지를 추가해주어야 한다.

b, err := ioutil.ReadAll(req.Body)
if err != nil {
    panic(err)
}

fmt.Printf("%s", b)

[링크 : https://stackoverflow.com/questions/46579429/golang-cant-get-body-from-request-getbody]

[링크 : https://stackoverflow.com/questions/33164564/golang-parse-post-request]

 

$.ajax({
    url: '/v1/object/3.json',
    method: 'DELETE',
    contentType: 'application/json',
    success: function(result) {
        // handle success
    },
    error: function(request,msg,error) {
        // handle failure
    }
});

[링크 : https://stackoverflow.com/questions/2153917/how-to-send-a-put-delete-request-in-jquery]

[링크 : https://stackoverflow.com/questions/15088955/how-to-pass-data-in-the-ajax-delete-request-other-than-headers]

 

걍 속편하게 mux 쓰는게 나으려나?

[링크 : https://github.com/gorilla/mux]

  [링크 : https://morioh.com/p/9a0e53da7908]

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

golang json  (0) 2022.09.15
golang ini  (0) 2022.09.15
golang range  (0) 2022.09.06
golang mutex  (0) 2022.09.06
golang make와 new  (0) 2022.09.06
Posted by 구차니
게임/닌텐도 스위치2022. 9. 12. 22:27

여운은 없고

그냥 빡세게 엔딩을 봤다.. 느낌?

마지막 보스는 괜히 힘들게 샷건, 로켓 런처, 가우스 캐논으로 잡다가

아 맞다!! 상남자의 무기 BFG9000! 을 꺼내면서 2차 전이라고 해야하나..

바닥에 전기 흘리는 쪽을 겨우겨우 깸.

 

역시 무기는 훌륭한 대화수단이 맞음.

'게임 > 닌텐도 스위치' 카테고리의 다른 글

닌텐도 스위치 방틴유리 깨짐  (0) 2022.10.24
연휴 제노블레이드 달려!  (0) 2022.10.10
제노블레이드3 구매  (0) 2022.09.12
둠 리부트 스위치 진행중  (0) 2022.08.23
둠 스위치 중고 구매  (0) 2022.08.21
Posted by 구차니

버튼들이 안눌려사 노비타 비데 버리고

(이전에 두번 정도 pcb 교체한 적 있음)

이마트제 12만원짜리 구매하여 자기오 교체함

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

김치 냉장고 지름  (0) 2022.09.25
병원 투어  (0) 2022.09.24
오랫만에 자전거 그리고  (0) 2022.09.11
연휴의 시작  (0) 2022.09.08
전자식 계량기 읽는 방법  (0) 2022.09.07
Posted by 구차니
게임/닌텐도 스위치2022. 9. 12. 21:54

이마트에서

64800원에서 20%할인해서 51840원에 팔아서

저만큼 중고가 똘어지려고 해도 한참 걸릴듯 하여 구매!

혹시나 동네 롯데마트 가봤지만 할인 없는걸 보면

닌텐도 코리아가 아닌 이마트 자체 할인인듯.

 

'게임 > 닌텐도 스위치' 카테고리의 다른 글

연휴 제노블레이드 달려!  (0) 2022.10.10
스위치 doom 최저 난이도 엔딩봄  (0) 2022.09.12
둠 리부트 스위치 진행중  (0) 2022.08.23
둠 스위치 중고 구매  (0) 2022.08.21
hdmi2usb 닌텐도 잘되네?  (2) 2022.08.19
Posted by 구차니

기절!

 

왕복 1시간 거리 오갔다 허벅지가 터질듯 ㅠㅠ

얼마나 운동을 안했었나를 뼈저리게 느끼네..

 

평속 20km (왕복) 갈때도 그렇고 올때도 지쳤는데 그런거 보면

집방향으로 바람이 분건가?

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

병원 투어  (0) 2022.09.24
비데 교체  (0) 2022.09.12
연휴의 시작  (0) 2022.09.08
전자식 계량기 읽는 방법  (0) 2022.09.07
라디오 분해 시도 실패 -_-  (4) 2022.08.07
Posted by 구차니

금,토,일,월,화

길다면 긴 연휴의 시작!

애들은 화요일에 보내니 그나마 좀 버틸만 하려나?

'개소리 왈왈 > 육아관련 주저리' 카테고리의 다른 글

비데 교체  (0) 2022.09.12
오랫만에 자전거 그리고  (0) 2022.09.11
전자식 계량기 읽는 방법  (0) 2022.09.07
라디오 분해 시도 실패 -_-  (4) 2022.08.07
라디오 분해?  (0) 2022.08.06
Posted by 구차니