Re: [go-nuts] For loop in go templating

2017-12-11 Thread Ian Lance Taylor
On Mon, Dec 11, 2017 at 6:41 PM, Josh Cox wrote: > > Why is there not a 'for' action in go templating? > > I seem to get punted for asking such blasphemy! > > my stackoverflow question > > and my [github > issue](https://github.com/golang/go/issues/23088#issuecomment-350871434) > > But it's a seri

Re: [go-nuts] base32 DecodeLen() miscalculation when no padding

2017-12-12 Thread Ian Lance Taylor
On Tue, Dec 12, 2017 at 12:06 AM, Jeff Goldberg wrote: > > In encoding/base32 there is, I believe, an off by one error in the > calculation of the size of the buffer needed for DecodeLen() when padding is > turned off. > > // DecodedLen returns the maximum length in bytes of the decoded data > /

Re: [go-nuts] base32 DecodeLen() miscalculation when no padding

2017-12-12 Thread Ian Lance Taylor
On Tue, Dec 12, 2017 at 3:13 PM, Jeffrey Goldberg wrote: > >> On Dec 12, 2017, at 9:00 AM, Ian Lance Taylor wrote: > >> DecodedLen is supposed to be applied to the length of the encoded >> data. RFC 4648 says that the encoded data must be padded to be a >> multipl

Re: [go-nuts] Inconsistent handling of permissions by os.Mkdir

2017-12-13 Thread Ian Lance Taylor
On Wed, Dec 13, 2017 at 5:46 AM, wrote: > > I just ran into some inconsistencies wrt permissions and `os.Mkdir()`, at > least on Linux. I'm not sure what part of this is actual bugs that need to > be fixed and what is a documentation bug, but let me state what I've found. > > The documentation fo

Re: [go-nuts] Inconsistent handling of permissions by os.Mkdir

2017-12-13 Thread Ian Lance Taylor
On Wed, Dec 13, 2017 at 7:57 AM, Matthijs Kooijman wrote: > >> I think the inconsistency in the handling of umask on *BSD systems is >> a bug. Please open an issue for that at https://golang.org/issue. > Ok: https://github.com/golang/go/issues/23120 > >> We've discussed in the past how much to do

Re: [go-nuts] How can I get unix timestamp(time.Now().Unix()) in linker(cmd/link)

2017-12-15 Thread Ian Lance Taylor
On Fri, Dec 15, 2017 at 3:08 AM, Ally Dale wrote: > Hi all, > I just need a function to report the timestamp when my app compiled. > > func main() { > > > unix := runtime.BuildTimestamp() > > > t := time.Unix(unix, 0) > > > println("hello world") > > > println("bui

Re: [go-nuts] Go Compiler How Work?!

2017-12-15 Thread Ian Lance Taylor
The technique of generating an object file directly from the compiler does not have a name. Many other compilers do the same thing For example, clang/LLVM does it. These questions about how compilers work do not have anything to do with Go, and I encourage you to take them to some other group.

Re: [go-nuts] callback for c code wrapper around go function

2017-12-18 Thread Ian Lance Taylor
On Mon, Dec 18, 2017 at 5:31 AM, wrote: > > I want to write a c wrapper around a go code that has a callback > > func SomeGoComputation(address string, callback func(string,int)) { > _, err = // do some computation with address, maybe go over the > network > if (err != nil) { >

Re: [go-nuts] bytes.Buffer Grow() doesn't always increase Cap()?

2017-12-19 Thread Ian Lance Taylor
On Tue, Dec 19, 2017 at 11:08 AM, Paul Boyd wrote: > > Sorry if this is a dumb question that's been answered before, but I can't > find anything about it. > > I'm calling Grow() on a bytes.Buffer and I thought that would increase Cap() > and the size of the underlying []byte. But, it doesn't seem

Re: [go-nuts] Re: callback for c code wrapper around go function

2017-12-19 Thread Ian Lance Taylor
On Tue, Dec 19, 2017 at 9:40 AM, wrote: > > Thanks for your response, are you referring to something like this: > /* > #include > #include > > void parse(char* err, int status) { > // do work > } > */ > > > > > func Ccomputation(address *C.char) { > > ptr := uintptr(unsafe.Pointer(C.parse)

Re: [go-nuts] GC Internals Questions

2017-12-20 Thread Ian Lance Taylor
On Wed, Dec 20, 2017 at 1:54 AM, Jan Mercl <0xj...@gmail.com> wrote: > > On Wed, Dec 20, 2017 at 12:57 AM 'Keith Randall' via golang-nuts > wrote: > >> Pointers that point from a Go object to somewhere outside the Go heap are >> perfectly fine. > > Can you please specify the exact mechanism used b

Re: [go-nuts] GC Internals Questions

2017-12-20 Thread Ian Lance Taylor
On Wed, Dec 20, 2017 at 2:45 AM, Xuanyi Chew wrote: > > I'm guessing also, that a "true" pointer has to be byte aligned - no pointer > tagging shennanigans with unsafe.Pointer You can do all the pointer tagging you like as long as the final bits can not be interpreted as a pointer into the Go hea

Re: [go-nuts] Re: newbie with go 1.9 troubles

2017-12-20 Thread Ian Lance Taylor
On Wed, Dec 20, 2017 at 3:41 AM, wrote: > > I have Fedora Linux 26 and I am trying to installed latest binary version > of go i.e go1.9.2.linux-amd64.tar.gz and there was no previous install on > the system and I have double checked with following command, and I have > installed go in my home d

Re: [go-nuts] How can I get unix timestamp(time.Now().Unix()) in linker(cmd/link)

2017-12-20 Thread Ian Lance Taylor
to add a variable to the runtime package for this. Ian > > 在 2017年12月16日星期六 UTC+8上午5:11:00,Ian Lance Taylor写道: >> >> On Fri, Dec 15, 2017 at 3:08 AM, Ally Dale wrote: >> > Hi all, >> > I just need a function to report the timestamp when my app compiled. &

Re: [go-nuts] Re: callback for c code wrapper around go function

2017-12-21 Thread Ian Lance Taylor
On Thu, Dec 21, 2017 at 6:15 AM, wrote: > > 2 - Do all functions added into the preamble get exported to the header and > the shared object that go build creates? Yes they do, if you use //export, as documented at https://golang.org/cmd/cgo. Ian -- You received this message because you are su

Re: [go-nuts] Re: callback for c code wrapper around go function

2017-12-21 Thread Ian Lance Taylor
in the Go program, then the C preamble is linked multiple times, so non-static functions in the preamble will cause multiple definition errors. Again I refer you to https://golang.org/cmd/cgo, where this is documented. Ian > On Thursday, December 21, 2017 at 9:39:07 AM UTC-5, Ian Lance

Re: [go-nuts] gRPC go on AIX

2017-12-21 Thread Ian Lance Taylor
On Thu, Dec 21, 2017 at 1:43 PM, wrote: > > Can someone help me to set up gRPC go on AIX running on a Power 8. I > tried installing using go get -u google.golang.org/grpc > (https://grpc.io/docs/quickstart/go.html#prerequisites), but it fails with > following: > > Fetching https://google.gola

Re: [go-nuts] Possible bug on os.Stat and mode is symlink

2017-12-26 Thread Ian Lance Taylor
On Mon, Dec 25, 2017 at 1:48 AM, Shulhan wrote: > Environment > > OS: Linux xenom-bubu 4.14.8-1-ARCH #1 SMP PREEMPT Wed Dec 20 21:27:44 > UTC 2017 x86_64 GNU/Linux > > Go: go1.10beta1 linux/amd64 > > Steps to reproduce > > $ mkdir testSymlink > $ cd testSymlink > $ touch test > $ ln -s tes

Re: [go-nuts] O_DIRECT and write Array returns Invalid argument error

2017-12-28 Thread Ian Lance Taylor
On Thu, Dec 28, 2017 at 2:31 PM, Viacheslav Biriukov wrote: > > Could you please help me with the following code with O_DIRECT and array. I > tried to implement direct io and stuck with weird behaviour of alignment > writes created from array. > > > Following code doesn't work: > > > package main

Re: [go-nuts] Extending an existing type by embedding

2018-01-01 Thread Ian Lance Taylor
On Mon, Jan 1, 2018 at 6:46 PM, Tong Sun wrote: > > I think I generally understand how embedding > (https://golang.org/doc/effective_go.html#embedding) works in GO. > However, when it comes to the following problem, I'm at lost again. > > I'm trying to extend the `html.Tokenizer` with new methods

Re: [go-nuts] Extending an existing type by embedding

2018-01-02 Thread Ian Lance Taylor
On Mon, Jan 1, 2018 at 8:13 PM, Tong Sun wrote: > > Are just the last two attempts that I make, apart from many other failed > attempts that I've lost track of, but neither compiles. Thanks. It helps to know that the problem is that the code does not compile. I see that this issue was already a

Re: [go-nuts] retpolines in the go compiler?

2018-01-04 Thread Ian Lance Taylor
On Thu, Jan 4, 2018 at 9:41 AM, wrote: > > The last few days have seen some scary CPU security issues. One is Spectre, > which takes advantage of branch prediction and cache timings to read memory > that should be inaccessible. > > The main (only?) mitigation that I have seen is to use "retpoline

Re: [go-nuts] Underlying arrays and their slices passed to functions

2018-01-04 Thread Ian Lance Taylor
On Thu, Jan 4, 2018 at 10:08 AM, Frank Davidson wrote: > > I'm sure this has probably been answered before, but I have a question about > when a slice's underlying array is copied? In this code: > > https://play.golang.org/p/TnMFo-rYKzq > > package main > > import ( > "fmt" > ) > > func main() { >

Re: [go-nuts] Meet "fatal morestack on g0" on Linux

2018-01-05 Thread Ian Lance Taylor
On Fri, Jan 5, 2018 at 7:17 AM, wrote: > > I meet a strange problem when running a program on Linux. I get "fatal: > morestack on g0" from stderr. The process is still there but does not > respond anymore. When I use `curl > http://ip:port/debug/pprof/goroutine?debug=1` to check the stack, but it

Re: [go-nuts] runtime.KeepAlive() needed if conditional usage follows?

2018-01-08 Thread Ian Lance Taylor
On Mon, Jan 8, 2018 at 5:28 PM, Justin Israel wrote: > > I've got a cgo library that needed a pass of adding runtime.KeepAlive() to > prevent crashes when passing C pointers into cgo calls. Today a similar > crash occurred in one of my functions in the library that looks like the > following: > >

Re: [go-nuts] New identifiers and selectors in short variable declarations

2018-01-09 Thread Ian Lance Taylor
On Tue, Jan 9, 2018 at 1:02 PM, Jim Bishopp wrote: > > Has there ever been a discussion about allowing new identifiers and > selectors in short variable declarations? > > var a struct { x int } > b, a.x := 1, 2 > > ERROR: expected identifier on left side of := That idea appears in https://golang.

Re: [go-nuts] Is there an equivalent of telldir in go. If not what are the alternatives?

2018-01-10 Thread Ian Lance Taylor
On Wed, Jan 10, 2018 at 3:31 PM, Amandeep Gautam wrote: > > Is there a equivalent of telldir in golang which can page reading of a > directory. > Just using filepath.walk would be inefficient for large file systems. There is no telldir, but you can simply call the `Readdir` (or `Readdirnames`) me

Re: [go-nuts] Re: Is there any ways to kill goroutine immediately ?

2018-01-11 Thread Ian Lance Taylor
On Thu, Jan 11, 2018 at 9:02 AM, wrote: > A `return` should kill it. Or runtime.Goexit (https://golang.org/pkg/runtime/#Goexit). Ian > On Thursday, 11 January 2018 15:50:24 UTC, Iman Tumorang wrote: >> >> I'm using goroutine with 2 concurrent jobs. >> >> And I've using context with both of the

[go-nuts] Re: [golang-dev] Go 1.10 Beta 2 is released

2018-01-11 Thread Ian Lance Taylor
On Thu, Jan 11, 2018 at 11:44 AM, Andrew Bonventre wrote: > Hello gophers, > > We have just released go1.10beta2, a beta version of Go 1.10. > It is cut from the master branch at the revision tagged go1.10beta2. > > There are no known problems or regressions. > > Please try running production load

Re: [go-nuts] Non-Coherent Caches

2018-01-12 Thread Ian Lance Taylor
On Fri, Jan 12, 2018 at 2:03 AM, Chris Hopkins wrote: > > Does anyone know of an architecture that go runs on that has non-coherent > data caches? If so, is there a mechanism in the language/tool chain to > protect against the issues of this? > > Background: > I was watching a video on the go trac

Re: [go-nuts] Go on processor without SSE

2018-01-12 Thread Ian Lance Taylor
On Fri, Jan 12, 2018 at 2:03 AM, wrote: > > I'm searching how to compile golang to use it on an old 32bits cpu (AMD > Geode) without SSE. > > Any idea? Tell us exactly what you did and exactly how it failed. Ian -- You received this message because you are subscribed to the Google Groups "go

Re: [go-nuts] Is len() shadowed in crypto/sha256?

2018-01-14 Thread Ian Lance Taylor
On Sun, Jan 14, 2018 at 9:15 AM, Dan Lüdtke wrote: > > looking for some insights regarding Sum256, especially line 139. > https://golang.org/src/crypto/sha256/sha256.go?#L139 > Doesn't the statement `len := d.len` shadow the len() function and isn't > that supposed to be "bad style" or am I missin

Re: [go-nuts] Unexpected behaviour with LD_PRELOAD and fopen and cgo

2018-01-15 Thread Ian Lance Taylor
On Mon, Jan 15, 2018 at 9:09 AM, wrote: > > I'm doing more experiments with created shared-object files with functions > that override syscalls and I've hit something I'd like to see if you guys > can help with. > > See a cut-down version of what I'm doing here > > There are 2 problems.. > > 1. I

Re: [go-nuts] Unexpected behaviour with LD_PRELOAD and fopen and cgo

2018-01-15 Thread Ian Lance Taylor
fferent C file, with the right signature, that calls go_fopen64. Ian > On Monday, January 15, 2018 at 2:35:19 PM UTC-5, Ian Lance Taylor wrote: >> >> You neglected to say which system you are running on. If it's >> GNU/Linux, note that fopen64 is not declared by default

Re: [go-nuts] Unexpected behaviour with LD_PRELOAD and fopen and cgo

2018-01-15 Thread Ian Lance Taylor
on written in myfopen.c will follow ordinary C rules. If you don't make it static, it will be exported. Ian > On Monday, January 15, 2018 at 3:05:32 PM UTC-5, Ian Lance Taylor wrote: >> >> The simplist workaround is to export go_fopen64, and write a tiny >> fopen64 in a

Re: [go-nuts] SIGSEGV during build of Go from source

2018-01-15 Thread Ian Lance Taylor
On Mon, Jan 15, 2018 at 1:43 PM, wrote: > > My bootstrap Go is a 1.9.2 binary, and I'm trying to compile Go on High > Sierra (MacOS 10.13.2). > > I get a SIGSEGV during test run: > > # cmd/go terminal test > panic: runtime error: invalid memory address or nil pointer dereference > [signal SIG

Re: [go-nuts] Where is the help page of range in go doc?

2018-01-16 Thread Ian Lance Taylor
On Tue, Jan 16, 2018 at 9:05 AM, wrote: > > I don't fine the help page of `range`. Does anybody if there is a way to > find it with `go doc`? > > $ go doc range > doc: /Users/xxx/linux/test/golang/lang/import/strings/Split/main.go:1:1: > illegal character U+0023 '#' > exit status 1 `go doc` is u

Re: [go-nuts] Re: where is the implementation of `getg`?

2018-01-16 Thread Ian Lance Taylor
On Tue, Jan 16, 2018 at 5:51 PM, Dave Cheney wrote: > A long time ago getg was written in assembly in the runtime package. These > days it is implemented directly as pseudo instruction in the compiler. > Search for OpGetG in $GOROOT/src/cmd/compile/internal Yes. The simplest way to see the gener

Re: [go-nuts] Effective Go recommends reading the language specification first

2018-01-16 Thread Ian Lance Taylor
On Tue, Jan 16, 2018 at 6:40 PM, wrote: > > It strikes me as odd that Effective Go recommends reading the language > specification first. > > "This document gives tips for writing clear, idiomatic Go code. It augments > the language specification, the Tour of Go, and How to Write Go Code, all of

Re: [go-nuts] Effective Go recommends reading the language specification first

2018-01-17 Thread Ian Lance Taylor
On Wed, Jan 17, 2018 at 3:30 AM, Matt McClure wrote: > > Hard to say until I read both. My original message is based on my experience > with other languages and their specs. The Go spec is intended to be as readable as possible. Ian > On Wed, Jan 17, 2018 at 01:09 Ian Lance T

Re: [go-nuts] Core team and internal organisation of go project

2018-01-18 Thread Ian Lance Taylor
On Thu, Jan 18, 2018 at 9:23 AM, Davor Kapša wrote: > > How many members has core team? > > How are they internally organised? > (How are they organised on daily bases? How many sub teams exist and how are > they divided?) > > Are they all on Google salaries? We do use the phrase "core team" loos

Re: [go-nuts] where is an online version of older versions like 1.8 1.6 golang pkg doc ?

2018-01-18 Thread Ian Lance Taylor
On Thu, Jan 18, 2018 at 5:32 PM, derek wrote: > like for 1.8 1.6 > > for archeology and other reasons, I am researching a in-house software > written in Golang1.6 > want an online version of golang1.6 doc? > > https://golang.org/doc/go1.6/pkg/encoding/json/ > > https://golang.org/pkg/encoding/json

Re: [go-nuts] what does 'go.info,go.range' mean in golang asm?

2018-01-18 Thread Ian Lance Taylor
On Thu, Jan 18, 2018 at 6:21 PM, sheepbao wrote: > > I wrote this code add.go: > package asm > > func add(a, b int) int { >return a + b > } > > then I compile this code to asm: > go tool compile -S add.go > the output is: > "".add STEXT nosplit size=19 args=0x18 locals=0x0 >0x 0 (a

Re: [go-nuts] where is an online version of older versions like 1.8 1.6 golang pkg doc ?

2018-01-19 Thread Ian Lance Taylor
On Fri, Jan 19, 2018 at 9:49 AM, derek wrote: > On Thu, Jan 18, 2018 at 7:39 PM, Ian Lance Taylor wrote: >>> Like for Nodejs, and Python and many other language has permanent >>> archived docs for olders versions: >>> >>> https://nodejs.org/docs/v8.4.

Re: [go-nuts] Can go files be nested in package?

2018-01-20 Thread Ian Lance Taylor
On Sat, Jan 20, 2018 at 3:56 PM, Peng Yu wrote: > > The following example shows that go files cannot be nested in a > package. Is it so that the go files in a package must be at the root > level of the package? Yes, the go tool expects that all files in a single package will be in the same direct

Re: [go-nuts] Doc mentioned it's possible to inspect unexported methods using reflect, but I can't figure out how

2018-01-20 Thread Ian Lance Taylor
On Sat, Jan 20, 2018 at 8:43 PM, Glen Huang wrote: > > The doc for the method type in the reflect package > (https://golang.org/pkg/reflect/#Method) seems to suggest that it's possible > to inspect a type's unexported methods: > > // PkgPath is the package path that qualifies a lower case

Re: [go-nuts] Re: Go 1.9.3 is released

2018-01-22 Thread Ian Lance Taylor
[ +andybons ] On Mon, Jan 22, 2018 at 6:10 PM, wrote: > Hi Go team, > > It seems that the go1.9.3 tag is not on the good commit,, it's not possible > to do `git checkout go1.9.3`. > > - current go1.9.3 tag: > https://github.com/golang/go/commit/26b65a4816384072b3abd0c76b969a7940fd4ea0 > - curren

Re: [go-nuts] How to get mount point or device name by directory?

2018-01-23 Thread Ian Lance Taylor
On Mon, Jan 22, 2018 at 10:11 PM, Matrix Neo wrote: > > I want to get the mount point or device name (like /dev/sda1) by the > directory name. I try my best only to find syscall.Stat_t struct but there > is no field to > point the information i need. So is there any way to implement this ? Y

Re: [go-nuts] Re: Nil Channels and Case Evaluation

2018-01-23 Thread Ian Lance Taylor
On Tue, Jan 23, 2018 at 5:44 AM, dc0d wrote: > > Can anybody help me understand the reason? (It's in the spec. That's not the > reason) It gives a precise order of evaluation of the select statement. Consider case f1() <- f2(): It's useful to specify the order in which f1 and f2 are evaluate

Re: [go-nuts] How to get mount point or device name by directory?

2018-01-23 Thread Ian Lance Taylor
data. > It's ok to use findmnt to get /dev/sda3. But if the given dir is > /data/test1, > the findmnt returns nothing. Sorry the suggestion didn't help, but in any case this is a GNU/Linux question, not a Go question as such. Ian > 在 2018年1月23日星期二 UTC+8下午10:39:58,Ian Lance Tayl

Re: [go-nuts] Ensuring resource cleanup when app is killed

2018-01-24 Thread Ian Lance Taylor
On Tue, Jan 23, 2018 at 11:20 PM, Sundar Nadathur wrote: > > My golang application creates UNIX sockets in specific paths: > /mypath/name1.sock, /mypath/name2.sock etc. It then launches a go routine > that listens to one or more of those sockets. I need to ensure that they get > cleaned up (remove

Re: [go-nuts] Re: Nil Channels and Case Evaluation

2018-01-24 Thread Ian Lance Taylor
On Tue, Jan 23, 2018 at 10:13 PM, dc0d wrote: > > The third option was the expected one. Locking aside (as the thought line > behind the original question), the time spent on preparing/calculating a > result value to be sent to a channel, is not directly relevant to the case > for nil channels - w

Re: [go-nuts] syscall.SetNonblock stopped working in Go 1.9.3

2018-01-25 Thread Ian Lance Taylor
On Wed, Jan 24, 2018 at 8:06 PM, Dave Keck wrote: > > Hey all, this program exits (as expected) when run with macOS 10.12.6 + Go > 1.8.6, but it deadlocks when run with Go 1.9.3: > > https://play.golang.org/p/Dw_ND9gkgPm > > The same behavior is observed when using unix.SetNonblock instead of

Re: [go-nuts] syscall.SetNonblock stopped working in Go 1.9.3

2018-01-25 Thread Ian Lance Taylor
On Thu, Jan 25, 2018 at 7:04 AM, Max wrote: > > Thanks for the explanation and the solution :) > > Where is this behaviour documented? > > The current documentation https://golang.org/pkg/os does not indicate > blocking vs non blocking behaviour of *os.File and of functions that return > *os.File,

Re: [go-nuts] Re: "Try Go" in golang.org stopped working properly?

2018-01-27 Thread Ian Lance Taylor
[ +andybons, bradfitz ] Looks like something has gone wrong with the play.golang.org caching. Ian On Sat, Jan 27, 2018 at 10:18 AM, wrote: > I see the same thing. Changing even one character fixes the problem. Even > just adding white space to the code. If I copy the example from > https://gol

Re: [go-nuts] Shared stdlib questions

2018-01-27 Thread Ian Lance Taylor
On Sat, Jan 27, 2018 at 1:44 AM, Serhat Şevki Dinçer wrote: > > On Manjaro 64-bit with go 1.9.3 I am doing: > go install -gcflags '-B -s' -ldflags '-s -w' -buildmode shared std > > I get two warnings many times: > go/src/unicode/casetables.go:17:11: redundant type: CaseRange > go/src/vendor/golang

Re: [go-nuts] Use and redeclare same variable in block

2018-01-28 Thread Ian Lance Taylor
On Sun, Jan 28, 2018 at 12:53 AM, Wenbin Shang wrote: > > The following code: > > package main > > import "fmt" > > func main() { > var i int > fmt.Println(i) > if true { > i = 5 > i, j := 3, 4 > fmt.Println(i, j) > } > fmt.Println(i) > } > > Output: > 0

Re: [go-nuts] is it normal for buildmode=shared and buildmode=c-shared to be ok with building package main with no exported functions?

2018-01-28 Thread Ian Lance Taylor
On Sun, Jan 28, 2018 at 10:06 AM, wrote: > > Was looking through the issues tracker and saw someone having issues with > trying to use buildmode=c-shared and I noticed he linked a package main with > only a main function as the thing he is trying to build. > > So for lulz I tried building it with

Re: [go-nuts] How many Go compilers are out there?

2019-04-25 Thread Ian Lance Taylor
On Thu, Apr 25, 2019 at 8:29 AM JuciÊ Andrade wrote: > > These are the ones I am aware of: > > . GC toolchain > . GCC > . gopherjs > > By Go compiler I mean any tool that understands Go source files and generates > executable code. There is also llgo (though I'm not sure if that one still works)

Re: [go-nuts] Pass value from C code to GO code(CGO)

2019-04-26 Thread Ian Lance Taylor
On Fri, Apr 26, 2019 at 4:41 AM Nitish Saboo wrote: > > Thanks for the info. Jan.My main issue is how can I access the value on Go > side after some manipulation within the C code ? You do it exactly as though you passed a pointer to a Go function, and then accessed the value after the Go functi

Re: [go-nuts] Go if else syntax .. suggested replacement

2019-04-26 Thread Ian Lance Taylor
On Thu, Apr 25, 2019 at 10:57 PM Mike Schinkel wrote: > > Marcus Low wrote: >> >> datalen := removedKeyken // removedKeyken must have been int32 in your >> example. >> if value != nil { >>datalen = len(value) >> } > > > The issue with this is it makes two assignments when value != nil instead

Re: [go-nuts] cracking the go language aplication

2019-04-26 Thread Ian Lance Taylor
On Fri, Apr 26, 2019 at 5:36 AM smn shilla wrote: > > Hi > any luck please We can't help you because we don't know what you want. You need to explain what you are after in a way that we can understand. Ian > On Thursday, 18 April 2019 00:12:05 UTC+3, Tyler Compton wrote: >> >> Could you provi

Re: [go-nuts] Random panic in production with Sprintf

2019-05-02 Thread Ian Lance Taylor
On Thu, May 2, 2019 at 10:31 AM XXX ZZZ wrote: > > We are having a random panic on our go application that is happening once > every million requests or so, and so far we haven't been able to reproduce it > nor to even grasp what's going on. > > Basically our code goes like: > > type Subid_info

Re: [go-nuts] Random panic in production with Sprintf

2019-05-02 Thread Ian Lance Taylor
On Thu, May 2, 2019 at 11:18 AM Marcin Romaszewicz wrote: > > If that's the actual problem, you'd just be masking it, and producing an > invalid "x". Look here: > > func (r *Subid_info) Prepare_subid_logic(){ > r.Second_subid_8=fmt.Sprintf("1%07v", r.Second_subid) > panic happens > here.

Re: [go-nuts] Re: Random panic in production with Sprintf

2019-05-02 Thread Ian Lance Taylor
On Thu, May 2, 2019 at 2:50 PM Anthony Martin wrote: > > What version of Go are you using? > > XXX ZZZ once said: > > fmt.(*pp).fmtString(0xc023c17740, 0x0, 0x5, 0xc00076) > > /usr/local/go/src/fmt/print.go:448 +0x132 > > fmt.(*pp).printArg(0xc023c17740, 0x9978e0, 0xc016a68a30, 0x76) > >

Re: [go-nuts] Re: the Dominance of English in Programming Languages

2019-05-03 Thread Ian Lance Taylor
On Fri, May 3, 2019 at 7:28 AM Louki Sumirniy wrote: > > It would be incredibly computationally costly to add a natural language > translator to the compilation process. I'm not sure, but I think also > identifiers in Go can only be plain ASCII, ie pure latin script (and initial > character mus

Re: [go-nuts] Re: What does "identifier...type" mean in a function definition?

2019-05-03 Thread Ian Lance Taylor
On Fri, May 3, 2019 at 7:34 AM Louki Sumirniy wrote: > > The ellipsis has two uses in Go, one is in variadic parameters, the other is > in the slice append operator. It is essentially an iterator that takes a list > and turns it into a slice (parameters) or takes a slice and turns it into a > r

Re: [go-nuts] Re: What does "identifier...type" mean in a function definition?

2019-05-03 Thread Ian Lance Taylor
ther variadic function. Ian > On Friday, 3 May 2019 16:44:47 UTC+2, Ian Lance Taylor wrote: >> >> On Fri, May 3, 2019 at 7:34 AM Louki Sumirniy >> wrote: >> > >> > The ellipsis has two uses in Go, one is in variadic parameters, the other >> > i

Re: [go-nuts] Re: the Dominance of English in Programming Languages

2019-05-03 Thread Ian Lance Taylor
On Fri, May 3, 2019 at 8:25 AM Louki Sumirniy wrote: > > https://en.wikipedia.org/wiki/Unicode#General_Category_property > > This section in the wp entry lists these categories. > > So, in Go, actually, all identifiers can be in practically any language. Even > many of those funny african scripts

Re: [go-nuts] Re: What does "identifier...type" mean in a function definition?

2019-05-03 Thread Ian Lance Taylor
iterator. Ian > On Friday, 3 May 2019 19:13:02 UTC+2, Ian Lance Taylor wrote: >> >> On Fri, May 3, 2019 at 7:57 AM Louki Sumirniy >> wrote: >> > >> > Ellipsis makes the parameter type into a slice, but in append it makes the >> > append repe

Re: [go-nuts] If Go is using libc instead of syscalls on macOS now, why is it not shown via otool -L?

2019-05-03 Thread Ian Lance Taylor
On Fri, May 3, 2019 at 11:38 AM wrote: > > I read the following from one of the contributors: > > > On Solaris (and Windows), and more recently in macOS as well we link with > > libc (or equivalent). > > Go used to do raw system calls on macOS, and binaries were occasionally > > broken by kernel

Re: [go-nuts] Re: What does "identifier...type" mean in a function definition?

2019-05-03 Thread Ian Lance Taylor
On Fri, May 3, 2019 at 11:19 AM wrote: > > Am I missing something ?? > When u say : > For any function F and some type T declared asfunc F(x ...T) {} > within F x will have type []T. You can call F with a slice s of type []T as > F(s...) > > Why is this needed ?? What's the point of using

Re: [go-nuts] If Go is using libc instead of syscalls on macOS now, why is it not shown via otool -L?

2019-05-03 Thread Ian Lance Taylor
On Fri, May 3, 2019 at 3:21 PM wrote: > > Indeed, it works with Go 1.12. I have 3 different Go versions, and my > aliasing was messed up. Sorry. > > > No. The Linux kernel, fortunately, supports static linking and provides a > > stable syscall API. There is no reason to make this change on GNU

Re: [go-nuts] If Go is using libc instead of syscalls on macOS now, why is it not shown via otool -L?

2019-05-03 Thread Ian Lance Taylor
On Fri, May 3, 2019 at 3:36 PM wrote: > > I know that calling C functions via cgo is relatively expensive because of > the goroutines, so there must be some optimizations/tricks to make all these > libc calls fast. Yes, this only uses part of the cgo call path, not all of it. In particular the

Re: [go-nuts] Is it possible to use the Go linker to link C object files?

2019-05-03 Thread Ian Lance Taylor
On Fri, May 3, 2019 at 4:25 PM wrote: > > Go linker is amazing. It's the only truly cross platform linker. > > Is it possible to use it to create binaries from object files compiled with C? Not really. It only really understands Go code. It understands just enough C code to handle internal link

Re: [go-nuts] Using cgo with go modules

2019-05-06 Thread Ian Lance Taylor
On Mon, May 6, 2019 at 12:37 PM wrote: > > Hello, > I am trying to adopt my cgo package with go modules. > The cgo project I mentioned above is built using simple Makefile so that I > obtain external shared library(.so on Unixes and .dll on Windows) to link > external applications(from other mod

Re: [go-nuts] What is the current status of generics in Go?

2019-05-06 Thread Ian Lance Taylor
On Mon, May 6, 2019 at 9:22 AM 'kalekold' via golang-nuts wrote: > > I saw a design document floating about sometime last year and there seemed to > be a lot of thought going into implementing them? What is the current status > and where can I read more? Thanks. There is continuing thought. Th

Re: [go-nuts] Is renewal of expired context possible?

2019-05-06 Thread Ian Lance Taylor
On Sun, May 5, 2019 at 11:13 AM wrote: > > Hi, Is there a way to renew a context that has already reached a deadline? No, sorry. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from

Re: [go-nuts] Re: Web access to golang-dev is down

2019-05-07 Thread Ian Lance Taylor
On Tue, May 7, 2019 at 4:05 AM peterGo wrote: > > Liam, > > "Web access to golang-dev is down" is too vague. Please be more precise. For > example, my recent experience: > > For the past few days, browsing to golang-dev without logging on, I get an > error: > > https://groups.google.com/forum/#!

Re: [go-nuts] A question about A sync.Once implementation.

2019-05-07 Thread Ian Lance Taylor
On Tue, May 7, 2019 at 5:55 AM wrote: > > Hi, > I did a quiz recently, but I'm having problem with the answer. > Quiz: https://github.com/smallnest/go-concurrent-quiz#-quiz-4 When sending code, please just send plain text or a link to play.golang.org. Thanks. I can't actually re

Re: [go-nuts] Re: Web access to golang-dev is down

2019-05-07 Thread Ian Lance Taylor
On Tue, May 7, 2019 at 7:22 AM JuciÊ Andrade wrote: > > Me too. I can't access golang-dev. > "An error (#401) occurred while communicating with the server." OK, if people are comfortable with it, it would help to know browser version and IP address and whether you can access other groups such as

Re: [go-nuts] Re: Web access to golang-dev is down

2019-05-07 Thread Ian Lance Taylor
On Tue, May 7, 2019 at 8:01 AM Marcin Romaszewicz wrote: > > The same for me. golang-dev is not accessible to me, nor does it show up in a > group search, meaning it's not visible to me. I'm not a registered member of > it, so it appears to no longer be a public group. Thanks for all the info.

Re: [go-nuts] Using cgo with go modules

2019-05-09 Thread Ian Lance Taylor
On Thu, May 9, 2019 at 8:21 AM wrote: > > Thanks for the reply. > Is there any automatic way to build a dynamic library that cgo-package > depends on? No, I don't think so. > I have the following line in sources of my cgo package(I have the dynamic > library libcl3go.so in cwrap folder): > //

Re: [go-nuts] Using archive ".a" at time of build

2019-05-10 Thread Ian Lance Taylor
On Fri, May 10, 2019 at 10:56 AM wrote: > > I have certain utility package which can be used by multiple projects. > Now in place of copying complete utility code in all of these projects at > time of building that project, I need to use archive file . > > So, I generated and it is placed in $GO

Re: [go-nuts] Using archive ".a" at time of build

2019-05-10 Thread Ian Lance Taylor
On Fri, May 10, 2019 at 11:35 AM wrote: > > Thanks for update. > But than it is confusing, what is use of ".a" files ? > Where we can use it ? Especially when using module mode with Go 1.12 and future releases, ".a" files are an internal detail of how Go programs are built. You aren't expected t

Re: [go-nuts] go runtime in DLL not getting intialized(?) on some windows hosts

2019-05-10 Thread Ian Lance Taylor
On Fri, May 10, 2019 at 1:43 PM Jason E. Aten wrote: > > I wondering if anyone can shed some light on > > a) how I might understand when the Go runtime inside a DLL is supposed to be > initialized; In c-shared mode the function _rt0_amd64_windows_lib is supposed to be called when the DLL is init

Re: [go-nuts] Build constraints and preceding non-line comments

2019-05-13 Thread Ian Lance Taylor
On Mon, May 13, 2019 at 10:39 AM Neil Schellenberger wrote: > > The documentation of build constraints says, in part (emphasis mine): > >> Constraints may appear in any kind of source file (not just Go), but they >> must appear near the top of the file, preceded only by blank lines and other >>

Re: [go-nuts] bool in go/ast.filterParamList

2019-05-13 Thread Ian Lance Taylor
On Mon, May 13, 2019 at 1:01 PM wrote: > > While studying the go/ast package, I stumbled upon the following: > https://golang.org/src/go/ast/filter.go#L140 > > Unless I am missing something, shouldnt this just be: > https://play.golang.org/p/uQJ3XtEcgWE ? The filterType function is not a pure p

Re: [go-nuts] Re: guarantees on net.Conn and net.UDPConn Read

2019-05-13 Thread Ian Lance Taylor
On Mon, May 13, 2019 at 2:45 PM Dan Kortschak wrote: > > Thanks, Jake. This was very helpful. It does seem that the docs in this area should be improved. Alas. Ian > On Mon, 2019-05-13 at 09:19 -0700, jake6...@gmail.com wrote: > > On Thursday, May 9, 2019 at 2:54:17 AM UTC-4, kortschak wrote:

Re: [go-nuts] Using archive ".a" at time of build

2019-05-13 Thread Ian Lance Taylor
On Mon, May 13, 2019 at 6:55 AM wrote: > > Is there any other way in Go, using which we can hide code of common > utilities and still it can be used in different projects (like static and > dynamic libraries in C). Not at present. You may want to look at the discussion around https://golang.or

Re: [go-nuts] Any way to prevent gc emitting AVX256 and AVX512 instructions for amd64?

2019-05-14 Thread Ian Lance Taylor
On Tue, May 14, 2019 at 2:18 AM Amnon Baron Cohen wrote: > > I am trying to avoid running any AVX instructions in order to prevent Intel's > dynamic frequency scaling > reducing my CPU base frequency. You should be able to avoid AVX instructions at runtime by setting the environment variable GOD

Re: [go-nuts] custom build tags - seeing which files get selected

2019-05-14 Thread Ian Lance Taylor
On Tue, May 14, 2019 at 5:41 AM 'White Hexagon' via golang-nuts wrote: > > My project is growing and I have started using custom build tags. When I > build the project I would really like to see a list of all the files that > have been selected based on the tags I have requested. Is that possi

Re: [go-nuts] Any way to prevent gc emitting AVX256 and AVX512 instructions for amd64?

2019-05-14 Thread Ian Lance Taylor
On Tue, May 14, 2019 at 7:03 AM Amnon Baron Cohen wrote: > > go version > go version go1.12.5 linux/amd64 > > GODEBUG=cpu.avx=off go build hello.go > > objdump -d hello | grep '%ymm' > 4021bd: c5 fe 6f 16 vmovdqu (%rsi),%ymm2 > 4021c1: c5 fe 6f 1f vmovdqu (%rdi),%ymm3 > 40

Re: [go-nuts] Passing structures containing other pointers to ioctl: Go vs Cgo memory

2019-05-17 Thread Ian Lance Taylor
On Thu, May 16, 2019 at 5:24 AM Matt Layher wrote: > > I'm working on a project that involves an ioctl API on OpenBSD. The idea is > that you store a memory address in a union within another structure, and then > invoke the ioctl. When it returns, both the structure itself and the memory > poin

Re: [go-nuts] Passing structures containing other pointers to ioctl: Go vs Cgo memory

2019-05-17 Thread Ian Lance Taylor
of Cgo at this point. Although I'd rather not if it were > deemed safe to go with my original pure Go approach. Allocating the memory with cgo is safe. It would also be safe to allocate the memory in some way other than using Go's memory allocator, such as by using syscall.Mmap. Ian

Re: [go-nuts] Go linker efficiency

2019-05-17 Thread Ian Lance Taylor
On Fri, May 17, 2019 at 9:12 PM Tong Sun wrote: > > How efficient Go linker is in detecting unused things (e.g., functions) in a > package during build and remove them from the compiled binary? > > To extremely simplify the case, say > > - I have a package that contains 10 individual functions, a

Re: [go-nuts] Go linker efficiency

2019-05-18 Thread Ian Lance Taylor
On Sat, May 18, 2019 at 6:01 AM Tong Sun wrote: > > On Saturday, May 18, 2019 at 1:52:43 AM UTC-4, Ian Lance Taylor wrote: >> >> On Fri, May 17, 2019 at 9:12 PM Tong Sun wrote: >> > >> > How efficient Go linker is in detecting unused things (e.g., functions)

Re: [go-nuts] binary compiled by golang 1.10 not working in golang 1.12 environment

2019-05-21 Thread Ian Lance Taylor
On Tue, May 21, 2019 at 11:14 PM wrote: > > Not sure someone reported this issue. > > Recently I had my golang compiler upgraded from 1.10.3 to 1.12.5. > A binary tool was built by 1.10 reported following errors when I executed it. > Obviously it's trying to include both x86 & AIX arch code, whic

Re: [go-nuts] Re: io.Copy and Writer

2019-05-22 Thread Ian Lance Taylor
On Wed, May 22, 2019 at 9:02 AM Robert Engels wrote: > > The more I think about this, the more I believe that this is a horrible > situation that breaks all rules of encapsulation. This requires the creator > to maintain references to the underlying Writer. It also requires the creator > to be

Re: [go-nuts] Aggressive Golang Garbage Collection Issues When Using cgo?

2019-05-22 Thread Ian Lance Taylor
On Wed, May 22, 2019 at 8:34 PM Steven Estes wrote: > > At this point, it seems, since there were no more references to the passed-in > Golang structures and the C pointers we had pulled out of them had been > morphed to uintptr values, that the Golang structures became eligible for > garbage c

<    4   5   6   7   8   9   10   11   12   13   >