# Executing a Workflow from Application Code

**URL:** <https://community.temporal.io/t/executing-a-workflow-from-application-code/11662>\
**Category:** Training\
**Tags:** edu-101-go\
**Created:** [April 8, 2024, 9:43am UTC](https://community.temporal.io/t/executing-a-workflow-from-application-code/11662 "2024-04-08T09:43:11Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![scott\_molinari](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/scott_molinari/32/5187_2.png) [@scott\_molinari](https://community.temporal.io/u/scott_molinari)\
**Post date:** [April 8, 2024, 9:43am UTC](https://community.temporal.io/t/executing-a-workflow-from-application-code/11662/1 "2024-04-08T09:43:11Z")

</div>

Hi,

Using the example code for a workflow in the tutorial " Executing a Workflow from Application Code", I’m using Go 1.21.1 and getting an error.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/2X/7/7e70e0e0e133a3e6c6e69ae51e7ed0baf8109edc.png)

Would love a tip as to what dumb mistake I’m making.

Scott

---

<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:** [April 8, 2024, 10:38am UTC](https://community.temporal.io/t/executing-a-workflow-from-application-code/11662/2 "2024-04-08T10:38:43Z")

</div>

> [@scott\_molinari](#):
>
> Executing a Workflow from Application Code

Could you link to the exact page that contains that code?

---

<div class="post-metadata">

**Author:** ![scott\_molinari](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/scott_molinari/32/5187_2.png) [@scott\_molinari](https://community.temporal.io/u/scott_molinari)\
**Post date:** [April 8, 2024, 12:27pm UTC](https://community.temporal.io/t/executing-a-workflow-from-application-code/11662/3 "2024-04-08T12:27:42Z")

</div>

@maxim - [This is the page](https://temporal.talentlms.com/unit/view/id:2123).

Scott

---

<div class="post-metadata">

**Author:** ![tomwheeler](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tomwheeler/32/5441_2.png) [@tomwheeler](https://community.temporal.io/u/tomwheeler)\
**Post date:** [April 8, 2024, 3:00pm UTC](https://community.temporal.io/t/executing-a-workflow-from-application-code/11662/4 "2024-04-08T15:00:12Z")

</div>

This code sample is an excerpt meant to illustrate how you can initiate Workflow Execution from code (i.e., the Go SDK). The `app` package referenced here is a placeholder for the one that would contain your Workflow Definition.

I do see how this might be confusing, so I’ll think of a way to clarify that.

---

<div class="post-metadata">

**Author:** ![tomwheeler](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tomwheeler/32/5441_2.png) [@tomwheeler](https://community.temporal.io/u/tomwheeler)\
**Post date:** [April 8, 2024, 3:23pm UTC](https://community.temporal.io/t/executing-a-workflow-from-application-code/11662/5 "2024-04-08T15:23:32Z")

</div>

I meant to also add that the next exercise in the course (as well as all that follow) use similar code to start the Workflow Execution. You’ll have the opportunity to see and run a complete working example this as you continue in the course. But again, I will also update the course to clarify the example you cited, and I appreciate your feedback.

---

<div class="post-metadata">

**Author:** ![scott\_molinari](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/scott_molinari/32/5187_2.png) [@scott\_molinari](https://community.temporal.io/u/scott_molinari)\
**Post date:** [April 9, 2024, 1:38pm UTC](https://community.temporal.io/t/executing-a-workflow-from-application-code/11662/6 "2024-04-09T13:38:12Z")

</div>

I’ve re-reviewed the course up to the issue I pointed out and see what is happening now.

I think offering the code shown in [the video in “Writing a Workflow Definition”](https://temporal.talentlms.com/unit/view/id:2116) in the text below the video would help.

Edit: In fact, in the “Initializing the Worker” section, this is written:

> The following is an example Go program used to initialize and start a Worker that can run the Workflow Definition shown previously.

Yet, the code is only shown in the video.

I like how the videos are peppered throughout the tutorial, it breaks up the monotony. But, at the same time content only mentioned in a video and not in the text can cause the text content to end up a bit confusing.

Scott

---

<div class="post-metadata">

**Author:** ![tomwheeler](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tomwheeler/32/5441_2.png) [@tomwheeler](https://community.temporal.io/u/tomwheeler)\
**Post date:** [April 9, 2024, 2:32pm UTC](https://community.temporal.io/t/executing-a-workflow-from-application-code/11662/7 "2024-04-09T14:32:01Z")

</div>

Hi Scott,

If you click the “Video Transcript” link directly below the video, it will expand the page to show a complete transcript of everything I said in the video, as well as the code that I showed on screen.

Please let me know if that resolves the issue you reported.

Thanks,

Tom

---

<div class="post-metadata">

**Author:** ![scott\_molinari](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/scott_molinari/32/5187_2.png) [@scott\_molinari](https://community.temporal.io/u/scott_molinari)\
**Post date:** [April 9, 2024, 3:05pm UTC](https://community.temporal.io/t/executing-a-workflow-from-application-code/11662/8 "2024-04-09T15:05:49Z")

</div>

Yeah. Sort of I guess.

I would have not have thought to click open the transcript after watching the video though. 😊

Maybe add “in the video transcript” after “The following is an example Go program used to initialize and start a Worker that can run the Workflow Definition shown previously.”

I’m getting picky now for sure and dancing around the fact that I just wasn’t following things well.

Thanks for the support though. Also not so common. I appreciate that!

Scott

---

<div class="post-metadata">

**Author:** ![tomwheeler](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tomwheeler/32/5441_2.png) [@tomwheeler](https://community.temporal.io/u/tomwheeler)\
**Post date:** [April 9, 2024, 3:27pm UTC](https://community.temporal.io/t/executing-a-workflow-from-application-code/11662/9 "2024-04-09T15:27:33Z")

</div>

I have updated the “Initializing the Worker” page. It now says, “The following is an example Go program used to initialize and start a Worker that can run the Workflow Definition shown **during the previous video (and whose code was included in the transcript for that video)**” (bold text used here to emphasize the part I added).

Thank you for the feedback—I appreciate it!

---

<div class="post-metadata">

**Author:** ![scott\_molinari](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/scott_molinari/32/5187_2.png) [@scott\_molinari](https://community.temporal.io/u/scott_molinari)\
**Post date:** [April 9, 2024, 3:38pm UTC](https://community.temporal.io/t/executing-a-workflow-from-application-code/11662/10 "2024-04-09T15:38:10Z")

</div>

And thank you for being patient with my feedback.

Continuing on with the course now!!! 😁

Scott

---

<div class="post-metadata">

**Author:** ![scott\_molinari](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/scott_molinari/32/5187_2.png) [@scott\_molinari](https://community.temporal.io/u/scott_molinari)\
**Post date:** [April 9, 2024, 4:01pm UTC](https://community.temporal.io/t/executing-a-workflow-from-application-code/11662/11 "2024-04-09T16:01:36Z")

</div>

I’m learning Go too as I go. (haha, pun not intended) 😛

I’ve found out, to import the “app” sub-package, the file or files would need to be in a folder named “app” below the root folder. And to import the functions available in that sub-package, the import would need to be “main/app” (assuming the module is called “main”). Maybe changing the code to import “main/app” might also make more sense? 🤔

Scott

---

<div class="post-metadata">

**Author:** ![scott\_molinari](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/scott_molinari/32/5187_2.png) [@scott\_molinari](https://community.temporal.io/u/scott_molinari)\
**Post date:** [April 10, 2024, 6:29am UTC](https://community.temporal.io/t/executing-a-workflow-from-application-code/11662/12 "2024-04-10T06:29:06Z")

</div>

@tomwheeler - Now that I have downloaded the git repo with the tutorial code, I see where I was making a mental mistake. I was thinking the workflow definition should be below the worker and not the other way around. Learned a few things about Go in this tutorial too. 😁

Scott
