# Go SDK: non-deterministic error

**URL:** <https://community.temporal.io/t/go-sdk-non-deterministic-error/12393>\
**Category:** Community Support\
**Created:** [June 6, 2024, 1:43pm UTC](https://community.temporal.io/t/go-sdk-non-deterministic-error/12393 "2024-06-06T13:43:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ingmar](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ingmar/32/5054_2.png) [@Ingmar](https://community.temporal.io/u/Ingmar)\
**Post date:** [June 6, 2024, 1:43pm UTC](https://community.temporal.io/t/go-sdk-non-deterministic-error/12393/1 "2024-06-06T13:43:08Z")

</div>

We saw this error recently:

```txt
unknown command CommandType: Timer, ID: XXXX, possible causes are nondeterministic workflow definition code or incompatible change in the workflow definition

```

This is from a scheduled workflow. One activity was changed but the main workflow definition was untouched. We added an event publisher to the struct that implements the workflow. The event is published from an activity.

Can deployments of updated binaries cause this for scheduled workflows?

Example code:

```go
type eventPublisher interface {
	PublishEvent(ctx context.Context)
}

type Workflow struct {
	eventPublisher eventPublisher // this was added
}

// this function wasn't touched at all
func (w *Workflow) DoSomething(ctx workflow.Context) error {
	if err := workflow.ExecuteActivity(ctx, w.DoSomeActivity).Get(ctx, nil); err != nil {
		return err
	}
	return nil
}

func (w *Workflow) DoSomeActivity(ctx context.Context) error {
	// do something

	// we added something like this:
	w.eventPublisher.PublishEvent(ctx)
	return nil
}

```

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [June 7, 2024, 2:30am UTC](https://community.temporal.io/t/go-sdk-non-deterministic-error/12393/2 "2024-06-07T02:30:36Z")

</div>

I don’t think your published code would cause a deterministic failure.

We recommend against using structures to define workflow function, use them only for activities.

---

<div class="post-metadata">

**Author:** ![Ingmar](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ingmar/32/5054_2.png) [@Ingmar](https://community.temporal.io/u/Ingmar)\
**Post date:** [June 7, 2024, 7:13am UTC](https://community.temporal.io/t/go-sdk-non-deterministic-error/12393/3 "2024-06-07T07:13:28Z")

</div>

Ok, thanks for the quick reply!

For anyone else looking for answers: it was fixed by deleting the schedule and recreating it through the new deployment.

As for:

> We recommend against using structures to define workflow function, use them only for activities.

Good to know, maybe it should be explicitly mentioned here?

> **[Core application - Temporal Go SDK feature guide | Temporal Documentation](https://docs.temporal.io/develop/go/core-application#develop-workflows)**
>
> The Foundations section of the Temporal Developer's guide introduces essential concepts for building and running a Temporal Application, outlining steps to start Workflow and Activity Execution, running development Workers, and installing the...

Yes, you can see this best practice in the examples, but I think it’s too easy to end up bundling it as a struct.
