Code Monkey home page Code Monkey logo

goblog's People

Contributors

semi-xi avatar

Watchers

 avatar

goblog's Issues

指针在结构体以及普通类型的差异

var a = 1
getPrt(&a)

func getPrt(ptr *int) {
	println(ptr)
}

实际上输出是一个地址

type Book struct {
	title string
}
func getBookInfo(ptr *Book) {
	println("title", ptr.title)
	println("prt", ptr)
}

p := Book{title: "BookName"}
getBookInfo(&p)

第1个输出是BookName,第2个值输出是一个地址。可以确认的是如果指针指向的是那个变量,那个变量的直接输出就是一个内存地址,对于结构体来说,哪怕是拿变量的地址去获取值,结果获取出来的也是一个具体的值

go的常规设定

同一个目录下的package name 必须是同一个

utils
     -a.go
     -b.go

a、b2个文件的开头都必须是相同的package neme

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.