How to draw a multi-color line

How can I draw a multi-color line?
For example, I want to draw a line that has two color, red and blue. the red and blue appear alternately on the line.

By “alternately”, if you mean “red-then-blue-then-red-then-blue-then…”, then you could do something like:

      myDiagram.linkTemplate =
        $(go.Link,
          { routing: go.Link.AvoidsNodes, corner: 10 },
          $(go.Shape, { isPanelMain: true, strokeWidth: 2, strokeDashArray: [5, 5],
                        stroke: "red" }),
          $(go.Shape, { isPanelMain: true, strokeWidth: 2, strokeDashArray: [5, 5],
                        stroke: "blue", strokeDashOffset: 5 }),
          $(go.Shape, { toArrow: "OpenTriangle" })
        );

which produces:

Note that the link path consists of two Shapes. That requires setting GraphObject.isPanelMain to true on both of them.

This is what I want. Thanks