# Bug in os.Args?

**URL:** https://talk.remobjects.com/t/bug-in-os-args/21639
**Category:** Gold
**Tags:** island
**Created:** [March 20, 2020, 10:08pm UTC](https://talk.remobjects.com/t/bug-in-os-args/21639 "2020-03-20T22:08:46Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![ormente](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ormente/32/7519_2.png) [@ormente](https://talk.remobjects.com/u/ormente)
#### Post date: [March 20, 2020, 10:08pm UTC](https://talk.remobjects.com/t/bug-in-os-args/21639/1 "2020-03-20T22:08:46Z")

</div>

Hi!

I wanted to try Gold and made some very basic command line apps. When i tried to access os.Args i ran into troubles: it seems to allways return an empty array on island widows (while working fine for .net).

Is this a known bug?

Thanks

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [March 20, 2020, 10:30pm UTC](https://talk.remobjects.com/t/bug-in-os-args/21639/2 "2020-03-20T22:30:50Z")

</div>

> [@ormente](#):
>
> Is this a known bug?

Not a _known_ bug, But certainly looks like a bug; I’ll have this looked at ASAP.

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [March 20, 2020, 10:30pm UTC](https://talk.remobjects.com/t/bug-in-os-args/21639/3 "2020-03-20T22:30:53Z")

</div>

Thanks, logged as [bugs://84090](https://www.remobjects.com/portal/bugs/?id=84090)

---

<div class="post-metadata">

### Author: ![ormente](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ormente/32/7519_2.png) [@ormente](https://talk.remobjects.com/u/ormente)
#### Post date: [March 21, 2020, 12:50pm UTC](https://talk.remobjects.com/t/bug-in-os-args/21639/4 "2020-03-21T12:50:09Z")

</div>

Thanks a lot, Marc.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [March 21, 2020, 2:08pm UTC](https://talk.remobjects.com/t/bug-in-os-args/21639/5 "2020-03-21T14:08:09Z")

</div>

Of course!

---

<div class="post-metadata">

### Author: ![ormente](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ormente/32/7519_2.png) [@ormente](https://talk.remobjects.com/u/ormente)
#### Post date: [March 21, 2020, 9:45pm UTC](https://talk.remobjects.com/t/bug-in-os-args/21639/6 "2020-03-21T21:45:19Z")

</div>

BTW it seems there is also a problem with “time” on island windows. This code :

> ```
> start := time.Now()
> time.Sleep(200 * time.Millisecond)
> t := time.Now()
> fmt.Printf("Elapsed: %v mcs.\n", t.Sub(start).Microseconds())
> fmt.Printf("Elapsed: %v ms.\n", t.Sub(start).Milliseconds())
> fmt.Printf("Elapsed: %v ms.\n", t.Sub(start).Seconds()*1000)
> 
> ```

displays :

> ```
> Elapsed: 20 mcs.
> Elapsed: 0 ms.
> Elapsed: 0.0203 ms.
> 
> ```

While compiled for .net it prints the correct :

> ```
> Elapsed: 201246 mcs.
> Elapsed: 201 ms.
> Elapsed: 201.2467 ms.
> 
> ```

From an external timer it looks like both apps sleeps for about 200ms.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [March 22, 2020, 1:16pm UTC](https://talk.remobjects.com/t/bug-in-os-args/21639/7 "2020-03-22T13:16:03Z")

</div>

> [@ormente](#):
>
> From an external timer it looks like both apps sleeps for about 200ms.

So Sleep works correctly, “just” either t.Sub() seems to be broken? Logging.

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [March 22, 2020, 1:16pm UTC](https://talk.remobjects.com/t/bug-in-os-args/21639/8 "2020-03-22T13:16:14Z")

</div>

Thanks, logged as [bugs://84092](https://www.remobjects.com/portal/bugs/?id=84092)

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [March 22, 2020, 1:17pm UTC](https://talk.remobjects.com/t/bug-in-os-args/21639/9 "2020-03-22T13:17:00Z")

</div>

> [@ormente](#):
>
> BTW it seems there is also a problem with “time” on island windows. This code :

I’ll make sure both pf these get looked at tomorrow.

---

<div class="post-metadata">

### Author: ![ormente](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ormente/32/7519_2.png) [@ormente](https://talk.remobjects.com/u/ormente)
#### Post date: [March 22, 2020, 1:57pm UTC](https://talk.remobjects.com/t/bug-in-os-args/21639/10 "2020-03-22T13:57:22Z")

</div>

Yes, Sleep seems to work corectly. Changing the value is correctly reflected in the total run time measured externaly.

No emergency here, but thanks again! 👏 👍

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [March 22, 2020, 2:38pm UTC](https://talk.remobjects.com/t/bug-in-os-args/21639/11 "2020-03-22T14:38:53Z")

</div>

> [@ormente](#):
>
> I wanted to try Gold and made some very basic command line apps. When i tried to access os.Args i ran into troubles: it seems to allways return an empty array on island widows (while working fine for .net).

Guess this explains it somewhat:

```oxygene
var Args: go.builtin.Slice<go.builtin.string> := {$IF ISLAND}new go.builtin.Slice<go.builtin.string>(''){raise new NotImplementedException}{$ELSEIF ECHOES}go.builtin.string.PlatformStringArrayToGoSlice(Environment.GetCommandLineArgs){$ENDIF};

```

😂

workaround for now: if you define your main() menthod to accept a string array, you should get the arguments there, ok.

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [March 25, 2020, 3:09pm UTC](https://talk.remobjects.com/t/bug-in-os-args/21639/12 "2020-03-25T15:09:47Z")

</div>

[bugs://84090](https://www.remobjects.com/portal/bugs/?id=84090) got closed with status fixed.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [March 27, 2020, 2:39pm UTC](https://talk.remobjects.com/t/bug-in-os-args/21639/13 "2020-03-27T14:39:03Z")

</div>

> [@RemObjectsSoftware](#):
>
> [bugs://84090](https://www.remobjects.com/portal/bugs/?id=84090) got closed with status fixed.

This was fixed, but I’m afraid we neglected to run a new full release build of GBL (which takes a long time 😉 prior to starting todays build, so 2497 will not have this fix. I can sen you a copy of the fixed GBL tomorrow (or you can build it yourself from github of course; I recommend only building the target you need, then, to seep it up ;).

---

<div class="post-metadata">

### Author: ![ormente](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ormente/32/7519_2.png) [@ormente](https://talk.remobjects.com/u/ormente)
#### Post date: [March 27, 2020, 6:02pm UTC](https://talk.remobjects.com/t/bug-in-os-args/21639/14 "2020-03-27T18:02:11Z")

</div>

Again, thanks a lot Marc. Nothing blocking here for me, I’m just playing and learning so I will explore other parts of Element during the next week (if time permits). 🙂

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [March 31, 2020, 5:43pm UTC](https://talk.remobjects.com/t/bug-in-os-args/21639/15 "2020-03-31T17:43:02Z")

</div>

[bugs://84092](https://www.remobjects.com/portal/bugs/?id=84092) got closed with status fixed.

---

<div class="post-metadata">

### Author: ![ormente](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ormente/32/7519_2.png) [@ormente](https://talk.remobjects.com/u/ormente)
#### Post date: [May 13, 2020, 10:55pm UTC](https://talk.remobjects.com/t/bug-in-os-args/21639/16 "2020-05-13T22:55:08Z")

</div>

Back to the game after a pause, and purchasing a (personal) licence. The numbers are now good on Windows, but the last attempt to display makes the program block (using 10.0.0.2509).

```
func main() {
    start := time.Now()
    time.Sleep(200 * time.Millisecond)
    t := time.Now()

    // OK
    fmt.Printf("Elapsed: %d mcs.\n", t.Sub(start).Microseconds())
    fmt.Printf("Elapsed: %d ms.\n", t.Sub(start).Milliseconds())

    // Possible hint at the bug cause
    fmt.Printf("%T \n", t.Sub(start).Milliseconds()) // -> go.builtin.int64
    fmt.Printf("%T \n", t.Sub(start).Seconds()) // -> RemObjects.Elements.System.Double

    // Program hangs !
    fmt.Printf("Elapsed: %f ms.\n", 1000*t.Sub(start).Seconds())
}
```

---

<div class="post-metadata">

### Author: ![ormente](https://talk.remobjects.com/user_avatar/talk.remobjects.com/ormente/32/7519_2.png) [@ormente](https://talk.remobjects.com/u/ormente)
#### Post date: [May 25, 2020, 9:55pm UTC](https://talk.remobjects.com/t/bug-in-os-args/21639/17 "2020-05-25T21:55:58Z")

</div>

Tested it with 2517 and the behavior is the same.

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [May 25, 2020, 10:03pm UTC](https://talk.remobjects.com/t/bug-in-os-args/21639/18 "2020-05-25T22:03:55Z")

</div>

Renaud,

> [@ormente](#):
>
> ested it with 2517 and the behavior is the same.

My apologies; it seems I missed rour last reply, and that issue was never logged. doing now.

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [May 25, 2020, 10:05pm UTC](https://talk.remobjects.com/t/bug-in-os-args/21639/19 "2020-05-25T22:05:21Z")

</div>

Thanks, logged as [bugs://84358](https://www.remobjects.com/portal/bugs/?id=84358)

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [November 17, 2021, 9:08am UTC](https://talk.remobjects.com/t/bug-in-os-args/21639/20 "2021-11-17T09:08:36Z")

</div>

[bugs://E24152](https://www.remobjects.com/portal/bugs/?id=E24152) was closed as fixed.
